Class 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.

    • 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 info
        arg - 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 evaluate
        args - 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 class InterpreterBase
        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 class Interpreter
        Parameters:
        node - the function node
        data - the data
        Returns:
        the function evaluation result.