Package org.apache.commons.jexl2
Class ExpressionImpl
- java.lang.Object
-
- org.apache.commons.jexl2.ExpressionImpl
-
- All Implemented Interfaces:
Expression,Script
public class ExpressionImpl extends java.lang.Object implements Expression, Script
Instances of ExpressionImpl are created by theJexlEngine, and this is the default implementation of theExpressionandScriptinterface.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringexpressionOriginal expression stripped from leading & trailing spaces.protected JexlEnginejexlThe engine for this expression.protected ASTJexlScriptscriptThe resulting AST we can interpret.
-
Constructor Summary
Constructors Modifier Constructor Description protectedExpressionImpl(JexlEngine engine, java.lang.String expr, ASTJexlScript ref)Do not let this be generally instantiated with a 'new'.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.Callable<java.lang.Object>callable(JexlContext context)Creates a Callable from this script.java.util.concurrent.Callable<java.lang.Object>callable(JexlContext context, java.lang.Object... args)Creates a Callable from this script.java.lang.Stringdump()Returns the JEXL expression by reconstructing it from the parsed tree.java.lang.Objectevaluate(JexlContext context)Evaluates the expression with the variables contained in the suppliedJexlContext.java.lang.Objectexecute(JexlContext context)Executes the script with the variables contained in the suppliedJexlContext.java.lang.Objectexecute(JexlContext context, java.lang.Object... args)Executes the script with the variables contained in the suppliedJexlContextand a set of arguments corresponding to the parameters used during parsing.java.lang.StringgetExpression()Returns the JEXL expression this Expression was created with.java.lang.String[]getLocalVariables()Gets this script local variables.java.lang.String[]getParameters()Gets this script parameters.java.lang.StringgetText()Returns the text of this Script.java.util.Set<java.util.List<java.lang.String>>getVariables()Gets this script variables.java.lang.StringtoString()Provide a string representation of this expression.
-
-
-
Field Detail
-
jexl
protected final JexlEngine jexl
The engine for this expression.
-
expression
protected final java.lang.String expression
Original expression stripped from leading & trailing spaces.
-
script
protected final ASTJexlScript script
The resulting AST we can interpret.
-
-
Constructor Detail
-
ExpressionImpl
protected ExpressionImpl(JexlEngine engine, java.lang.String expr, ASTJexlScript ref)
Do not let this be generally instantiated with a 'new'.- Parameters:
engine- the interpreter to evaluate the expressionexpr- the expression.ref- the parsed expression.
-
-
Method Detail
-
evaluate
public java.lang.Object evaluate(JexlContext context)
Evaluates the expression with the variables contained in the suppliedJexlContext.- Specified by:
evaluatein interfaceExpression- Parameters:
context- A JexlContext containing variables.- Returns:
- The result of this evaluation
-
dump
public java.lang.String dump()
Returns the JEXL expression by reconstructing it from the parsed tree.- Specified by:
dumpin interfaceExpression- Returns:
- the JEXL expression
-
getExpression
public java.lang.String getExpression()
Returns the JEXL expression this Expression was created with.- Specified by:
getExpressionin interfaceExpression- Returns:
- The JEXL expression to be evaluated
-
toString
public java.lang.String toString()
Provide a string representation of this expression.- Overrides:
toStringin classjava.lang.Object- Returns:
- the expression or blank if it's null.
-
getText
public java.lang.String getText()
Returns the text of this Script.
-
execute
public java.lang.Object execute(JexlContext context)
Executes the script with the variables contained in the suppliedJexlContext.
-
execute
public java.lang.Object execute(JexlContext context, java.lang.Object... args)
Executes the script with the variables contained in the suppliedJexlContextand a set of arguments corresponding to the parameters used during parsing.
-
getParameters
public java.lang.String[] getParameters()
Gets this script parameters.- Specified by:
getParametersin interfaceScript- Returns:
- the parameters or null
- Since:
- 2.1
-
getLocalVariables
public java.lang.String[] getLocalVariables()
Gets this script local variables.- Specified by:
getLocalVariablesin interfaceScript- Returns:
- the local variables or null
- Since:
- 2.1
-
getVariables
public java.util.Set<java.util.List<java.lang.String>> getVariables()
Gets this script variables.Note that since variables can be in an ant-ish form (ie foo.bar.quux), each variable is returned as a list of strings where each entry is a fragment of the variable ({"foo", "bar", "quux"} in the example.
- Specified by:
getVariablesin interfaceScript- Returns:
- the variables or null
- Since:
- 2.1
-
callable
public java.util.concurrent.Callable<java.lang.Object> callable(JexlContext context)
Creates a Callable from this script.This allows to submit it to an executor pool and provides support for asynchronous calls.
The interpreter will handle interruption/cancellation gracefully if needed.
-
callable
public java.util.concurrent.Callable<java.lang.Object> callable(JexlContext context, java.lang.Object... args)
Creates a Callable from this script.This allows to submit it to an executor pool and provides support for asynchronous calls.
The interpreter will handle interruption/cancellation gracefully if needed.
-
-