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.AnnotatedCallNested 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 WriterThe writer used to output.Fields inherited from class org.apache.commons.jexl3.internal.Interpreter
block, fp, frame, INTERFields 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
ConstructorsModifierConstructorDescriptionprotectedCreates a template interpreter instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidPrints to output.voidinclude(JxltEngine.Template script, Object... args) Includes a call to another template.voidprint(int e) Prints a unified expression evaluation result.private voidprintComposite(TemplateEngine.CompositeExpression composite) Prints a composite expression.protected ObjectresolveNamespace(String prefix, JexlNode node) Resolves a namespace, eventually allocating an instance using context as constructor argument.protected Objectvisit(ASTFunctionNode node, Object data) Interprets a function node.protected Objectvisit(ASTIdentifier node, Object data) protected Objectvisit(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, visitLexicalNodeMethods 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, variableErrorMethods 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:InterpreterBaseResolves a namespace, eventually allocating an instance using context as constructor argument.The lifetime of such instances span the current expression or script evaluation.
- Overrides:
resolveNamespacein 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:
visitin classInterpreter- Parameters:
node- the function nodedata- the data- Returns:
- the function evaluation result.
-
visit
- Overrides:
visitin classInterpreter
-
visit
- Overrides:
visitin classInterpreter
-