com.sun.slamd.scripting.general
Class CategoricalTrackerVariable

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

public class CategoricalTrackerVariable
extends Variable

This class defines a variable that may be added to a script to act as a categorical tracker. It also defines a set of methods for dealing with categorical trackers:


Field Summary
static Method[] CATEGORICAL_TRACKER_VARIABLE_METHODS
          The set of methods associated with categorical tracker variables.
static java.lang.String CATEGORICAL_TRACKER_VARIABLE_TYPE
          The name that will be used for the data type of categorical tracker variables.
static java.lang.String INCREMENT_METHOD_NAME
          The name of the method that will be used to increment the value of the tracker for a particular category.
static int INCREMENT_METHOD_NUMBER
          The method number for the "increment" method.
static java.lang.String SET_DISPLAY_NAME_METHOD_NAME
          The name of the method that will be used to set the display name of the categorical tracker.
static int SET_DISPLAY_NAME_METHOD_NUMBER
          The method number for the "setDisplayName" method.
static java.lang.String START_TRACKER_METHOD_NAME
          The name of the method that will be used to tell the tracker to start collecting statistics.
static int START_TRACKER_METHOD_NUMBER
          The method number for the "startTracker" method.
static java.lang.String STOP_TRACKER_METHOD_NAME
          The name of the method that will be used to tell the tracker to stop collecting statistics.
static int STOP_TRACKER_METHOD_NUMBER
          The method number for the "stopTracker" method.
 
Constructor Summary
CategoricalTrackerVariable()
          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.
 StatTracker[] getStatTrackers()
          Retrieves the categorical tracker associated with this categorical tracker 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 startStatTrackers(JobClass jobThread)
          Starts the stat trackers associated with this variable.
 void stopStatTrackers()
          Stops the stat trackers associated with this variable.
 
Methods inherited from class com.sun.slamd.scripting.engine.Variable
getArgumentAsString, getArgumentType, getArgumentValue, getName, isValidIdentifier, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CATEGORICAL_TRACKER_VARIABLE_TYPE

public static final java.lang.String CATEGORICAL_TRACKER_VARIABLE_TYPE
The name that will be used for the data type of categorical tracker variables.

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 the tracker for a particular category.

See Also:
Constant Field Values

INCREMENT_METHOD_NUMBER

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

See Also:
Constant Field Values

SET_DISPLAY_NAME_METHOD_NAME

public static final java.lang.String SET_DISPLAY_NAME_METHOD_NAME
The name of the method that will be used to set the display name of the categorical tracker.

See Also:
Constant Field Values

SET_DISPLAY_NAME_METHOD_NUMBER

public static final int SET_DISPLAY_NAME_METHOD_NUMBER
The method number for the "setDisplayName" method.

See Also:
Constant Field Values

START_TRACKER_METHOD_NAME

public static final java.lang.String START_TRACKER_METHOD_NAME
The name of the method that will be used to tell the tracker to start collecting statistics.

See Also:
Constant Field Values

START_TRACKER_METHOD_NUMBER

public static final int START_TRACKER_METHOD_NUMBER
The method number for the "startTracker" method.

See Also:
Constant Field Values

STOP_TRACKER_METHOD_NAME

public static final java.lang.String STOP_TRACKER_METHOD_NAME
The name of the method that will be used to tell the tracker to stop collecting statistics.

See Also:
Constant Field Values

STOP_TRACKER_METHOD_NUMBER

public static final int STOP_TRACKER_METHOD_NUMBER
The method number for the "stopTracker" method.

See Also:
Constant Field Values

CATEGORICAL_TRACKER_VARIABLE_METHODS

public static final Method[] CATEGORICAL_TRACKER_VARIABLE_METHODS
The set of methods associated with categorical tracker variables.

Constructor Detail

CategoricalTrackerVariable

public CategoricalTrackerVariable()
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 Detail

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.

getStatTrackers

public StatTracker[] getStatTrackers()
Retrieves the categorical tracker associated with this categorical tracker variable.

Overrides:
getStatTrackers in class Variable
Returns:
The categorical tracker associated with this categorical tracker variable.

startStatTrackers

public void startStatTrackers(JobClass jobThread)
Starts the stat trackers associated with this variable.

Overrides:
startStatTrackers in class Variable
Parameters:
jobThread - The job thread with which the stat trackers are associated.

stopStatTrackers

public void stopStatTrackers()
Stops the stat trackers associated with this variable.

Overrides:
stopStatTrackers in class Variable

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.