|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.slamd.scripting.engine.ScriptParser
This class implements a mechanism for parsing and executing script files that specify instructions for performing operations in a SLAMD job. The set of reserved words understood by this parser is hard-coded, but the set of data types that may be used is flexible and may be extended by the end user.
| Field Summary | |
static java.lang.String[] |
AUTO_INCLUDED_VARIABLE_TYPES
The set of variable types that will be automatically included and available to scripts without the need for an explicit "use" definition. |
static java.lang.String |
RESERVED_WORD_BEGIN
The reserved word that is used to indicate the beginning of an instruction block. |
static java.lang.String |
RESERVED_WORD_BREAK
The reserved word that is used to indicate that execution of the current loop should stop immediately and that execution should resume with the next instruction immediately after the loop. |
static java.lang.String |
RESERVED_WORD_CONTINUE
The reserved word that is used to indicate that the execution of the current loop iteration should stop immediately and that the next iteration should begin if appropriate. |
static java.lang.String |
RESERVED_WORD_ELSE
The reserved word that is used to execute an instruction if the boolean value associated with the immediately preceding if statement is false. |
static java.lang.String |
RESERVED_WORD_END
The reserved word that is used to indicate the end of an instruction block. |
static java.lang.String |
RESERVED_WORD_IF
The reserved word that is used to execute an instruction if the associated boolean value is true. |
static java.lang.String |
RESERVED_WORD_IF_NOT
The reserved word that is used to execute an instruction if the associated boolean value is false. |
static java.lang.String |
RESERVED_WORD_LOOP
The reserved word that is used to execute an instruction a specified number of times. |
static java.lang.String |
RESERVED_WORD_USE
The reserved word that is used to define a new variable type for use in the SLAMD script. |
static java.lang.String |
RESERVED_WORD_VARIABLE
The reserved word that is used to define a new variable instance for use in the SLAMD script. |
static java.lang.String |
RESERVED_WORD_WHILE
The reserved word that is used to execute an instruction until a specified condition becomes false. |
static java.lang.String |
RESERVED_WORD_WHILE_NOT
The reserved word that is used to execute an instruction until a specified condition becomes true. |
static java.lang.String |
VARIABLE_TYPE_SUPERCLASS_NAME
The Java class name that is the superclass of all variable types that may be used in SLAMD scripts. |
| Constructor Summary | |
ScriptParser()
Creates a new script parser that can be used to parse and execute a SLAMD script. |
|
| Method Summary | |
void |
debugExecute(JobClass jobThread)
Executes the script in debug mode, sending debug information to the client's message writer. |
void |
execute(JobClass jobThread)
Executes the script. |
java.lang.String |
getScriptArgument(java.lang.String argumentName)
Retrieves the value of the specified script argument. |
StatTracker[] |
getStatTrackers()
Retrieves the set of statistics gathered while running this script. |
static boolean |
isReservedWord(java.lang.String token)
Indicates whether the specified token is one of the reserved words in the SLAMD scripting environment. |
void |
parse()
Parses the script information and tokenizes the instructions so that they may be more easily and efficiently executed. |
java.lang.String |
peekAtNextToken()
Retrieves the next token from the script but preserves the internal markers used to keep track of the position in the script. |
void |
read(java.io.InputStream inputStream)
Reads the script file data from the specified input stream into memory. |
void |
read(java.lang.String filename)
Reads the specified script file into memory. |
void |
registerVariableType(java.lang.String className)
Registers a variable type definition for use in the SLAMD script. |
void |
setScriptArguments(java.util.Hashtable scriptArgumentHash)
Specifies the script arguments to use with this script. |
void |
setScriptLines(java.lang.String[] lines)
Specifies the lines to use for the script. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String[] AUTO_INCLUDED_VARIABLE_TYPES
public static final java.lang.String VARIABLE_TYPE_SUPERCLASS_NAME
public static final java.lang.String RESERVED_WORD_USE
public static final java.lang.String RESERVED_WORD_VARIABLE
public static final java.lang.String RESERVED_WORD_BEGIN
public static final java.lang.String RESERVED_WORD_END
public static final java.lang.String RESERVED_WORD_IF
public static final java.lang.String RESERVED_WORD_IF_NOT
public static final java.lang.String RESERVED_WORD_ELSE
public static final java.lang.String RESERVED_WORD_LOOP
public static final java.lang.String RESERVED_WORD_WHILE
public static final java.lang.String RESERVED_WORD_WHILE_NOT
public static final java.lang.String RESERVED_WORD_BREAK
public static final java.lang.String RESERVED_WORD_CONTINUE
| Constructor Detail |
public ScriptParser()
throws ScriptException
ScriptException - If there is a problem initializing the script
parser or loading the automatically included
variable types.| Method Detail |
public void registerVariableType(java.lang.String className)
throws ScriptException
className - The name of the Java class that provides the variable
type definition.
ScriptException - If the specified class cannot be found, cannot
be instantiated, does not define a variable type,
or defines a variable type that is already in
use.
public void read(java.lang.String filename)
throws java.io.IOException
filename - The path and name of the script file to be read.
java.io.IOException - If there is a problem reading from the script file.
public void read(java.io.InputStream inputStream)
throws java.io.IOException
inputStream - The input stream from which the script file data will
be read.
java.io.IOException - If there is a problem reading the script file data.public void setScriptLines(java.lang.String[] lines)
lines - The lines to use for the script.public void setScriptArguments(java.util.Hashtable scriptArgumentHash)
scriptArgumentHash - The set of arguments to use in conjunction with
this script.public java.lang.String getScriptArgument(java.lang.String argumentName)
argumentName - The name of the script argument to retrieve.
null
if it was not defined.
public void parse()
throws ScriptException
ScriptException - If the script cannot be parsed as a valid SLAMD
script (i.e., if the script contains one or more
syntax errors).
public java.lang.String peekAtNextToken()
throws ScriptException
nextToken().
nextToken().
ScriptException - If there is a problem while parsing the next
token.public static boolean isReservedWord(java.lang.String token)
token - The token for which to make the determination.
true if the specified token is one of the reserved
words, or false if not.
public void execute(JobClass jobThread)
throws ScriptException
jobThread - The job thread that will be executing the script.
ScriptException - If a problem occurs while executing the script.
public void debugExecute(JobClass jobThread)
throws ScriptException
jobThread - The job thread that will be executing the script.
ScriptException - If a problem occurs while executing the script.public StatTracker[] getStatTrackers()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||