com.sun.slamd.scripting.general
Class StringArrayVariable

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

public class StringArrayVariable
extends Variable

This class defines a string array variable that holds zero or more string values. It also defines a set of methods for dealing with string array variables:


Field Summary
static java.lang.String ADD_VALUE_METHOD_NAME
          The name of the method that will be used to add a new value to this array.
static int ADD_VALUE_METHOD_NUMBER
          The method number for the "addValue" method.
static java.lang.String ASSIGN_METHOD_NAME
          The name of the method that will be used to initialize this array.
static int ASSIGN_METHOD_NUMBER
          The method number for the "assign" method.
static java.lang.String CONTAINS_METHOD_NAME
          The name of the method that will be used to determine if this method contains the specified value.
static int CONTAINS_METHOD_NUMBER
          The method number for the "contains" method.
static java.lang.String FIRST_VALUE_METHOD_NAME
          The name of the method that will be used to retrieve the first value from this array.
static int FIRST_VALUE_METHOD_NUMBER
          The method number for the "firstValue" method.
static int INDEX_OF_1_METHOD_NUMBER
          The method number for the first "indexOf" method.
static int INDEX_OF_2_METHOD_NUMBER
          The method number for the second "indexOf" method.
static java.lang.String INDEX_OF_METHOD_NAME
          The name of the method that will be used to determine the position of the specified value.
static java.lang.String INSERT_METHOD_NAME
          The name of the method that will be used to insert a value into this array.
static int INSERT_METHOD_NUMBER
          The method number for the "insert" method.
static java.lang.String IS_EMPTY_METHOD_NAME
          The name of the method that will determine if this array is empty.
static int IS_EMPTY_METHOD_NUMBER
          The method number for the "isEmpty" method.
static java.lang.String IS_NOT_EMPTY_METHOD_NAME
          The name of the method that will determine if this array is not empty.
static int IS_NOT_EMPTY_METHOD_NUMBER
          The method number for the "isNotEmpty" method.
static java.lang.String LENGTH_METHOD_NAME
          The name of the method that will be used to determine the number of elements in this array.
static int LENGTH_METHOD_NUMBER
          The method number for the "length" method.
static java.lang.String NEXT_VALUE_METHOD_NAME
          The name of the method that will be used to retrieve the next value from the array.
static int NEXT_VALUE_METHOD_NUMBER
          The method number for the "nextValue" method.
static java.lang.String RANDOM_VALUE_METHOD_NAME
          The name of the method that will be used to retrive a random value from the array.
static int RANDOM_VALUE_METHOD_NUMBER
          the method number for the "randomValue" method.
static java.lang.String REMOVE_ALL_METHOD_NAME
          The name of the method that will be used to remove all values from this array.
static int REMOVE_ALL_METHOD_NUMBER
          The method number for the "removeAll" method.
static java.lang.String REMOVE_METHOD_NAME
          The name of the method that will be used to remove a value from this array.
static int REMOVE_METHOD_NUMBER
          The method number for the "remove" method.
static java.lang.String REMOVE_VALUE_AT_METHOD_NAME
          The name of the method that will be used to remove the value at the specified position from the array.
static int REMOVE_VALUE_AT_METHOD_NUMBER
          The method number for the "removeValueAt" method.
static java.lang.String SET_VALUE_AT_METHOD_NAME
          The name of the method that will be used to set the value at the specified position in the array.
static int SET_VALUE_AT_METHOD_NUMBER
          The method number for the "setValueAt" method.
static Method[] STRING_ARRAY_VARIABLE_METHODS
          The set of methods associated with string array variables.
static java.lang.String STRING_ARRAY_VARIABLE_TYPE
          The name that will be used for the data type of string array variables.
static java.lang.String VALUE_AT_METHOD_NAME
          The name of the method that will be used to retrieve the value at the specified position in the array.
static int VALUE_AT_METHOD_NUMBER
          The method number for the "valueAt" method.
 
Constructor Summary
StringArrayVariable()
          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.
StringArrayVariable(java.lang.String[] values)
          Creates a new string array variable with the specified set of values.
 
Method Summary
 void addStringValue(java.lang.String stringValue)
          Adds the specified value to this string array.
 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 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[] getStringValues()
          Retrieves the set of string values associated with this variable.
 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 setStringValues(java.lang.String[] stringValues)
          Specifies the set of string values for this 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

STRING_ARRAY_VARIABLE_TYPE

public static final java.lang.String STRING_ARRAY_VARIABLE_TYPE
The name that will be used for the data type of string array variables.

See Also:
Constant Field Values

ADD_VALUE_METHOD_NAME

public static final java.lang.String ADD_VALUE_METHOD_NAME
The name of the method that will be used to add a new value to this array.

See Also:
Constant Field Values

ADD_VALUE_METHOD_NUMBER

public static final int ADD_VALUE_METHOD_NUMBER
The method number for the "addValue" 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 initialize this array.

See Also:
Constant Field Values

ASSIGN_METHOD_NUMBER

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

See Also:
Constant Field Values

CONTAINS_METHOD_NAME

public static final java.lang.String CONTAINS_METHOD_NAME
The name of the method that will be used to determine if this method contains the specified value.

See Also:
Constant Field Values

CONTAINS_METHOD_NUMBER

public static final int CONTAINS_METHOD_NUMBER
The method number for the "contains" method.

See Also:
Constant Field Values

FIRST_VALUE_METHOD_NAME

public static final java.lang.String FIRST_VALUE_METHOD_NAME
The name of the method that will be used to retrieve the first value from this array.

See Also:
Constant Field Values

FIRST_VALUE_METHOD_NUMBER

public static final int FIRST_VALUE_METHOD_NUMBER
The method number for the "firstValue" method.

See Also:
Constant Field Values

INDEX_OF_METHOD_NAME

public static final java.lang.String INDEX_OF_METHOD_NAME
The name of the method that will be used to determine the position of the specified value.

See Also:
Constant Field Values

INDEX_OF_1_METHOD_NUMBER

public static final int INDEX_OF_1_METHOD_NUMBER
The method number for the first "indexOf" method.

See Also:
Constant Field Values

INDEX_OF_2_METHOD_NUMBER

public static final int INDEX_OF_2_METHOD_NUMBER
The method number for the second "indexOf" method.

See Also:
Constant Field Values

INSERT_METHOD_NAME

public static final java.lang.String INSERT_METHOD_NAME
The name of the method that will be used to insert a value into this array.

See Also:
Constant Field Values

INSERT_METHOD_NUMBER

public static final int INSERT_METHOD_NUMBER
The method number for the "insert" method.

See Also:
Constant Field Values

IS_EMPTY_METHOD_NAME

public static final java.lang.String IS_EMPTY_METHOD_NAME
The name of the method that will determine if this array is empty.

See Also:
Constant Field Values

IS_EMPTY_METHOD_NUMBER

public static final int IS_EMPTY_METHOD_NUMBER
The method number for the "isEmpty" method.

See Also:
Constant Field Values

IS_NOT_EMPTY_METHOD_NAME

public static final java.lang.String IS_NOT_EMPTY_METHOD_NAME
The name of the method that will determine if this array is not empty.

See Also:
Constant Field Values

IS_NOT_EMPTY_METHOD_NUMBER

public static final int IS_NOT_EMPTY_METHOD_NUMBER
The method number for the "isNotEmpty" method.

See Also:
Constant Field Values

LENGTH_METHOD_NAME

public static final java.lang.String LENGTH_METHOD_NAME
The name of the method that will be used to determine the number of elements in this array.

See Also:
Constant Field Values

LENGTH_METHOD_NUMBER

public static final int LENGTH_METHOD_NUMBER
The method number for the "length" method.

See Also:
Constant Field Values

NEXT_VALUE_METHOD_NAME

public static final java.lang.String NEXT_VALUE_METHOD_NAME
The name of the method that will be used to retrieve the next value from the array.

See Also:
Constant Field Values

NEXT_VALUE_METHOD_NUMBER

public static final int NEXT_VALUE_METHOD_NUMBER
The method number for the "nextValue" method.

See Also:
Constant Field Values

RANDOM_VALUE_METHOD_NAME

public static final java.lang.String RANDOM_VALUE_METHOD_NAME
The name of the method that will be used to retrive a random value from the array.

See Also:
Constant Field Values

RANDOM_VALUE_METHOD_NUMBER

public static final int RANDOM_VALUE_METHOD_NUMBER
the method number for the "randomValue" method.

See Also:
Constant Field Values

REMOVE_METHOD_NAME

public static final java.lang.String REMOVE_METHOD_NAME
The name of the method that will be used to remove a value from this array.

See Also:
Constant Field Values

REMOVE_METHOD_NUMBER

public static final int REMOVE_METHOD_NUMBER
The method number for the "remove" method.

See Also:
Constant Field Values

REMOVE_ALL_METHOD_NAME

public static final java.lang.String REMOVE_ALL_METHOD_NAME
The name of the method that will be used to remove all values from this array.

See Also:
Constant Field Values

REMOVE_ALL_METHOD_NUMBER

public static final int REMOVE_ALL_METHOD_NUMBER
The method number for the "removeAll" method.

See Also:
Constant Field Values

REMOVE_VALUE_AT_METHOD_NAME

public static final java.lang.String REMOVE_VALUE_AT_METHOD_NAME
The name of the method that will be used to remove the value at the specified position from the array.

See Also:
Constant Field Values

REMOVE_VALUE_AT_METHOD_NUMBER

public static final int REMOVE_VALUE_AT_METHOD_NUMBER
The method number for the "removeValueAt" method.

See Also:
Constant Field Values

SET_VALUE_AT_METHOD_NAME

public static final java.lang.String SET_VALUE_AT_METHOD_NAME
The name of the method that will be used to set the value at the specified position in the array.

See Also:
Constant Field Values

SET_VALUE_AT_METHOD_NUMBER

public static final int SET_VALUE_AT_METHOD_NUMBER
The method number for the "setValueAt" method.

See Also:
Constant Field Values

VALUE_AT_METHOD_NAME

public static final java.lang.String VALUE_AT_METHOD_NAME
The name of the method that will be used to retrieve the value at the specified position in the array.

See Also:
Constant Field Values

VALUE_AT_METHOD_NUMBER

public static final int VALUE_AT_METHOD_NUMBER
The method number for the "valueAt" method.

See Also:
Constant Field Values

STRING_ARRAY_VARIABLE_METHODS

public static final Method[] STRING_ARRAY_VARIABLE_METHODS
The set of methods associated with string array variables.

Constructor Detail

StringArrayVariable

public StringArrayVariable()
                    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.

StringArrayVariable

public StringArrayVariable(java.lang.String[] values)
Creates a new string array variable with the specified set of values.

Parameters:
values - The set of values to use for this string array variable.
Method Detail

getStringValues

public java.lang.String[] getStringValues()
Retrieves the set of string values associated with this variable.

Returns:
The set of string values associated with this variable.

setStringValues

public void setStringValues(java.lang.String[] stringValues)
Specifies the set of string values for this variable.

Parameters:
stringValues - The set of string values for this variable.

addStringValue

public void addStringValue(java.lang.String stringValue)
Adds the specified value to this string array.

Parameters:
stringValue - The value to add to this string array.

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.