Class ScriptParser
- java.lang.Object
-
- org.apache.manifoldcf.scriptengine.ScriptParser
-
public class ScriptParser extends java.lang.ObjectClass 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>commandsA table of commands that we know how to deal with.protected org.apache.http.conn.HttpClientConnectionManagerconnectionManagerThe connection manager.protected java.util.Map<java.lang.String,ContextVariableReference>contextThe current variable context.protected org.apache.http.client.HttpClienthttpClientThe client instanceprotected java.lang.IntegerhttpClientLockThe lock for the httpclient factoryprotected java.util.Map<java.lang.String,NewOperation>newOperationsA table of "new" operations that we know how to deal with.protected static intSTATEMENT_BREAKprotected static intSTATEMENT_ISMEprotected static intSTATEMENT_NOTME
-
Constructor Summary
Constructors Constructor Description ScriptParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCommand(java.lang.String commandName, Command command)Add a command.voidaddNewOperation(java.lang.String operationName, NewOperation operation)Add a "new" operation.voidaddVariable(java.lang.String variableName, Variable v)Add a variable.static java.lang.StringconvertToString(org.apache.http.HttpResponse httpResponse)VariableReferenceevaluateExpression(TokenStream currentStream)Evaluate an expression.protected VariableReferenceevaluateExpression_1(TokenStream currentStream)protected VariableReferenceevaluateExpression_2(TokenStream currentStream)protected VariableReferenceevaluateExpression_3(TokenStream currentStream)protected VariableReferenceevaluateExpression_4(TokenStream currentStream)protected VariableReferenceevaluateExpression_5(TokenStream currentStream)protected VariableReferenceevaluateExpression_6(TokenStream currentStream)voidexecute(TokenStream currentStream)Execute script.org.apache.http.client.HttpClientgetHttpClient()static voidlocalError(TokenStream currentStream, java.lang.String message)static voidmain(java.lang.String[] argv)protected intparseStatement(TokenStream currentStream)Parse a single statement.booleanparseStatements(TokenStream currentStream)Parse and execute multiple statements.protected VariableReferenceparseVariableReference(TokenStream currentStream)protected VariableReferenceparseVariableReference_0(TokenStream currentStream)protected VariableReferenceparseVariableReference_1(TokenStream currentStream)protected VariableReferenceparseVariableReference_2(TokenStream currentStream)static VariableresolveMustExist(TokenStream currentStream, VariableReference vr)booleanskipExpression(TokenStream currentStream)Skip an expression.protected booleanskipExpression_1(TokenStream currentStream)protected booleanskipExpression_2(TokenStream currentStream)protected booleanskipExpression_3(TokenStream currentStream)protected booleanskipExpression_4(TokenStream currentStream)protected booleanskipExpression_5(TokenStream currentStream)protected booleanskipExpression_6(TokenStream currentStream)protected booleanskipStatement(TokenStream currentStream)Skip a single statement.voidskipStatements(TokenStream currentStream)Skip multiple statements.protected booleanskipVariableReference(TokenStream currentStream)protected booleanskipVariableReference_0(TokenStream currentStream)protected booleanskipVariableReference_1(TokenStream currentStream)protected booleanskipVariableReference_2(TokenStream currentStream)static voidsyntaxError(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 ScriptExceptionAdd 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)
-
-