Top Description Fields Constructors Methods
org.apache.commons.jexl2

public Class Interpreter

extends Object
implements ParserVisitor
Class Inheritance
All Implemented Interfaces
org.apache.commons.jexl2.parser.ParserVisitor
Imports
java.lang.reflect.Array, .InvocationTargetException, java.util.Collection, .HashMap, .Iterator, .Map, .Set, org.apache.commons.jexl2.parser.SimpleNode, .ASTFloatLiteral, .ASTIntegerLiteral, .JexlNode, .ASTAdditiveNode, .ASTAdditiveOperator, .ASTAndNode, .ASTAmbiguous, .ASTArrayAccess, .ASTArrayLiteral, .ASTAssignment, .ASTBitwiseAndNode, .ASTBitwiseComplNode, .ASTBitwiseOrNode, .ASTBitwiseXorNode, .ASTBlock, .ASTConstructorNode, .ASTDivNode, .ASTEQNode, .ASTERNode, .ASTEmptyFunction, .ASTFalseNode, .ASTFunctionNode, .ASTForeachStatement, .ASTGENode, .ASTGTNode, .ASTIdentifier, .ASTIfStatement, .ASTJexlScript, .ASTLENode, .ASTLTNode, .ASTMapEntry, .ASTMapLiteral, .ASTMethodNode, .ASTModNode, .ASTMulNode, .ASTNENode, .ASTNRNode, .ASTNotNode, .ASTNullLiteral, .ASTNumberLiteral, .ASTOrNode, .ASTReference, .ASTReferenceExpression, .ASTReturnStatement, .ASTSizeFunction, .ASTSizeMethod, .ASTStringLiteral, .ASTTernaryNode, .ASTTrueNode, .ASTUnaryMinusNode, .ASTWhileStatement, .Node, .ParserVisitor, .ASTVar, org.apache.commons.logging.Log, org.apache.commons.jexl2.introspection.Uberspect, .JexlMethod, .JexlPropertyGet, .JexlPropertySet

An interpreter of JEXL syntax.
Since
2.0

Field Summary

Modifier and TypeField and Description
protected final JexlArithmetic
arithmetic

The arithmetic handler.

protected final boolean
cache

Cache executors.

private volatile boolean
cancelled

Cancellation support.

protected final JexlContext
context

The context to store/retrieve variables.

protected static final Object[]
EMPTY_PARAMS

Empty parameters for method matching.

protected final Map<String, Object>
functions

The map of registered functions.

protected Map<String, Object>
functors

The map of registered functions.

protected final Log
logger

The logger.

private String[]
parameters

Parameter names if any.

protected Object[]
registers

Registers or arguments.

protected boolean
silent

Silent intepreter flag.

protected boolean
strict

Strict interpreter flag.

protected final Uberspect
uberspect

The uberspect.

Constructor Summary

AccessConstructor and Description
public
Interpreter(JexlEngine
the engine creating this interpreter
jexl
,
JexlContext
the context to evaluate expression
aContext
)

Deprecated
Creates an interpreter.
public
Interpreter(JexlEngine
the engine creating this interpreter
jexl
,
JexlContext
the context to evaluate expression
aContext
,
boolean
whether this interpreter runs in strict mode
strictFlag
,
boolean
whether this interpreter runs in silent mode
silentFlag
)

Creates an interpreter.

protected
Interpreter(Interpreter
the base to copy
base
)

Copy constructor.

Method Summary

Modifier and TypeMethod and Description
private Object

Returns:

the result of the method invocation
call
(JexlNode
the method node
node
,
Object
the bean this method should be invoked upon
bean
,
ASTIdentifier
the node carrying the method name
methodNode
,
int
the first argument index, child of the method node
argb
)

Calls a method (or function).

protected JexlNode

Returns:

the left, right or parent node
findNullOperand
(RuntimeException
the RuntimeException
xrt
,
JexlNode
the parent node
node
,
Object
the left argument
left
,
Object
the right argument
right
)

Finds the node causing a NPE for diadic operators.

public Object

Returns:

the attribute value
getAttribute
(Object
to retrieve value from
object
,
Object
the attribute of the object, e.g. an index (1, 0, 2) or key for a map
attribute
)

Gets an attribute of an object.

protected Object

Returns:

the attribute value
getAttribute
(Object
to retrieve value from
object
,
Object
the attribute of the object, e.g. an index (1, 0, 2) or key for a map
attribute
,
JexlNode
the node that evaluated as the object
node
)

Gets an attribute of an object.

protected JexlContext

Returns:

the JexlContext used for evaluation.
getContext
()

Gets the context.

protected Uberspect

Returns:

an Uberspect
getUberspect
()

Gets the uberspect.

public Object

Returns:

the result of the interpretation.
interpret
(JexlNode
the script or expression to interpret.
node
)

Interpret the given script/expression.

protected Object

Returns:

throws JexlException if strict, null otherwise
invocationFailed
(JexlException
the JexlException wrapping the original error
xjexl
)

Triggered when method, function or constructor invocation fails.

protected boolean

Returns:

true if cancelled, false otherwise
isCancelled
()

Checks whether this interpreter execution was cancelled due to thread interruption.

public boolean

Returns:

true if silent, false otherwise
isSilent
()

Checks whether this interpreter throws JexlException when encountering errors.

public boolean

Returns:

true if strict, false otherwise
isStrict
()

Checks whether this interpreter considers unknown variables, methods and constructors as errors.

private boolean

Returns:

true if nullable variable, false otherwise
isTernaryProtected
(JexlNode
the expression node
node
)

Check if a null evaluated expression is protected by a ternary expression.

protected Object

Returns:

the namespace instance
resolveNamespace
(String
the prefix name (may be null for global namespace)
prefix
,
JexlNode
the AST node
node
)

Resolves a namespace, eventually allocating an instance using context as constructor argument.

public void
setAttribute(Object
to set the value to
object
,
Object
the attribute of the object, e.g. an index (1, 0, 2) or key for a map
attribute
,
Object
the value to assign to the object's attribute
value
)

Sets an attribute of an object.

protected void
setAttribute(Object
to set the value to
object
,
Object
the attribute of the object, e.g. an index (1, 0, 2) or key for a map
attribute
,
Object
the value to assign to the object's attribute
value
,
JexlNode
the node that evaluated as the object
node
)

Sets an attribute of an object.

protected void
setFrame(JexlEngine.Frame
the calling frame
frame
)

Sets this interpreter parameters and arguments.

protected void
setRegisters(Object...
the array of registers
theRegisters
)

Deprecated
Sets this interpreter registers for bean access/assign expressions.
public void
setSilent(boolean
true for silent, false for verbose
flag
)

Deprecated Do not use; will be removed in a later version
Sets whether this interpreter throws JexlException when encountering errors.
public void
setStrict(boolean
true for strict, false for lenient
flag
)

Deprecated Do not use; will be removed in a later version
Sets whether this interpreter considers unknown variables, methods and constructors as errors.
private int

Returns:

the size of val
sizeOf
(JexlNode
the node that gave the value to size
node
,
Object
the object to get the size of.
val
)

Calculate the size of various types: Collection, Array, Map, String, and anything that has a int size() method.

protected Object

Returns:

throws JexlException if strict, null otherwise
unknownVariable
(JexlException
the JexlException ("undefined variable " + variable)
xjexl
)

Triggered when variable can not be resolved.

public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
visit(ASTFloatLiteral node, Object data)

Deprecated Do not use
public Object
visit(ASTIntegerLiteral node, Object data)

Deprecated Do not use
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object
public Object

Returns:

does not return
visit
(SimpleNode
a node
node
,
Object
the data
data
)

Implements org.apache.commons.jexl2.parser.ParserVisitor.visit.

Unused, satisfy ParserVisitor interface.
public Object

Returns:

does not return
visit
(ASTAmbiguous
a node
node
,
Object
the data
data
)

Implements org.apache.commons.jexl2.parser.ParserVisitor.visit.

Unused, should throw in Parser.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait