com.sun.slamd.scripting.general
Class BooleanVariable

java.lang.Object
  extended by com.sun.slamd.scripting.engine.Variable
      extended by com.sun.slamd.scripting.general.BooleanVariable
All Implemented Interfaces:
Argument

public class BooleanVariable
extends Variable

This class defines a Boolean variable that has a value of either "true" or "false". It also defines a set of methods for dealing with Boolean variables:

Author:
Neil A. Wilson

Field Summary
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 a logical AND between this and one or more other Boolean values.
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 assign a value to this Boolean variable.
static Method[] BOOLEAN_VARIABLE_METHODS
          The set of methods associated with Boolean variables.
static java.lang.String BOOLEAN_VARIABLE_TYPE
          The name that will be used for the data type of Boolean variables.
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 this Boolean variable has a value equal to another Boolean variable.
static java.lang.String IS_FALSE_METHOD_NAME
          The name of the method that will be used to determine whether this Boolean variable has a value of false.
static int IS_FALSE_METHOD_NUMBER
          The method number for the "isFalse" method.
static int NOT_EQUAL_1_METOHD_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 be used to determine whether two Boolean values are different.
static int OR_1_METHOD_NUMBER
          The method number for the first "or" method.
static int OR_2_METHOD_NUMBER
          The method number for the second "or" method.
static java.lang.String OR_METHOD_NAME
          The name of the method that will be used to perform a logical OR between this and one or more other Boolean values.
static java.lang.String TO_STRING_METHOD_NAME
          The name of the method that will be used to retrieve a string representation of this Boolean variable.
static int TO_STRING_METHOD_NUMBER
          The number for the "toString" method.
 
Constructor Summary
BooleanVariable()
          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.
BooleanVariable(boolean booleanValue)
          Creates a new Boolean variable with the provided 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.
 boolean getBooleanValue()
          Retrieves the boolean value associated with this Boolean 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 setBooleanValue(boolean booleanValue)
          Specifies the boolean value to use for this Boolean 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

BOOLEAN_VARIABLE_TYPE

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

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 a logical AND between this and one or more other Boolean values.

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 assign a value to this Boolean 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

EQUALS_METHOD_NAME

public static final java.lang.String EQUALS_METHOD_NAME
The name of the method that will be used to determine whether this Boolean variable has a value equal to another Boolean 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

IS_FALSE_METHOD_NAME

public static final java.lang.String IS_FALSE_METHOD_NAME
The name of the method that will be used to determine whether this Boolean variable has a value of false.

See Also:
Constant Field Values

IS_FALSE_METHOD_NUMBER

public static final int IS_FALSE_METHOD_NUMBER
The method number for the "isFalse" 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 be used to determine whether two Boolean values are different.

See Also:
Constant Field Values

NOT_EQUAL_1_METOHD_NUMBER

public static final int NOT_EQUAL_1_METOHD_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 a logical OR between this and one or more other Boolean values.

See Also:
Constant Field Values

OR_1_METHOD_NUMBER

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

See Also:
Constant Field Values

OR_2_METHOD_NUMBER

public static final int OR_2_METHOD_NUMBER
The method number for the second "or" 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 will be used to retrieve a string representation of this Boolean variable.

See Also:
Constant Field Values

TO_STRING_METHOD_NUMBER

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

See Also:
Constant Field Values

BOOLEAN_VARIABLE_METHODS

public static final Method[] BOOLEAN_VARIABLE_METHODS
The set of methods associated with Boolean variables.

Constructor Detail

BooleanVariable

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

BooleanVariable

public BooleanVariable(boolean booleanValue)
Creates a new Boolean variable with the provided value.

Parameters:
booleanValue - The value to use for this Boolean variable.
Method Detail

getBooleanValue

public boolean getBooleanValue()
Retrieves the boolean value associated with this Boolean variable.

Returns:
The boolean value associated with this Boolean variable.

setBooleanValue

public void setBooleanValue(boolean booleanValue)
Specifies the boolean value to use for this Boolean variable.

Parameters:
booleanValue - The boolean value to use for this Boolean 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.

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.

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.

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.