public final class TemplateScript extends Object implements JxltEngine.Template
Constructor and Description |
---|
TemplateScript(TemplateEngine engine,
JexlInfo info,
String directive,
Reader reader,
String... parms)
Creates a new template from an character input.
|
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() |
public TemplateScript(TemplateEngine engine, JexlInfo info, String directive, Reader reader, String... parms)
engine
- the template engineinfo
- the source infodirective
- the prefix for lines of code; can not be "$", "${", "#" or "#{"
since this would preclude being able to differentiate directives and jxlt expressionsreader
- the input readerparms
- the parameter namesNullPointerException
- if either the directive prefix or input is nullIllegalArgumentException
- if the directive prefix is invalidpublic String asString()
JxltEngine.Template
asString
in interface JxltEngine.Template
public TemplateScript prepare(JexlContext context)
JxltEngine.Template
prepare
in interface JxltEngine.Template
context
- the context to prepare againstpublic void evaluate(JexlContext context, Writer writer)
JxltEngine.Template
evaluate
in interface JxltEngine.Template
context
- the context to use during evaluationwriter
- the writer to use for outputpublic void evaluate(JexlContext context, Writer writer, Object... args)
JxltEngine.Template
evaluate
in interface JxltEngine.Template
context
- the context to use during evaluationwriter
- the writer to use for outputargs
- the argumentspublic Set<List<String>> getVariables()
JxltEngine.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']).
getVariables
in interface JxltEngine.Template
public String[] getParameters()
JxltEngine.Template
getParameters
in interface JxltEngine.Template
Copyright © 2001–2015 The Apache Software Foundation. All rights reserved.