Class TemplateEngine.TemplateExpression
- All Implemented Interfaces:
JxltEngine.Expression
- Direct Known Subclasses:
TemplateEngine.CompositeExpression,TemplateEngine.ConstantExpression,TemplateEngine.JexlBasedExpression
- Enclosing class:
TemplateEngine
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final TemplateEngine.TemplateExpressionThe source of this template expression(seeprepare(org.apache.commons.jexl3.internal.Interpreter)). -
Constructor Summary
ConstructorsConstructorDescriptionCreates an TemplateExpression. -
Method Summary
Modifier and TypeMethodDescriptionasString()Generates this expression's string representation.protected abstract Objectevaluate(Interpreter interpreter) Interprets a sub-expression.final Objectevaluate(JexlContext context) Evaluates this expression.protected final Objectevaluate(JexlContext context, Frame frame, JexlOptions options) Evaluates this expression.(package private) JexlInfogetInfo()Retrieves this expression's source expression.(package private) abstract TemplateEngine.ExpressionTypegetType()Gets this TemplateExpression type.Gets the list of variables accessed by this expression.protected voidgetVariables(Engine.VarCollector collector) Fills up the list of variables accessed by this unified expression.final booleanChecks whether this expression is deferred.booleanChecks whether this expression is immediate.protected JexlOptionsoptions(JexlContext context) The options to use during evaluation.protected TemplateEngine.TemplateExpressionprepare(Interpreter interpreter) Prepares a sub-expression for interpretation.prepare(JexlContext context) Evaluates the immediate sub-expressions.protected final TemplateEngine.TemplateExpressionprepare(JexlContext context, Frame frame, JexlOptions opts) Prepares this expression.final StringtoString()Formats this expression, adding its source string representation in comments if available: 'expression /*= source *\/'' .Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.commons.jexl3.JxltEngine.Expression
asString
-
Field Details
-
source
The source of this template expression(seeprepare(org.apache.commons.jexl3.internal.Interpreter)).
-
-
Constructor Details
-
TemplateExpression
TemplateExpression(TemplateEngine.TemplateExpression src) Creates an TemplateExpression.- Parameters:
src- the source TemplateExpression if any
-
-
Method Details
-
asString
Description copied from interface:JxltEngine.ExpressionGenerates this expression's string representation.- Specified by:
asStringin interfaceJxltEngine.Expression- Returns:
- the string representation
-
evaluate
Interprets a sub-expression.- Parameters:
interpreter- a JEXL interpreter- Returns:
- the result of interpretation
- Throws:
JexlException- (only for nested and composite)
-
evaluate
Description copied from interface:JxltEngine.ExpressionEvaluates this expression.If the underlying JEXL engine is silent, errors will be logged through its logger as warning.
- Specified by:
evaluatein interfaceJxltEngine.Expression- Parameters:
context- the variable context- Returns:
- the result of this expression evaluation or null if an error occurs and the
JexlEngineis running in silent mode
-
evaluate
Evaluates this expression.- Parameters:
context- the context storing global variablesframe- the frame storing parameters and local variablesoptions- flags and properties that can alter the evaluation behavior.- Returns:
- the expression value
- Throws:
JexlException
-
getInfo
JexlInfo getInfo()- Returns:
- the info
-
getSource
Description copied from interface:JxltEngine.ExpressionRetrieves this expression's source expression.If this expression was prepared, this allows to retrieve the original expression that lead to it.
Other expressions return themselves.
- Specified by:
getSourcein interfaceJxltEngine.Expression- Returns:
- the source expression
-
getType
Gets this TemplateExpression type.- Returns:
- its type
-
getVariables
Description copied from interface:JxltEngine.ExpressionGets the list of variables accessed by this expression.This method will visit all nodes of the sub-expressions and extract all variables whether they are written in 'dot' or 'bracketed' notation. (a.b is equivalent to a['b']).
- Specified by:
getVariablesin interfaceJxltEngine.Expression- Returns:
- the set of variables, each as a list of strings (ant-ish variables use more than 1 string) or the empty set if no variables are used
-
getVariables
Fills up the list of variables accessed by this unified expression.- Parameters:
collector- the variable collector
-
isDeferred
public final boolean isDeferred()Description copied from interface:JxltEngine.ExpressionChecks whether this expression is deferred.- Specified by:
isDeferredin interfaceJxltEngine.Expression- Returns:
- true if deferred, false otherwise
-
isImmediate
public boolean isImmediate()Description copied from interface:JxltEngine.ExpressionChecks whether this expression is immediate.- Specified by:
isImmediatein interfaceJxltEngine.Expression- Returns:
- true if immediate, false otherwise
-
options
The options to use during evaluation.- Parameters:
context- the context- Returns:
- the options
-
prepare
Prepares a sub-expression for interpretation.- Parameters:
interpreter- a JEXL interpreter- Returns:
- a prepared unified expression
- Throws:
JexlException- (only for nested and composite)
-
prepare
Description copied from interface:JxltEngine.ExpressionEvaluates the immediate sub-expressions.When the expression is dependant upon immediate and deferred sub-expressions, evaluates the immediate sub-expressions with the context passed as parameter and returns this expression deferred form.
In effect, this binds the result of the immediate sub-expressions evaluation in the context, allowing to differ evaluation of the remaining (deferred) expression within another context. This only has an effect to nested and composite expressions that contain differed and immediate sub-expressions.
If the underlying JEXL engine is silent, errors will be logged through its logger as warning.*
- Specified by:
preparein interfaceJxltEngine.Expression- Parameters:
context- the context to use for immediate expression evaluations- Returns:
- an
JxltEngine.Expressionor null if an error occurs and theJexlEngineis running in silent mode
-
prepare
protected final TemplateEngine.TemplateExpression prepare(JexlContext context, Frame frame, JexlOptions opts) Prepares this expression.- Parameters:
context- the context storing global variablesframe- the frame storing parameters and local variablesopts- flags and properties that can alter the evaluation behavior.- Returns:
- the expression value
- Throws:
JexlException
-
toString
Description copied from interface:JxltEngine.ExpressionFormats this expression, adding its source string representation in comments if available: 'expression /*= source *\/'' .- Specified by:
toStringin interfaceJxltEngine.Expression- Overrides:
toStringin classObject- Returns:
- the formatted expression string
-