com.sun.slamd.scripting.general
Class ScriptVariable

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

public class ScriptVariable
extends Variable

This class defines a set of methods that may be called during script execution to perform various tasks. These methods are:


Field Summary
static char[] ALPHABET
          The set of characters that will be used to generate random string values.
static java.lang.String DEBUG_MESSAGE_METHOD_NAME
          The name of the method that can be used to write debug messages to the client's debug writer.
static int DEBUG_MESSAGE_METHOD_NUMBER
          The method number for the "debugMessage" method.
static java.lang.String EXIT_METHOD_NAME
          The name of the method that will be used to stop execution of the script.
static int EXIT_METHOD_NUMBER
          The method number for the "exit" method.
static java.lang.String EXIT_WITH_ERROR_METHOD_NAME
          The name of the method that will be used to stop execution of the script and indicate that an error occurred.
static int EXIT_WITH_ERROR_METHOD_NUMBER
          The method number for the "exitWithError" method.
static int GET_SCRIPT_ARGUMENT_1_METHOD_NUMBER
          The method number for the first "getScriptArgument" method.
static int GET_SCRIPT_ARGUMENT_2_METHOD_NUMBER
          The method number for the second "getScriptArgument" method.
static java.lang.String GET_SCRIPT_ARGUMENT_METHOD_NAME
          The name of the method that will be used to get argument information provided at the time the job was scheduled.
static java.lang.String GET_SCRIPT_BOOLEAN_ARGUMENT_METHOD_NAME
          The name of the method that will be used to get the boolean value of an argument provided at the time the job was scheduled.
static int GET_SCRIPT_BOOLEAN_ARGUMENT_METHOD_NUMBER
          The method number for the "getScriptBooleanArgument" method.
static java.lang.String GET_SCRIPT_INT_ARGUMENT_METHOD_NAME
          The name of the method that will be used to get the integer value of an argument provided at the time the job was scheduled.
static int GET_SCRIPT_INT_ARGUMENT_METHOD_NUMBER
          The method number for the "getScriptIntArgument" method.
static java.lang.String LOG_MESSAGE_METHOD_NAME
          The name of the method that will be used to write messages to the SLAMD log.
static int LOG_MESSAGE_METHOD_NUMBER
          The method number for the "logMessage" method.
static java.lang.String RANDOM_INT_METHOD_NAME
          The name of the method that will be used to generate a random integer value.
static int RANDOM_INT_METHOD_NUMBER
          The method number for the "randomInt" method.
static int RANDOM_STRING_1_METHOD_NUMBER
          The method number for the first "randomString" method.
static int RANDOM_STRING_2_METHOD_NUMBER
          The method number for the second "randomString" method.
static java.lang.String RANDOM_STRING_METHOD_NAME
          The name of the method that will be used to generate a random string value.
static Method[] SCRIPT_VARIABLE_METHODS
          The set of methods associated with script variables.
static java.lang.String SHOULD_NOT_STOP_METHOD_NAME
          The name of the method that will be used to determine whether the script has not yet been requested to stop runing.
static int SHOULD_NOT_STOP_METHOD_NUMBER
          The method number for the "shouldNotStop" method.
static java.lang.String SHOULD_STOP_METHOD_NAME
          The name of the method that will be used to determine whether the script should stop running.
static int SHOULD_STOP_METHOD_NUMBER
          The method number for the "shouldStop" method.
static java.lang.String SLEEP_METHOD_NAME
          The name of the method that will be used to pause execution of the script.
static int SLEEP_METHOD_NUMBER
          The method number for the "sleep" method.
static int TIMESTAMP_1_METHOD_NUMBER
          The method number for the first "timestamp" method.
static int TIMESTAMP_2_METHOD_NUMBER
          The method number for the second "timestamp" method.
static java.lang.String TIMESTAMP_METHOD_NAME
          The name of the method that will be used to generate a timestamp.
 
Constructor Summary
ScriptVariable()
          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.
 
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 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 setJobThread(JobClass jobThread)
          Associates this instance of the script variable with the job thread that is running it.
 void setParser(ScriptParser parser)
          Associates this instance of the script variable with the script parser in which it is defined.
 
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

ALPHABET

public static final char[] ALPHABET
The set of characters that will be used to generate random string values.


DEBUG_MESSAGE_METHOD_NAME

public static final java.lang.String DEBUG_MESSAGE_METHOD_NAME
The name of the method that can be used to write debug messages to the client's debug writer.

See Also:
Constant Field Values

DEBUG_MESSAGE_METHOD_NUMBER

public static final int DEBUG_MESSAGE_METHOD_NUMBER
The method number for the "debugMessage" method.

See Also:
Constant Field Values

EXIT_METHOD_NAME

public static final java.lang.String EXIT_METHOD_NAME
The name of the method that will be used to stop execution of the script.

See Also:
Constant Field Values

EXIT_METHOD_NUMBER

public static final int EXIT_METHOD_NUMBER
The method number for the "exit" method.

See Also:
Constant Field Values

EXIT_WITH_ERROR_METHOD_NAME

public static final java.lang.String EXIT_WITH_ERROR_METHOD_NAME
The name of the method that will be used to stop execution of the script and indicate that an error occurred.

See Also:
Constant Field Values

EXIT_WITH_ERROR_METHOD_NUMBER

public static final int EXIT_WITH_ERROR_METHOD_NUMBER
The method number for the "exitWithError" method.

See Also:
Constant Field Values

GET_SCRIPT_ARGUMENT_METHOD_NAME

public static final java.lang.String GET_SCRIPT_ARGUMENT_METHOD_NAME
The name of the method that will be used to get argument information provided at the time the job was scheduled.

See Also:
Constant Field Values

GET_SCRIPT_ARGUMENT_1_METHOD_NUMBER

public static final int GET_SCRIPT_ARGUMENT_1_METHOD_NUMBER
The method number for the first "getScriptArgument" method.

See Also:
Constant Field Values

GET_SCRIPT_ARGUMENT_2_METHOD_NUMBER

public static final int GET_SCRIPT_ARGUMENT_2_METHOD_NUMBER
The method number for the second "getScriptArgument" method.

See Also:
Constant Field Values

GET_SCRIPT_BOOLEAN_ARGUMENT_METHOD_NAME

public static final java.lang.String GET_SCRIPT_BOOLEAN_ARGUMENT_METHOD_NAME
The name of the method that will be used to get the boolean value of an argument provided at the time the job was scheduled.

See Also:
Constant Field Values

GET_SCRIPT_BOOLEAN_ARGUMENT_METHOD_NUMBER

public static final int GET_SCRIPT_BOOLEAN_ARGUMENT_METHOD_NUMBER
The method number for the "getScriptBooleanArgument" method.

See Also:
Constant Field Values

GET_SCRIPT_INT_ARGUMENT_METHOD_NAME

public static final java.lang.String GET_SCRIPT_INT_ARGUMENT_METHOD_NAME
The name of the method that will be used to get the integer value of an argument provided at the time the job was scheduled.

See Also:
Constant Field Values

GET_SCRIPT_INT_ARGUMENT_METHOD_NUMBER

public static final int GET_SCRIPT_INT_ARGUMENT_METHOD_NUMBER
The method number for the "getScriptIntArgument" method.

See Also:
Constant Field Values

LOG_MESSAGE_METHOD_NAME

public static final java.lang.String LOG_MESSAGE_METHOD_NAME
The name of the method that will be used to write messages to the SLAMD log.

See Also:
Constant Field Values

LOG_MESSAGE_METHOD_NUMBER

public static final int LOG_MESSAGE_METHOD_NUMBER
The method number for the "logMessage" method.

See Also:
Constant Field Values

RANDOM_INT_METHOD_NAME

public static final java.lang.String RANDOM_INT_METHOD_NAME
The name of the method that will be used to generate a random integer value.

See Also:
Constant Field Values

RANDOM_INT_METHOD_NUMBER

public static final int RANDOM_INT_METHOD_NUMBER
The method number for the "randomInt" method.

See Also:
Constant Field Values

RANDOM_STRING_METHOD_NAME

public static final java.lang.String RANDOM_STRING_METHOD_NAME
The name of the method that will be used to generate a random string value.

See Also:
Constant Field Values

RANDOM_STRING_1_METHOD_NUMBER

public static final int RANDOM_STRING_1_METHOD_NUMBER
The method number for the first "randomString" method.

See Also:
Constant Field Values

RANDOM_STRING_2_METHOD_NUMBER

public static final int RANDOM_STRING_2_METHOD_NUMBER
The method number for the second "randomString" method.

See Also:
Constant Field Values

SHOULD_NOT_STOP_METHOD_NAME

public static final java.lang.String SHOULD_NOT_STOP_METHOD_NAME
The name of the method that will be used to determine whether the script has not yet been requested to stop runing.

See Also:
Constant Field Values

SHOULD_NOT_STOP_METHOD_NUMBER

public static final int SHOULD_NOT_STOP_METHOD_NUMBER
The method number for the "shouldNotStop" method.

See Also:
Constant Field Values

SHOULD_STOP_METHOD_NAME

public static final java.lang.String SHOULD_STOP_METHOD_NAME
The name of the method that will be used to determine whether the script should stop running.

See Also:
Constant Field Values

SHOULD_STOP_METHOD_NUMBER

public static final int SHOULD_STOP_METHOD_NUMBER
The method number for the "shouldStop" method.

See Also:
Constant Field Values

SLEEP_METHOD_NAME

public static final java.lang.String SLEEP_METHOD_NAME
The name of the method that will be used to pause execution of the script.

See Also:
Constant Field Values

SLEEP_METHOD_NUMBER

public static final int SLEEP_METHOD_NUMBER
The method number for the "sleep" method.

See Also:
Constant Field Values

TIMESTAMP_METHOD_NAME

public static final java.lang.String TIMESTAMP_METHOD_NAME
The name of the method that will be used to generate a timestamp.

See Also:
Constant Field Values

TIMESTAMP_1_METHOD_NUMBER

public static final int TIMESTAMP_1_METHOD_NUMBER
The method number for the first "timestamp" method.

See Also:
Constant Field Values

TIMESTAMP_2_METHOD_NUMBER

public static final int TIMESTAMP_2_METHOD_NUMBER
The method number for the second "timestamp" method.

See Also:
Constant Field Values

SCRIPT_VARIABLE_METHODS

public static final Method[] SCRIPT_VARIABLE_METHODS
The set of methods associated with script variables.

Constructor Detail

ScriptVariable

public ScriptVariable()
               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.
Method Detail

setJobThread

public void setJobThread(JobClass jobThread)
Associates this instance of the script variable with the job thread that is running it.

Parameters:
jobThread - THe job thread that is running this script.

setParser

public void setParser(ScriptParser parser)
Associates this instance of the script variable with the script parser in which it is defined.

Parameters:
parser - The script parser with which this script variable is being used.

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.