Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2015 The Pennsylvania State University and the University of Wisconsin
   * Systems and Internet Infrastructure Security Laboratory
   *
   * Author: Damien Octeau
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package edu.psu.cse.siis.coal.arguments;
 
 import java.util.Map;

An argument for a modifier or a hotspot.
 
 public class Argument implements Serializable {
   private static final long serialVersionUID = 1L;
 
   private int[] argnum;
   private String type;
   private String[] actions;
   private String[] inlineValues;
   private Map<StringStringproperties;
   private short count = -1;
   private Field field;
   private String referencedFieldName;
 
   public Argument() {
   }
 
   public Argument(Argument other) {
     this. = other.argnum;
     this. = other.type;
     this. = other.field;
     this. = other.actions;
     this. = other.inlineValues;
     if (other.properties != null) {
       this. = new HashMap<>(other.properties);
     }
     this. = other.count;
   }

  
Sets the argument number. It is an array of integers because a modifier argument may be given by several actual method arguments. The way that arguments are determined is specified by the argument analysis that is registered for this argument type.

Parameters:
argnum The argument number.
 
   public void setArgnum(int[] argnum) {
     this. = argnum;
   }

  
Sets the type of the argument. The specified type should be registered using ArgumentValueManager.registerArgumentValueAnalysis(java.lang.String,edu.psu.cse.siis.coal.arguments.ArgumentValueAnalysis).

Parameters:
type The argument type.
 
   public void setType(String type) {
     this. = type;
   }

  
Sets the field to which the argument refers.

Parameters:
field The field to set.
 
   public void setField(Field field) {
     this. = field;
   }

  
Sets the actions to be performed with the argument. If more than one action is specified, all action are composed in the order that they are specified. Any action specified here should be registered using registerFieldTransformerFactory .

Parameters:
actions The actions to be performed.
 
   public void setActions(String[] actions) {
     this. = actions;
   }

  
Sets the inline values for the argument. Inline values are specified in COAL when the value of an argument is always the same. If more than one value is specified, then they lead to several different field transformers.

Parameters:
inlineValues The inline values to set.
  public void setInlineValues(String[] inlineValues) {
    this. = inlineValues;
  }

  
Adds a property for this argument. Properties are key-value pairs that can be specified in the COAL specification and retrieve later, for example when processing the results of the analysis.

Parameters:
key A key.
value A value associated with the argument key.
  public void addProperty(String keyString value) {
    if (this. == null) {
      this. = new HashMap<>();
    }
    this..put(keyvalue);
  }

  
Sets the number of values expected to be associated with a field. If this is set to 1, then the argument cannot have more than one value, so do not set to 1 unless the field cannot contain more than one value. For example, this can be useful when a field is a single string and not a set of strings.

Parameters:
count The expected count.
  public void setCount(short count) {
    this. = count;
  }

  
Sets the name of a referenced field. This is useful when an argument is a value modeled using COAL. This specifies which field from the modeled value we are interested in.

Parameters:
referencedFieldName The referenced field name.
  public void setReferencedFieldName(String referencedFieldName) {
    this. = referencedFieldName;
  }

  
Returns the argument number for this argument. It is an array of integers because a modifier argument may be given by several actual method arguments. The way that arguments are determined is specified by the argument analysis that is registered for this argument type.

Returns:
The argument number.
  public int[] getArgnum() {
    return ;
  }

  
Returns the type of the field influenced by this argument.

Returns:
The field type.
  public String getType() {
    if ( == null) {
      return .getType();
    }
    return ;
  }

  
Returns the nominal field type for the field modified by this argument. This is the type declared for the field. The argument value analysis used to determine the argument is the one returned by getType().

Returns:
The nominal field type.
  public String getNominalFieldType() {
    return .getType();
  }

  
Returns the name of the field modified by this argument.

Returns:
The field name.
  public String getFieldName() {
    return .getName();
  }

  
Returns the operations performed by this argument on the field.

Returns:
The operations performed by this argument on the field.
  public String[] getActions() {
    return ;
  }

  
Returns the inline values for the argument. Inline values are specified in COAL when the value of an argument is always the same. If more than one value is specified, then they lead to several different field transformers.

Returns:
The inline values for the argument.
  public String[] getInlineValues() {
    return ;
  }

  
Returns the property for a given key.

Parameters:
key A key.
Returns:
The property for the key.
  public String getProperty(String key) {
    if (this. == null) {
      return null;
    }
    return this..get(key);
  }

  
Returns the map of properties for this argument. Properties are key-value pairs that can be specified in the COAL specification and retrieve later, for example when processing the results of the analysis.

Returns:
The properties for this argument.
  public Map<StringStringgetProperties() {
    return this.;
  }

  
Returns the referenced field name for an argument that is a COAL value. This specifies which field from the modeled value we are interested in.

Returns:
The referenced field name.
    return this.;
  }

  
Returns the number of expected values for the field modified by this argument.

Returns:
The expected count.
  public short getCount() {
    return this.;
  }
  public String toString() {
    StringBuilder result = new StringBuilder();
    boolean first = true;
    if (getArgnum() != null) {
      result.append("(");
      for (int argnum : getArgnum()) {
        if (first) {
          first = false;
        } else {
          result.append(",");
        }
        result.append(argnum);
      }
      result.append(") ");
    }
    result.append(getType());
    result.append(" ");
    result.append(getFieldName());
    result.append(" ");
    if (getActions() != null) {
      result.append("(");
      first = true;
      for (String action : getActions()) {
        if (first) {
          first = false;
        } else {
          result.append(",");
        }
        result.append(action);
      }
      result.append(")");
    }
    result.append(" ");
    if (getInlineValues() != null) {
      result.append("(");
      first = true;
      for (String inlineValue : getInlineValues()) {
        if (first) {
          first = false;
        } else {
          result.append(",");
        }
        result.append(inlineValue);
      }
      result.append(")");
    }
    return result.toString();
  }
New to GrepCode? Check out our FAQ X