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
-
public class TemplateInterpreter extends Interpreter
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 Classes Modifier and Type Class Description static class
TemplateInterpreter.Arguments
Helper ctor.-
Nested 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
Fields Modifier and Type Field Description (package private) TemplateEngine.TemplateExpression[]
exprs
The array of template expressions.(package private) java.io.Writer
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
Constructors Modifier Constructor Description protected
TemplateInterpreter(TemplateInterpreter.Arguments args)
Creates a template interpreter instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
doPrint(JexlInfo info, java.lang.Object arg)
Prints to output.void
include(JxltEngine.Template script, java.lang.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 java.lang.Object
resolveNamespace(java.lang.String prefix, JexlNode node)
Resolves a namespace, eventually allocating an instance using context as constructor argument.protected java.lang.Object
visit(ASTFunctionNode node, java.lang.Object data)
Interprets a function node.protected java.lang.Object
visit(ASTIdentifier node, java.lang.Object data)
protected java.lang.Object
visit(ASTJexlScript script, java.lang.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 Detail
-
exprs
final TemplateEngine.TemplateExpression[] exprs
The array of template expressions.
-
writer
final java.io.Writer writer
The writer used to output.
-
-
Constructor Detail
-
TemplateInterpreter
protected TemplateInterpreter(TemplateInterpreter.Arguments args)
Creates a template interpreter instance.- Parameters:
args
- the template interpreter arguments
-
-
Method Detail
-
doPrint
private void doPrint(JexlInfo info, java.lang.Object arg)
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
public void include(JxltEngine.Template script, java.lang.Object... args)
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
private void printComposite(TemplateEngine.CompositeExpression composite)
Prints a composite expression.- Parameters:
composite
- the composite expression
-
resolveNamespace
protected java.lang.Object resolveNamespace(java.lang.String prefix, JexlNode node)
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
protected java.lang.Object visit(ASTFunctionNode node, java.lang.Object data)
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
protected java.lang.Object visit(ASTIdentifier node, java.lang.Object data)
- Overrides:
visit
in classInterpreter
-
visit
protected java.lang.Object visit(ASTJexlScript script, java.lang.Object data)
- Overrides:
visit
in classInterpreter
-
-