com.sun.slamd.scripting.engine
Class Variable

java.lang.Object
  extended bycom.sun.slamd.scripting.engine.Variable
All Implemented Interfaces:
Argument
Direct Known Subclasses:
BooleanVariable, CategoricalTrackerVariable, FileURLVariable, HTMLDocumentVariable, HTTPClientVariable, HTTPRequestVariable, HTTPResponseVariable, IMAPConnectionVariable, IncrementalTrackerVariable, IntegerValueTrackerVariable, IntegerVariable, JDBCConnectionVariable, JDBCPreparedStatementVariable, JDBCResultSetVariable, LDAPAttributeVariable, LDAPConnectionVariable, LDAPEntryVariable, LDAPModificationSetVariable, LDAPModificationVariable, LDAPUtilsVariable, MailMessageVariable, POPConnectionVariable, RateLimiterVariable, ScriptVariable, SMTPConnectionVariable, StringArrayVariable, StringVariable, TimeTrackerVariable, ValuePatternVariable

public abstract class Variable
extends java.lang.Object
implements Argument

This class defines a generic variable that may be defined in an LDAP script.


Constructor Summary
Variable()
          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.
Variable(java.lang.String name)
          Creates a generic variable with a name but no value.
 
Method Summary
abstract  void assign(Argument argument)
          Assigns the value of the provided argument to this variable.
abstract  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.
 java.lang.String getArgumentAsString()
          Retrieves a string representation of this argument in a form appropriate for inclusion in a script.
 java.lang.String getArgumentType()
          Retrieves the name of the data type associated with this argument.
 Variable getArgumentValue()
          Retrieves the value of this argument.
abstract  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.
abstract  Method[] getMethods()
          Retrieves a list of all methods defined for this variable.
 java.lang.String getName()
          Retrieves the name of this variable.
abstract  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 set of stat trackers that are maintained for this variable type.
abstract  java.lang.String getVariableTypeName()
          Retrieves the name of the variable type for this variable.
abstract  boolean hasMethod(java.lang.String methodName)
          Indicates whether this variable type has a method with the specified name.
static boolean isValidIdentifier(java.lang.String identifierName)
          Indicates whether the specified string may be used as a variable or method identifier in a SLAMD script.
 void setName(java.lang.String name)
          Sets the name of this variable.
 void startStatTrackers(JobClass jobThread)
          Notifies all the stat trackers associated with this variable type that they should start collecting statistics.
 void stopStatTrackers()
          Notifies all the stat trackers associated with this variable type that they should start collecting statistics.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.slamd.scripting.engine.Argument
getValueAsString
 

Constructor Detail

Variable

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


Variable

public Variable(java.lang.String name)
Creates a generic variable with a name but no value.

Parameters:
name - The name to use for this variable.
Method Detail

getVariableTypeName

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

Returns:
The name of the variable type for this variable.

setName

public void setName(java.lang.String name)
Sets the name of this variable.

Parameters:
name - The name to use for this variable.

getName

public java.lang.String getName()
Retrieves the name of this variable.

Returns:
The name of this variable.

isValidIdentifier

public static boolean isValidIdentifier(java.lang.String identifierName)
Indicates whether the specified string may be used as a variable or method identifier in a SLAMD script. All valid identifiers must start with an alphabetic character and must contain only alphabetic characters, numeric digits, or underscore characters.

Parameters:
identifierName - The name of the identifier for which to make the determination.
Returns:
true if the provided name may be used as a valid identifier, or false if not.

getMethods

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

Returns:
A list of all methods defined for this variable.

hasMethod

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

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 abstract 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.

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 abstract 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.

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 abstract 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.

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.

getStatTrackers

public StatTracker[] getStatTrackers()
Retrieves the set of stat trackers that are maintained for this variable type. Note that most variables should not maintain stat trackers -- only those that perform a function for which it is worthwhile to report statistics back to the SLAMD server. Also note that if this method is implemented by a variable type, then the startStatTrackers() and stopStatTrackers() methods must also be implemented to make sure that they are handled properly.

Returns:
The set of stat trackers that are maintained for this variable type.

startStatTrackers

public void startStatTrackers(JobClass jobThread)
Notifies all the stat trackers associated with this variable type that they should start collecting statistics.

Parameters:
jobThread - The job thread for which the statistics will be gathered.

stopStatTrackers

public void stopStatTrackers()
Notifies all the stat trackers associated with this variable type that they should start collecting statistics.


getArgumentType

public java.lang.String getArgumentType()
Retrieves the name of the data type associated with this argument.

Specified by:
getArgumentType in interface Argument
Returns:
The name of the data type associated with this argument.

getArgumentValue

public Variable getArgumentValue()
                          throws ScriptException
Retrieves the value of this argument.

Specified by:
getArgumentValue in interface Argument
Returns:
The value of this argument.
Throws:
ScriptException - If a problem occurs while determing the value of this argument.

assign

public abstract 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.

Parameters:
argument - The argument whose value should be assigned to this variable.
Throws:
ScriptException - If there is a problem while performing the assignment.

getArgumentAsString

public java.lang.String getArgumentAsString()
Retrieves a string representation of this argument in a form appropriate for inclusion in a script.

Specified by:
getArgumentAsString in interface Argument
Returns:
A string representation of this argument in a form appropriate for inclusion in a script.