Class TemplateInterpreter
java.lang.Object
org.apache.commons.jexl3.parser.ParserVisitor
org.apache.commons.jexl3.internal.InterpreterBase
org.apache.commons.jexl3.internal.Interpreter
org.apache.commons.jexl3.internal.TemplateInterpreter
The type of interpreter to use during evaluation of templates.
This context exposes its writer as '$jexl' to the scripts.
public for introspection purpose.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.apache.commons.jexl3.internal.Interpreter
Interpreter.AnnotatedCall
Nested classes/interfaces inherited from class org.apache.commons.jexl3.internal.InterpreterBase
InterpreterBase.ArithmeticFuncall, InterpreterBase.CallDispatcher, InterpreterBase.ContextFuncall, InterpreterBase.ContextualCtor, InterpreterBase.Funcall
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final TemplateEngine.TemplateExpression[]
The array of template expressions.(package private) final Writer
The writer used to output.Fields inherited from class org.apache.commons.jexl3.internal.Interpreter
block, fp, frame, INTER
Fields inherited from class org.apache.commons.jexl3.internal.InterpreterBase
arithmetic, cache, cancelled, context, EMPTY_PARAMS, fqcnSolver, functions, functors, jexl, logger, ns, operators, options, uberspect
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Creates a template interpreter instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Prints to output.void
include
(JxltEngine.Template script, Object... args) Includes a call to another template.void
print
(int e) Prints a unified expression evaluation result.private void
printComposite
(TemplateEngine.CompositeExpression composite) Prints a composite expression.protected Object
resolveNamespace
(String prefix, JexlNode node) Resolves a namespace, eventually allocating an instance using context as constructor argument.protected Object
visit
(ASTFunctionNode node, Object data) Interprets a function node.protected Object
visit
(ASTIdentifier node, Object data) protected Object
visit
(ASTJexlScript script, Object data) Methods inherited from class org.apache.commons.jexl3.internal.Interpreter
call, executeAssign, interpret, processAnnotation, processAnnotation, putThreadInterpreter, runClosure, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visitLexicalNode
Methods inherited from class org.apache.commons.jexl3.internal.InterpreterBase
annotationError, callArguments, cancel, cancelCheck, closeIfSupported, closeIfSupported, constVariable, defineVariable, findNullOperand, findNullOperand, functionArgument, functionArguments, getAttribute, getVariable, invocationException, isCancellable, isCancelled, isSafe, isSilent, isStrictEngine, isStrictOperand, isTernaryProtected, isVariableDefined, operatorError, redefinedVariable, setAttribute, setContextVariable, stringifyProperty, stringifyPropertyValue, undefinedVariable, unsolvableMethod, unsolvableMethod, unsolvableProperty, unsolvableVariable, variableError
Methods inherited from class org.apache.commons.jexl3.parser.ParserVisitor
visit, visit
-
Field Details
-
exprs
The array of template expressions. -
writer
The writer used to output.
-
-
Constructor Details
-
TemplateInterpreter
Creates a template interpreter instance.- Parameters:
args
- the template interpreter arguments
-
-
Method Details
-
doPrint
Prints to output.This will dynamically try to find the best suitable method in the writer through uberspection. Subclassing Writer by adding 'print' methods should be the preferred way to specialize output.
- Parameters:
info
- the source infoarg
- the argument to print out
-
include
Includes a call to another template.Includes another template using this template initial context and writer.
- Parameters:
script
- the TemplateScript to evaluateargs
- the arguments
-
print
public void print(int e) Prints a unified expression evaluation result.- Parameters:
e
- the expression number
-
printComposite
Prints a composite expression.- Parameters:
composite
- the composite expression
-
resolveNamespace
Description copied from class:InterpreterBase
Resolves a namespace, eventually allocating an instance using context as constructor argument.The lifetime of such instances span the current expression or script evaluation.
- Overrides:
resolveNamespace
in classInterpreterBase
- Parameters:
prefix
- the prefix name (can be null for global namespace)node
- the AST node- Returns:
- the namespace instance
-
visit
Interprets a function node. print() and include() must be decoded by this interpreter since delegating to the Uberspect may be sandboxing the interpreter itself making it unable to call the function.- Overrides:
visit
in classInterpreter
- Parameters:
node
- the function nodedata
- the data- Returns:
- the function evaluation result.
-
visit
- Overrides:
visit
in classInterpreter
-
visit
- Overrides:
visit
in classInterpreter
-