Class ScriptParser
- java.lang.Object
-
- org.apache.manifoldcf.scriptengine.ScriptParser
-
public class ScriptParser extends java.lang.Object
Class to parse various syntactical parts of a script and execute them.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,Command>
commands
A table of commands that we know how to deal with.protected org.apache.http.conn.HttpClientConnectionManager
connectionManager
The connection manager.protected java.util.Map<java.lang.String,ContextVariableReference>
context
The current variable context.protected org.apache.http.client.HttpClient
httpClient
The client instanceprotected java.lang.Integer
httpClientLock
The lock for the httpclient factoryprotected java.util.Map<java.lang.String,NewOperation>
newOperations
A table of "new" operations that we know how to deal with.protected static int
STATEMENT_BREAK
protected static int
STATEMENT_ISME
protected static int
STATEMENT_NOTME
-
Constructor Summary
Constructors Constructor Description ScriptParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCommand(java.lang.String commandName, Command command)
Add a command.void
addNewOperation(java.lang.String operationName, NewOperation operation)
Add a "new" operation.void
addVariable(java.lang.String variableName, Variable v)
Add a variable.static java.lang.String
convertToString(org.apache.http.HttpResponse httpResponse)
VariableReference
evaluateExpression(TokenStream currentStream)
Evaluate an expression.protected VariableReference
evaluateExpression_1(TokenStream currentStream)
protected VariableReference
evaluateExpression_2(TokenStream currentStream)
protected VariableReference
evaluateExpression_3(TokenStream currentStream)
protected VariableReference
evaluateExpression_4(TokenStream currentStream)
protected VariableReference
evaluateExpression_5(TokenStream currentStream)
protected VariableReference
evaluateExpression_6(TokenStream currentStream)
void
execute(TokenStream currentStream)
Execute script.org.apache.http.client.HttpClient
getHttpClient()
static void
localError(TokenStream currentStream, java.lang.String message)
static void
main(java.lang.String[] argv)
protected int
parseStatement(TokenStream currentStream)
Parse a single statement.boolean
parseStatements(TokenStream currentStream)
Parse and execute multiple statements.protected VariableReference
parseVariableReference(TokenStream currentStream)
protected VariableReference
parseVariableReference_0(TokenStream currentStream)
protected VariableReference
parseVariableReference_1(TokenStream currentStream)
protected VariableReference
parseVariableReference_2(TokenStream currentStream)
static Variable
resolveMustExist(TokenStream currentStream, VariableReference vr)
boolean
skipExpression(TokenStream currentStream)
Skip an expression.protected boolean
skipExpression_1(TokenStream currentStream)
protected boolean
skipExpression_2(TokenStream currentStream)
protected boolean
skipExpression_3(TokenStream currentStream)
protected boolean
skipExpression_4(TokenStream currentStream)
protected boolean
skipExpression_5(TokenStream currentStream)
protected boolean
skipExpression_6(TokenStream currentStream)
protected boolean
skipStatement(TokenStream currentStream)
Skip a single statement.void
skipStatements(TokenStream currentStream)
Skip multiple statements.protected boolean
skipVariableReference(TokenStream currentStream)
protected boolean
skipVariableReference_0(TokenStream currentStream)
protected boolean
skipVariableReference_1(TokenStream currentStream)
protected boolean
skipVariableReference_2(TokenStream currentStream)
static void
syntaxError(TokenStream currentStream, java.lang.String message)
-
-
-
Field Detail
-
connectionManager
protected org.apache.http.conn.HttpClientConnectionManager connectionManager
The connection manager.
-
httpClient
protected org.apache.http.client.HttpClient httpClient
The client instance
-
httpClientLock
protected java.lang.Integer httpClientLock
The lock for the httpclient factory
-
context
protected java.util.Map<java.lang.String,ContextVariableReference> context
The current variable context.
-
commands
protected java.util.Map<java.lang.String,Command> commands
A table of commands that we know how to deal with.
-
newOperations
protected java.util.Map<java.lang.String,NewOperation> newOperations
A table of "new" operations that we know how to deal with.
-
STATEMENT_NOTME
protected static final int STATEMENT_NOTME
- See Also:
- Constant Field Values
-
STATEMENT_ISME
protected static final int STATEMENT_ISME
- See Also:
- Constant Field Values
-
STATEMENT_BREAK
protected static final int STATEMENT_BREAK
- See Also:
- Constant Field Values
-
-
Method Detail
-
addCommand
public void addCommand(java.lang.String commandName, Command command)
Add a command.- Parameters:
commandName
- is the name of the command.command
- is the command instance.
-
addNewOperation
public void addNewOperation(java.lang.String operationName, NewOperation operation)
Add a "new" operation.- Parameters:
operationName
- is the name of the operation.operation
- is the operation to create.
-
addVariable
public void addVariable(java.lang.String variableName, Variable v) throws ScriptException
Add a variable.- Throws:
ScriptException
-
execute
public void execute(TokenStream currentStream) throws ScriptException
Execute script.- Throws:
ScriptException
-
parseStatements
public boolean parseStatements(TokenStream currentStream) throws ScriptException
Parse and execute multiple statements.- Parameters:
currentStream
- is the token stream to parse.- Returns:
- true for a break signal.
- Throws:
ScriptException
-
skipStatements
public void skipStatements(TokenStream currentStream) throws ScriptException
Skip multiple statements.- Parameters:
currentStream
- is the token stream to parse.- Throws:
ScriptException
-
parseStatement
protected int parseStatement(TokenStream currentStream) throws ScriptException
Parse a single statement.- Parameters:
currentStream
- is the current token stream.- Returns:
- a signal indicating either NOTME, ISME, or BREAK.
- Throws:
ScriptException
-
skipStatement
protected boolean skipStatement(TokenStream currentStream) throws ScriptException
Skip a single statement.- Parameters:
currentStream
- is the current token stream.- Returns:
- true if a statement was detected, false otherwise.
- Throws:
ScriptException
-
evaluateExpression
public VariableReference evaluateExpression(TokenStream currentStream) throws ScriptException
Evaluate an expression.- Parameters:
currentStream
- is the token stream to parse.- Returns:
- a VariableReference object if an expression was detected, null otherwise.
- Throws:
ScriptException
-
skipExpression
public boolean skipExpression(TokenStream currentStream) throws ScriptException
Skip an expression.- Parameters:
currentStream
- is the token stream to parse.- Returns:
- true if an expression was detected, false otherwise.
- Throws:
ScriptException
-
evaluateExpression_1
protected VariableReference evaluateExpression_1(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
skipExpression_1
protected boolean skipExpression_1(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
evaluateExpression_2
protected VariableReference evaluateExpression_2(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
skipExpression_2
protected boolean skipExpression_2(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
evaluateExpression_3
protected VariableReference evaluateExpression_3(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
skipExpression_3
protected boolean skipExpression_3(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
evaluateExpression_4
protected VariableReference evaluateExpression_4(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
skipExpression_4
protected boolean skipExpression_4(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
evaluateExpression_5
protected VariableReference evaluateExpression_5(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
skipExpression_5
protected boolean skipExpression_5(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
evaluateExpression_6
protected VariableReference evaluateExpression_6(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
skipExpression_6
protected boolean skipExpression_6(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
parseVariableReference
protected VariableReference parseVariableReference(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
skipVariableReference
protected boolean skipVariableReference(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
parseVariableReference_0
protected VariableReference parseVariableReference_0(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
parseVariableReference_1
protected VariableReference parseVariableReference_1(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
parseVariableReference_2
protected VariableReference parseVariableReference_2(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
skipVariableReference_0
protected boolean skipVariableReference_0(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
skipVariableReference_1
protected boolean skipVariableReference_1(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
skipVariableReference_2
protected boolean skipVariableReference_2(TokenStream currentStream) throws ScriptException
- Throws:
ScriptException
-
syntaxError
public static void syntaxError(TokenStream currentStream, java.lang.String message) throws ScriptException
- Throws:
ScriptException
-
resolveMustExist
public static Variable resolveMustExist(TokenStream currentStream, VariableReference vr) throws ScriptException
- Throws:
ScriptException
-
localError
public static void localError(TokenStream currentStream, java.lang.String message) throws ScriptException
- Throws:
ScriptException
-
convertToString
public static java.lang.String convertToString(org.apache.http.HttpResponse httpResponse) throws java.io.IOException
- Throws:
java.io.IOException
-
getHttpClient
public org.apache.http.client.HttpClient getHttpClient()
-
main
public static void main(java.lang.String[] argv)
-
-