public final class UnifiedJEXL.TemplateContext extends java.lang.Object implements JexlContext, NamespaceResolver
This context exposes its writer as '$jexl' to the scripts.
public for introspection purpose.
Modifier and Type | Field and Description |
---|---|
private UnifiedJEXL.Expression[] |
exprs
The array of UnifiedJEXL expressions.
|
private JexlEngine.Frame |
frame
The call frame.
|
private JexlContext |
wrap
The wrapped context.
|
private java.io.Writer |
writer
The writer used to output.
|
Modifier | Constructor and Description |
---|---|
protected |
TemplateContext(JexlContext jcontext,
JexlEngine.Frame jframe,
UnifiedJEXL.Expression[] expressions,
java.io.Writer out)
Creates a template context instance.
|
Modifier and Type | Method and Description |
---|---|
private void |
doPrint(java.lang.Object arg)
Prints to output.
|
java.lang.Object |
get(java.lang.String name)
Gets the value of a variable.
|
JexlEngine.Frame |
getFrame()
Gets this context calling frame.
|
boolean |
has(java.lang.String name)
Checks whether a variable is defined in this context.
|
void |
include(UnifiedJEXL.Template template,
java.lang.Object... args)
Includes a call to another template.
|
void |
print(int e)
Prints an expression result.
|
protected void |
printComposite(UnifiedJEXL.CompositeExpression composite)
Prints a composite expression.
|
java.lang.Object |
resolveNamespace(java.lang.String ns)
Resolves a namespace by its name.
|
void |
set(java.lang.String name,
java.lang.Object value)
Sets the value of a variable.
|
private final JexlContext wrap
private final UnifiedJEXL.Expression[] exprs
private final java.io.Writer writer
private final JexlEngine.Frame frame
protected TemplateContext(JexlContext jcontext, JexlEngine.Frame jframe, UnifiedJEXL.Expression[] expressions, java.io.Writer out)
jcontext
- the base contextjframe
- the calling frameexpressions
- the list of expression from the template to evaluateout
- the output writerpublic JexlEngine.Frame getFrame()
public java.lang.Object get(java.lang.String name)
get
in interface JexlContext
name
- the variable's namepublic void set(java.lang.String name, java.lang.Object value)
set
in interface JexlContext
name
- the variable's namevalue
- the variable's valuepublic boolean has(java.lang.String name)
A variable may be defined with a null value; this method checks whether the value is null or if the variable is undefined.
has
in interface JexlContext
name
- the variable's namepublic java.lang.Object resolveNamespace(java.lang.String ns)
resolveNamespace
in interface NamespaceResolver
ns
- the namepublic void include(UnifiedJEXL.Template template, java.lang.Object... args)
Evaluates a template using this template initial context and writer.
template
- the template to evaluateargs
- the argumentspublic void print(int e)
e
- the expression numberprotected void printComposite(UnifiedJEXL.CompositeExpression composite)
composite
- the composite expressionprivate void doPrint(java.lang.Object arg)
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.
arg
- the argument to print out