com.sun.slamd.scripting.general
Class IntegerVariable

java.lang.Object
  extended bycom.sun.slamd.scripting.engine.Variable
      extended bycom.sun.slamd.scripting.general.IntegerVariable
All Implemented Interfaces:
Argument

public class IntegerVariable
extends Variable

This class defines an integer variable that has an integer value. It also defines a set of methods for dealing with integer variables:


Field Summary
static int ADD_1_METHOD_NUMBER
          The method number for the first "add" method.
static int ADD_2_METHOD_NUMBER
          The method number for the second "add" method.
static java.lang.String ADD_METHOD_NAME
          The name of the method that will be used to add integer values.
static int AND_1_METHOD_NUMBER
          The method number for the first "and" method.
static int AND_2_METHOD_NUMBER
          The method number for the second "and" method.
static java.lang.String AND_METHOD_NAME
          The name of the method that will be used to perform bitwise AND operations.
static int ASSIGN_1_METHOD_NUMBER
          The method number for the first "assign" method.
static int ASSIGN_2_METHOD_NUMBER
          The method number for the second "assign" method.
static java.lang.String ASSIGN_METHOD_NAME
          The name of the method that will be used to specify the value of this integer variable.
static int DECREMENT_1_METHOD_NUMBER
          The method number for the first "decrement" method.
static int DECREMENT_2_METHOD_NUMBER
          The method number for the second "decrement" method.
static java.lang.String DECREMENT_METHOD_NAME
          The name of the method that will be used to decrement the value of this integer variable.
static int DIVIDE_1_METHOD_NUMBER
          The method number for the "divide" method.
static int DIVIDE_2_METHOD_NUMBER
          The method number for the "divideBy" method.
static java.lang.String DIVIDE_METHOD_NAME
          The name of the method that will be used to divide one integer value by another.
static int EQUALS_1_METHOD_NUMBER
          The method number for the first "equals" method.
static int EQUALS_2_METHOD_NUMBER
          The method number for the second "equals" method.
static java.lang.String EQUALS_METHOD_NAME
          The name of the method that will be used to determine whether the value of this integer variable is equal to the value of another integer variable.
static int GREATER_OR_EQUAL_1_METHOD_NUMBER
          The method number for the first "greaterThanOrEqualTo" method.
static int GREATER_OR_EQUAL_2_METHOD_NUMBER
          The method number for the second "greaterThanOrEqualTo" method.
static java.lang.String GREATER_OR_EQUAL_METHOD_NAME
          The name of the method that will be used to determine whether the value of this integer variable is greater than or equal to the value of another integer variable.
static int GREATER_THAN_1_METHOD_NUMBER
          The method number for the first "greaterThan" method.
static int GREATER_THAN_2_METHOD_NUMBER
          The method number for the second "greaterThan" method.
static java.lang.String GREATER_THAN_METHOD_NAME
          The name of the method that will be used to determine whether the value of this integer variable is greater than the value of another integer variable.
static int INCREMENT_1_METHOD_NUMBER
          The method number for the first "increment" method.
static int INCREMENT_2_METHOD_NUMBER
          The method number for the second "increment" method.
static java.lang.String INCREMENT_METHOD_NAME
          The name of the method that will be used to increment the value of this integer variable.
static Method[] INTEGER_VARIABLE_METHODS
          The set of methods associated with integer variables.
static java.lang.String INTEGER_VARIABLE_TYPE
          The name that will be used for the data type of integer variables.
static int LESS_OR_EQUAL_1_METHOD_NUMBER
          The method number for the first "lessThanOrEqualTo" method.
static int LESS_OR_EQUAL_2_METHOD_NUMBER
          The method number for the second "lessThanOrEqualTo" method.
static java.lang.String LESS_OR_EQUAL_METHOD_NAME
          The name of the method that will be used to determine whether the value of this integer variable is less than or equal to the value of another integer variable.
static int LESS_THAN_1_METHOD_NUMBER
          The method number for the first "lessThan" method.
static int LESS_THAN_2_METHOD_NUMBER
          The method number for the second "lessThan" method.
static java.lang.String LESS_THAN_METHOD_NAME
          The name of the method that will be used to determine whether the value of this integer variable is less than the value of another integer variable.
static int MULTIPLY_1_METHOD_NUMBER
          The method number for the "multiply" method.
static int MULTIPLY_2_METHOD_NUMBER
          The method number for the "multiplyBy" method.
static java.lang.String MULTIPLY_METHOD_NAME
          The name of the method that multiplies the values of two integer variables.
static int NOT_1_METHOD_NUMBER
          The method number for the first "not" method.
static int NOT_2_METHOD_NUMBER
          The method number for the second "not" method.
static int NOT_EQUAL_1_METHOD_NUMBER
          The method number for the first "notEqual" method.
static int NOT_EQUAL_2_METHOD_NUMBER
          The method number for the second "notEqual" method.
static java.lang.String NOT_EQUAL_METHOD_NAME
          The name of the method that will determine whether two integer values are not equal.
static java.lang.String NOT_METHOD_NAME
          The name of the method that will be used to perform bitwise NOT operations.
static int OR_1_METHOD_NUMBER
          The method number for the first "and" method.
static int OR_2_METHOD_NUMBER
          The method number for the second "and" method.
static java.lang.String OR_METHOD_NAME
          The name of the method that will be used to perform bitwise OR operations.
static int REMAINDER_1_METHOD_NUMBER
          The method number for the first "remainder" method.
static int REMAINDER_2_METHOD_NUMBER
          The method number for the second "remainder" method.
static java.lang.String REMAINDER_METHOD_NAME
          The name of the method that will determine the remainder when performing integer division between two values.
static int SUBTRACT_1_METHOD_NUMBER
          The method number for the first "subtract" method.
static int SUBTRACT_2_METHOD_NUMBER
          The method number for the second "subtract" method.
static java.lang.String SUBTRACT_METHOD_NAME
          The name of the method that subtracts the value of another integer variable from the value of this integer variable.
static java.lang.String TO_STRING_METHOD_NAME
          The name of the method that returns a string representation of this integer variable.
static int TO_STRING_METHOD_NUMBER
          The method number for the "toString" method.
static int XOR_1_METHOD_NUMBER
          The method number for the first "xor" method.
static int XOR_2_METHOD_NUMBER
          The method number for the second "xor" method.
static java.lang.String XOR_METHOD_NAME
          The name of the method that will be used to perform bitwise exclusive OR operations.
 
Constructor Summary
IntegerVariable()
          Creates a new variable with no name, to be used only when creating a variable with Class.newInstance(), and only when setName() is called after that to set the name.
IntegerVariable(int intValue)
          Creates a new integer variable with the specified value.
 
Method Summary
 void assign(Argument argument)
          Assigns the value of the provided argument to this variable.
 Variable executeMethod(int lineNumber, int methodNumber, Argument[] arguments)
          Executes the specified method, using the provided variables as arguments to the method, and makes the return value available to the caller.
 int getIntValue()
          Retrieves the int value associated with this integer variable.
 int getMethodNumber(java.lang.String methodName, java.lang.String[] argumentTypes)
          Retrieves the method number for the method that has the specified name and argument types, or -1 if there is no such method.
 Method[] getMethods()
          Retrieves a list of all methods defined for this variable.
 java.lang.String getReturnTypeForMethod(java.lang.String methodName, java.lang.String[] argumentTypes)
          Retrieves the return type for the method with the specified name and argument types.
 java.lang.String getValueAsString()
          Retrieves a string representation of the value of this argument.
 java.lang.String getVariableTypeName()
          Retrieves the name of the variable type for this variable.
 boolean hasMethod(java.lang.String methodName)
          Indicates whether this variable type has a method with the specified name.
 void setIntValue(int intValue)
          Specifies the value to use for this integer variable.
 
Methods inherited from class com.sun.slamd.scripting.engine.Variable
getArgumentAsString, getArgumentType, getArgumentValue, getName, getStatTrackers, isValidIdentifier, setName, startStatTrackers, stopStatTrackers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTEGER_VARIABLE_TYPE

public static final java.lang.String INTEGER_VARIABLE_TYPE
The name that will be used for the data type of integer variables.

See Also:
Constant Field Values

ADD_METHOD_NAME

public static final java.lang.String ADD_METHOD_NAME
The name of the method that will be used to add integer values.

See Also:
Constant Field Values

ADD_1_METHOD_NUMBER

public static final int ADD_1_METHOD_NUMBER
The method number for the first "add" method.

See Also:
Constant Field Values

ADD_2_METHOD_NUMBER

public static final int ADD_2_METHOD_NUMBER
The method number for the second "add" method.

See Also:
Constant Field Values

AND_METHOD_NAME

public static final java.lang.String AND_METHOD_NAME
The name of the method that will be used to perform bitwise AND operations.

See Also:
Constant Field Values

AND_1_METHOD_NUMBER

public static final int AND_1_METHOD_NUMBER
The method number for the first "and" method.

See Also:
Constant Field Values

AND_2_METHOD_NUMBER

public static final int AND_2_METHOD_NUMBER
The method number for the second "and" method.

See Also:
Constant Field Values

ASSIGN_METHOD_NAME

public static final java.lang.String ASSIGN_METHOD_NAME
The name of the method that will be used to specify the value of this integer variable.

See Also:
Constant Field Values

ASSIGN_1_METHOD_NUMBER

public static final int ASSIGN_1_METHOD_NUMBER
The method number for the first "assign" method.

See Also:
Constant Field Values

ASSIGN_2_METHOD_NUMBER

public static final int ASSIGN_2_METHOD_NUMBER
The method number for the second "assign" method.

See Also:
Constant Field Values

DECREMENT_METHOD_NAME

public static final java.lang.String DECREMENT_METHOD_NAME
The name of the method that will be used to decrement the value of this integer variable.

See Also:
Constant Field Values

DECREMENT_1_METHOD_NUMBER

public static final int DECREMENT_1_METHOD_NUMBER
The method number for the first "decrement" method.

See Also:
Constant Field Values

DECREMENT_2_METHOD_NUMBER

public static final int DECREMENT_2_METHOD_NUMBER
The method number for the second "decrement" method.

See Also:
Constant Field Values

DIVIDE_METHOD_NAME

public static final java.lang.String DIVIDE_METHOD_NAME
The name of the method that will be used to divide one integer value by another.

See Also:
Constant Field Values

DIVIDE_1_METHOD_NUMBER

public static final int DIVIDE_1_METHOD_NUMBER
The method number for the "divide" method.

See Also:
Constant Field Values

DIVIDE_2_METHOD_NUMBER

public static final int DIVIDE_2_METHOD_NUMBER
The method number for the "divideBy" method.

See Also:
Constant Field Values

EQUALS_METHOD_NAME

public static final java.lang.String EQUALS_METHOD_NAME
The name of the method that will be used to determine whether the value of this integer variable is equal to the value of another integer variable.

See Also:
Constant Field Values

EQUALS_1_METHOD_NUMBER

public static final int EQUALS_1_METHOD_NUMBER
The method number for the first "equals" method.

See Also:
Constant Field Values

EQUALS_2_METHOD_NUMBER

public static final int EQUALS_2_METHOD_NUMBER
The method number for the second "equals" method.

See Also:
Constant Field Values

GREATER_THAN_METHOD_NAME

public static final java.lang.String GREATER_THAN_METHOD_NAME
The name of the method that will be used to determine whether the value of this integer variable is greater than the value of another integer variable.

See Also:
Constant Field Values

GREATER_THAN_1_METHOD_NUMBER

public static final int GREATER_THAN_1_METHOD_NUMBER
The method number for the first "greaterThan" method.

See Also:
Constant Field Values

GREATER_THAN_2_METHOD_NUMBER

public static final int GREATER_THAN_2_METHOD_NUMBER
The method number for the second "greaterThan" method.

See Also:
Constant Field Values

GREATER_OR_EQUAL_METHOD_NAME

public static final java.lang.String GREATER_OR_EQUAL_METHOD_NAME
The name of the method that will be used to determine whether the value of this integer variable is greater than or equal to the value of another integer variable.

See Also:
Constant Field Values

GREATER_OR_EQUAL_1_METHOD_NUMBER

public static final int GREATER_OR_EQUAL_1_METHOD_NUMBER
The method number for the first "greaterThanOrEqualTo" method.

See Also:
Constant Field Values

GREATER_OR_EQUAL_2_METHOD_NUMBER

public static final int GREATER_OR_EQUAL_2_METHOD_NUMBER
The method number for the second "greaterThanOrEqualTo" method.

See Also:
Constant Field Values

INCREMENT_METHOD_NAME

public static final java.lang.String INCREMENT_METHOD_NAME
The name of the method that will be used to increment the value of this integer variable.

See Also:
Constant Field Values

INCREMENT_1_METHOD_NUMBER

public static final int INCREMENT_1_METHOD_NUMBER
The method number for the first "increment" method.

See Also:
Constant Field Values

INCREMENT_2_METHOD_NUMBER

public static final int INCREMENT_2_METHOD_NUMBER
The method number for the second "increment" method.

See Also:
Constant Field Values

LESS_THAN_METHOD_NAME

public static final java.lang.String LESS_THAN_METHOD_NAME
The name of the method that will be used to determine whether the value of this integer variable is less than the value of another integer variable.

See Also:
Constant Field Values

LESS_THAN_1_METHOD_NUMBER

public static final int LESS_THAN_1_METHOD_NUMBER
The method number for the first "lessThan" method.

See Also:
Constant Field Values

LESS_THAN_2_METHOD_NUMBER

public static final int LESS_THAN_2_METHOD_NUMBER
The method number for the second "lessThan" method.

See Also:
Constant Field Values

LESS_OR_EQUAL_METHOD_NAME

public static final java.lang.String LESS_OR_EQUAL_METHOD_NAME
The name of the method that will be used to determine whether the value of this integer variable is less than or equal to the value of another integer variable.

See Also:
Constant Field Values

LESS_OR_EQUAL_1_METHOD_NUMBER

public static final int LESS_OR_EQUAL_1_METHOD_NUMBER
The method number for the first "lessThanOrEqualTo" method.

See Also:
Constant Field Values

LESS_OR_EQUAL_2_METHOD_NUMBER

public static final int LESS_OR_EQUAL_2_METHOD_NUMBER
The method number for the second "lessThanOrEqualTo" method.

See Also:
Constant Field Values

MULTIPLY_METHOD_NAME

public static final java.lang.String MULTIPLY_METHOD_NAME
The name of the method that multiplies the values of two integer variables.

See Also:
Constant Field Values

MULTIPLY_1_METHOD_NUMBER

public static final int MULTIPLY_1_METHOD_NUMBER
The method number for the "multiply" method.

See Also:
Constant Field Values

MULTIPLY_2_METHOD_NUMBER

public static final int MULTIPLY_2_METHOD_NUMBER
The method number for the "multiplyBy" method.

See Also:
Constant Field Values

NOT_METHOD_NAME

public static final java.lang.String NOT_METHOD_NAME
The name of the method that will be used to perform bitwise NOT operations.

See Also:
Constant Field Values

NOT_1_METHOD_NUMBER

public static final int NOT_1_METHOD_NUMBER
The method number for the first "not" method.

See Also:
Constant Field Values

NOT_2_METHOD_NUMBER

public static final int NOT_2_METHOD_NUMBER
The method number for the second "not" method.

See Also:
Constant Field Values

NOT_EQUAL_METHOD_NAME

public static final java.lang.String NOT_EQUAL_METHOD_NAME
The name of the method that will determine whether two integer values are not equal.

See Also:
Constant Field Values

NOT_EQUAL_1_METHOD_NUMBER

public static final int NOT_EQUAL_1_METHOD_NUMBER
The method number for the first "notEqual" method.

See Also:
Constant Field Values

NOT_EQUAL_2_METHOD_NUMBER

public static final int NOT_EQUAL_2_METHOD_NUMBER
The method number for the second "notEqual" method.

See Also:
Constant Field Values

OR_METHOD_NAME

public static final java.lang.String OR_METHOD_NAME
The name of the method that will be used to perform bitwise OR operations.

See Also:
Constant Field Values

OR_1_METHOD_NUMBER

public static final int OR_1_METHOD_NUMBER
The method number for the first "and" method.

See Also:
Constant Field Values

OR_2_METHOD_NUMBER

public static final int OR_2_METHOD_NUMBER
The method number for the second "and" method.

See Also:
Constant Field Values

REMAINDER_METHOD_NAME

public static final java.lang.String REMAINDER_METHOD_NAME
The name of the method that will determine the remainder when performing integer division between two values.

See Also:
Constant Field Values

REMAINDER_1_METHOD_NUMBER

public static final int REMAINDER_1_METHOD_NUMBER
The method number for the first "remainder" method.

See Also:
Constant Field Values

REMAINDER_2_METHOD_NUMBER

public static final int REMAINDER_2_METHOD_NUMBER
The method number for the second "remainder" method.

See Also:
Constant Field Values

SUBTRACT_METHOD_NAME

public static final java.lang.String SUBTRACT_METHOD_NAME
The name of the method that subtracts the value of another integer variable from the value of this integer variable.

See Also:
Constant Field Values

SUBTRACT_1_METHOD_NUMBER

public static final int SUBTRACT_1_METHOD_NUMBER
The method number for the first "subtract" method.

See Also:
Constant Field Values

SUBTRACT_2_METHOD_NUMBER

public static final int SUBTRACT_2_METHOD_NUMBER
The method number for the second "subtract" method.

See Also:
Constant Field Values

TO_STRING_METHOD_NAME

public static final java.lang.String TO_STRING_METHOD_NAME
The name of the method that returns a string representation of this integer variable.

See Also:
Constant Field Values

TO_STRING_METHOD_NUMBER

public static final int TO_STRING_METHOD_NUMBER
The method number for the "toString" method.

See Also:
Constant Field Values

XOR_METHOD_NAME

public static final java.lang.String XOR_METHOD_NAME
The name of the method that will be used to perform bitwise exclusive OR operations.

See Also:
Constant Field Values

XOR_1_METHOD_NUMBER

public static final int XOR_1_METHOD_NUMBER
The method number for the first "xor" method.

See Also:
Constant Field Values

XOR_2_METHOD_NUMBER

public static final int XOR_2_METHOD_NUMBER
The method number for the second "xor" method.

See Also:
Constant Field Values

INTEGER_VARIABLE_METHODS

public static final Method[] INTEGER_VARIABLE_METHODS
The set of methods associated with integer variables.

Constructor Detail

IntegerVariable

public IntegerVariable()
                throws ScriptException
Creates a new variable with no name, to be used only when creating a variable with Class.newInstance(), and only when setName() is called after that to set the name.

Throws:
ScriptException - If a problem occurs while initializing the new variable.

IntegerVariable

public IntegerVariable(int intValue)
Creates a new integer variable with the specified value.

Parameters:
intValue - The value to use for this integer variable.
Method Detail

getIntValue

public int getIntValue()
Retrieves the int value associated with this integer variable.

Returns:
The int value associated with this integer variable.

setIntValue

public void setIntValue(int intValue)
Specifies the value to use for this integer variable.

Parameters:
intValue - The value to use for this integer variable.

getVariableTypeName

public java.lang.String getVariableTypeName()
Retrieves the name of the variable type for this variable.

Specified by:
getVariableTypeName in class Variable
Returns:
The name of the variable type for this variable.

getMethods

public Method[] getMethods()
Retrieves a list of all methods defined for this variable.

Specified by:
getMethods in class Variable
Returns:
A list of all methods defined for this variable.

hasMethod

public boolean hasMethod(java.lang.String methodName)
Indicates whether this variable type has a method with the specified name.

Specified by:
hasMethod in class Variable
Parameters:
methodName - The name of the method.
Returns:
true if this variable has a method with the specified name, or false if it does not.

getMethodNumber

public int getMethodNumber(java.lang.String methodName,
                           java.lang.String[] argumentTypes)
Retrieves the method number for the method that has the specified name and argument types, or -1 if there is no such method.

Specified by:
getMethodNumber in class Variable
Parameters:
methodName - The name of the method.
argumentTypes - The list of argument types for the method.
Returns:
The method number for the method that has the specified name and argument types.

getReturnTypeForMethod

public java.lang.String getReturnTypeForMethod(java.lang.String methodName,
                                               java.lang.String[] argumentTypes)
Retrieves the return type for the method with the specified name and argument types.

Specified by:
getReturnTypeForMethod in class Variable
Parameters:
methodName - The name of the method.
argumentTypes - The set of argument types for the method.
Returns:
The return type for the method, or null if there is no such method defined.

executeMethod

public Variable executeMethod(int lineNumber,
                              int methodNumber,
                              Argument[] arguments)
                       throws ScriptException
Executes the specified method, using the provided variables as arguments to the method, and makes the return value available to the caller.

Specified by:
executeMethod in class Variable
Parameters:
lineNumber - The line number of the script in which the method call occurs.
methodNumber - The method number of the method to execute.
arguments - The set of arguments to use for the method.
Returns:
The value returned from the method, or null if it does not return a value.
Throws:
ScriptException - If the specified method does not exist, or if a problem occurs while attempting to execute it.

assign

public void assign(Argument argument)
            throws ScriptException
Assigns the value of the provided argument to this variable. The value of the provided argument must be of the same type as this variable.

Specified by:
assign in class Variable
Parameters:
argument - The argument whose value should be assigned to this variable.
Throws:
ScriptException - If a problem occurs while performing the assignment.

getValueAsString

public java.lang.String getValueAsString()
Retrieves a string representation of the value of this argument.

Returns:
A string representation of the value of this argument.