org.apache.commons.jexl3.internal

## Class TemplateScript

- java.lang.Object
- - org.apache.commons.jexl3.internal.TemplateScript

- All Implemented Interfaces:
    JxltEngine.Template

      public final class TemplateScript
      extends Object
      implements JxltEngine.Template

  A Template instance.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TemplateScript(TemplateEngine engine, JexlInfo info, String directive, Reader reader, String... parms)` Creates a new template from an character input.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `asString()` Recreate the template source from its inner components.
    `void` | `evaluate(JexlContext context, Writer writer)` Evaluates this template.
    `void` | `evaluate(JexlContext context, Writer writer, Object... args)` Evaluates this template.
    `String[]` | `getParameters()` Gets the list of parameters expected by this template.
    `Set<List<String>>` | `getVariables()` Gets the list of variables accessed by this template.
    `TemplateScript` | `prepare(JexlContext context)` Prepares this template by expanding any contained deferred TemplateExpression.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### TemplateScript

          public TemplateScript(TemplateEngine engine,
                        JexlInfo info,
                        String directive,
                        Reader reader,
                        String... parms)

      Creates a new template from an character input.
      Parameters:
        `engine` - the template engine
        `info` - the source info
        `directive` - the prefix for lines of code; can not be "$", "${", "#" or "#{" since this would preclude being able to differentiate directives and jxlt expressions
        `reader` - the input reader
        `parms` - the parameter names
      Throws:
        `NullPointerException` - if either the directive prefix or input is null
        `IllegalArgumentException` - if the directive prefix is invalid

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### asString

          public String asString()

      Description copied from interface: `JxltEngine.Template`
      Recreate the template source from its inner components.
      Specified by:
        `asString` in interface `JxltEngine.Template`
      Returns:
        the template source rewritten

    - #### prepare

          public TemplateScript prepare(JexlContext context)

      Description copied from interface: `JxltEngine.Template`
      Prepares this template by expanding any contained deferred TemplateExpression.
      Specified by:
        `prepare` in interface `JxltEngine.Template`
      Parameters:
        `context` - the context to prepare against
      Returns:
        the prepared version of the template

    - #### evaluate

          public void evaluate(JexlContext context,
                      Writer writer)

      Description copied from interface: `JxltEngine.Template`
      Evaluates this template.
      Specified by:
        `evaluate` in interface `JxltEngine.Template`
      Parameters:
        `context` - the context to use during evaluation
        `writer` - the writer to use for output

    - #### evaluate

          public void evaluate(JexlContext context,
                      Writer writer,
                      Object... args)

      Description copied from interface: `JxltEngine.Template`
      Evaluates this template.
      Specified by:
        `evaluate` in interface `JxltEngine.Template`
      Parameters:
        `context` - the context to use during evaluation
        `writer` - the writer to use for output
        `args` - the arguments

    - #### getVariables

          public Set<List<String>> getVariables()

      Description copied from interface: `JxltEngine.Template`
      Gets the list of variables accessed by this template.

      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:
        `getVariables` in interface `JxltEngine.Template`
      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

    - #### getParameters

          public String[] getParameters()

      Description copied from interface: `JxltEngine.Template`
      Gets the list of parameters expected by this template.
      Specified by:
        `getParameters` in interface `JxltEngine.Template`
      Returns:
        the parameter names array

Copyright © 2001–2015 The Apache Software Foundation. All rights reserved.