|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.jexl2.Interpreter
public class Interpreter
An interpreter of JEXL syntax.
Field Summary | |
---|---|
protected JexlArithmetic |
arithmetic
The arithmetic handler. |
protected boolean |
cache
Cache executors. |
protected JexlContext |
context
The context to store/retrieve variables. |
protected static Object[] |
EMPTY_PARAMS
Empty parameters for method matching. |
protected Map<String,Object> |
functions
The map of registered functions. |
protected Map<String,Object> |
functors
The map of registered functions. |
protected org.apache.commons.logging.Log |
logger
The logger. |
protected Object[] |
registers
Registers or arguments. |
protected boolean |
silent
Silent intepreter flag. |
protected boolean |
strict
Strict interpreter flag. |
protected Uberspect |
uberspect
The uberspect. |
Constructor Summary | |
---|---|
protected |
Interpreter(Interpreter base)
Copy constructor. |
|
Interpreter(JexlEngine jexl,
JexlContext aContext)
Deprecated. |
|
Interpreter(JexlEngine jexl,
JexlContext aContext,
boolean strictFlag,
boolean silentFlag)
Creates an interpreter. |
Method Summary | |
---|---|
protected JexlNode |
findNullOperand(RuntimeException xrt,
JexlNode node,
Object left,
Object right)
Finds the node causing a NPE for diadic operators. |
Object |
getAttribute(Object object,
Object attribute)
Gets an attribute of an object. |
protected Object |
getAttribute(Object object,
Object attribute,
JexlNode node)
Gets an attribute of an object. |
protected JexlContext |
getContext()
Gets the context. |
protected Uberspect |
getUberspect()
Gets the uberspect. |
Object |
interpret(JexlNode node)
Interpret the given script/expression. |
protected Object |
invocationFailed(JexlException xjexl)
Triggered when method, function or constructor invocation fails. |
protected boolean |
isCancelled()
Checks whether this interpreter execution was cancelled due to thread interruption. |
boolean |
isSilent()
Checks whether this interpreter throws JexlException when encountering errors. |
boolean |
isStrict()
Checks whether this interpreter considers unknown variables, methods and constructors as errors. |
protected Object |
resolveNamespace(String prefix,
JexlNode node)
Resolves a namespace, eventually allocating an instance using context as constructor argument. |
void |
setAttribute(Object object,
Object attribute,
Object value)
Sets an attribute of an object. |
protected void |
setAttribute(Object object,
Object attribute,
Object value,
JexlNode node)
Sets an attribute of an object. |
protected void |
setFrame(JexlEngine.Frame frame)
Sets this interpreter parameters and arguments. |
protected void |
setRegisters(Object... theRegisters)
Deprecated. |
void |
setSilent(boolean flag)
Deprecated. Do not use; will be removed in a later version |
void |
setStrict(boolean flag)
Deprecated. Do not use; will be removed in a later version |
protected Object |
unknownVariable(JexlException xjexl)
Triggered when variable can not be resolved. |
Object |
visit(ASTAdditiveNode node,
Object data)
|
Object |
visit(ASTAdditiveOperator node,
Object data)
|
Object |
visit(ASTAmbiguous node,
Object data)
Unused, should throw in Parser. |
Object |
visit(ASTAndNode node,
Object data)
|
Object |
visit(ASTArrayAccess node,
Object data)
|
Object |
visit(ASTArrayLiteral node,
Object data)
|
Object |
visit(ASTAssignment node,
Object data)
|
Object |
visit(ASTBitwiseAndNode node,
Object data)
|
Object |
visit(ASTBitwiseComplNode node,
Object data)
|
Object |
visit(ASTBitwiseOrNode node,
Object data)
|
Object |
visit(ASTBitwiseXorNode node,
Object data)
|
Object |
visit(ASTBlock node,
Object data)
|
Object |
visit(ASTConstructorNode node,
Object data)
|
Object |
visit(ASTDivNode node,
Object data)
|
Object |
visit(ASTEmptyFunction node,
Object data)
|
Object |
visit(ASTEQNode node,
Object data)
|
Object |
visit(ASTERNode node,
Object data)
|
Object |
visit(ASTFalseNode node,
Object data)
|
Object |
visit(ASTFloatLiteral node,
Object data)
Deprecated. Do not use |
Object |
visit(ASTForeachStatement node,
Object data)
|
Object |
visit(ASTFunctionNode node,
Object data)
|
Object |
visit(ASTGENode node,
Object data)
|
Object |
visit(ASTGTNode node,
Object data)
|
Object |
visit(ASTIdentifier node,
Object data)
|
Object |
visit(ASTIfStatement node,
Object data)
|
Object |
visit(ASTIntegerLiteral node,
Object data)
Deprecated. Do not use |
Object |
visit(ASTJexlScript node,
Object data)
|
Object |
visit(ASTLENode node,
Object data)
|
Object |
visit(ASTLTNode node,
Object data)
|
Object |
visit(ASTMapEntry node,
Object data)
|
Object |
visit(ASTMapLiteral node,
Object data)
|
Object |
visit(ASTMethodNode node,
Object data)
|
Object |
visit(ASTModNode node,
Object data)
|
Object |
visit(ASTMulNode node,
Object data)
|
Object |
visit(ASTNENode node,
Object data)
|
Object |
visit(ASTNotNode node,
Object data)
|
Object |
visit(ASTNRNode node,
Object data)
|
Object |
visit(ASTNullLiteral node,
Object data)
|
Object |
visit(ASTNumberLiteral node,
Object data)
|
Object |
visit(ASTOrNode node,
Object data)
|
Object |
visit(ASTReferenceExpression node,
Object data)
|
Object |
visit(ASTReference node,
Object data)
|
Object |
visit(ASTReturnStatement node,
Object data)
|
Object |
visit(ASTSizeFunction node,
Object data)
|
Object |
visit(ASTSizeMethod node,
Object data)
|
Object |
visit(ASTStringLiteral node,
Object data)
|
Object |
visit(ASTTernaryNode node,
Object data)
|
Object |
visit(ASTTrueNode node,
Object data)
|
Object |
visit(ASTUnaryMinusNode node,
Object data)
|
Object |
visit(ASTVar node,
Object data)
|
Object |
visit(ASTWhileStatement node,
Object data)
|
Object |
visit(SimpleNode node,
Object data)
Unused, satisfy ParserVisitor interface. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final org.apache.commons.logging.Log logger
protected final Uberspect uberspect
protected final JexlArithmetic arithmetic
protected final Map<String,Object> functions
protected Map<String,Object> functors
protected final JexlContext context
protected boolean strict
protected boolean silent
protected final boolean cache
protected Object[] registers
protected static final Object[] EMPTY_PARAMS
Constructor Detail |
---|
@Deprecated public Interpreter(JexlEngine jexl, JexlContext aContext)
jexl
- the engine creating this interpreteraContext
- the context to evaluate expressionpublic Interpreter(JexlEngine jexl, JexlContext aContext, boolean strictFlag, boolean silentFlag)
jexl
- the engine creating this interpreteraContext
- the context to evaluate expressionstrictFlag
- whether this interpreter runs in strict modesilentFlag
- whether this interpreter runs in silent modeprotected Interpreter(Interpreter base)
base
- the base to copyMethod Detail |
---|
@Deprecated public void setStrict(boolean flag)
flag
- true for strict, false for lenient@Deprecated public void setSilent(boolean flag)
flag
- true for silent, false for verbosepublic boolean isStrict()
public boolean isSilent()
public Object interpret(JexlNode node)
If the underlying JEXL engine is silent, errors will be logged through its logger as info.
node
- the script or expression to interpret.
JexlException
- if any error occurs during interpretation.protected JexlContext getContext()
JexlContext
used for evaluation.protected Uberspect getUberspect()
Uberspect
@Deprecated protected void setRegisters(Object... theRegisters)
Use setFrame(...) instead.
theRegisters
- the array of registersprotected void setFrame(JexlEngine.Frame frame)
frame
- the calling frameprotected JexlNode findNullOperand(RuntimeException xrt, JexlNode node, Object left, Object right)
xrt
- the RuntimeExceptionnode
- the parent nodeleft
- the left argumentright
- the right argument
protected Object unknownVariable(JexlException xjexl)
xjexl
- the JexlException ("undefined variable " + variable)
protected Object invocationFailed(JexlException xjexl)
xjexl
- the JexlException wrapping the original error
protected boolean isCancelled()
protected Object resolveNamespace(String prefix, JexlNode node)
prefix
- the prefix name (may be null for global namespace)node
- the AST node
public Object visit(ASTAdditiveNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTAdditiveOperator node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTAndNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTArrayAccess node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTArrayLiteral node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTAssignment node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTBitwiseAndNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTBitwiseComplNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTBitwiseOrNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTBitwiseXorNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTBlock node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTDivNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTEmptyFunction node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTEQNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTFalseNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTForeachStatement node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTGENode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTGTNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTERNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTIdentifier node, Object data)
visit
in interface ParserVisitor
@Deprecated public Object visit(ASTFloatLiteral node, Object data)
@Deprecated public Object visit(ASTIntegerLiteral node, Object data)
public Object visit(ASTVar node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTIfStatement node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTNumberLiteral node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTJexlScript node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTLENode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTLTNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTMapEntry node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTMapLiteral node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTMethodNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTFunctionNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTConstructorNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTModNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTMulNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTNENode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTNRNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTNotNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTNullLiteral node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTOrNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTReference node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTReferenceExpression node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTReturnStatement node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTSizeFunction node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTSizeMethod node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTStringLiteral node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTTernaryNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTTrueNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTUnaryMinusNode node, Object data)
visit
in interface ParserVisitor
public Object visit(ASTWhileStatement node, Object data)
visit
in interface ParserVisitor
public Object getAttribute(Object object, Object attribute)
object
- to retrieve value fromattribute
- the attribute of the object, e.g. an index (1, 0, 2) or
key for a map
protected Object getAttribute(Object object, Object attribute, JexlNode node)
object
- to retrieve value fromattribute
- the attribute of the object, e.g. an index (1, 0, 2) or
key for a mapnode
- the node that evaluated as the object
public void setAttribute(Object object, Object attribute, Object value)
object
- to set the value toattribute
- the attribute of the object, e.g. an index (1, 0, 2) or
key for a mapvalue
- the value to assign to the object's attributeprotected void setAttribute(Object object, Object attribute, Object value, JexlNode node)
object
- to set the value toattribute
- the attribute of the object, e.g. an index (1, 0, 2) or
key for a mapvalue
- the value to assign to the object's attributenode
- the node that evaluated as the objectpublic Object visit(SimpleNode node, Object data)
visit
in interface ParserVisitor
node
- a nodedata
- the data
public Object visit(ASTAmbiguous node, Object data)
visit
in interface ParserVisitor
node
- a nodedata
- the data
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |