Class UnifiedJEXL.TemplateContext
java.lang.Object
org.apache.commons.jexl2.UnifiedJEXL.TemplateContext
- All Implemented Interfaces:
JexlContext, NamespaceResolver
- Enclosing class:
UnifiedJEXL
public final class UnifiedJEXL.TemplateContext
extends Object
implements JexlContext, NamespaceResolver
The type of context to use during evaluation of templates.
This context exposes its writer as '$jexl' to the scripts.
public for introspection purpose.
- Since:
- 2.1
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTemplateContext(JexlContext jcontext, JexlEngine.Frame jframe, UnifiedJEXL.Expression[] expressions, Writer out) Creates a template context instance. -
Method Summary
Modifier and TypeMethodDescriptionGets the value of a variable.getFrame()Gets this context calling frame.booleanChecks whether a variable is defined in this context.voidinclude(UnifiedJEXL.Template template, Object... args) Includes a call to another template.voidprint(int e) Prints an expression result.protected voidprintComposite(org.apache.commons.jexl2.UnifiedJEXL.CompositeExpression composite) Prints a composite expression.Resolves a namespace by its name.voidSets the value of a variable.
-
Constructor Details
-
TemplateContext
protected TemplateContext(JexlContext jcontext, JexlEngine.Frame jframe, UnifiedJEXL.Expression[] expressions, Writer out) Creates a template context instance.- Parameters:
jcontext- the base contextjframe- the calling frameexpressions- the list of expression from the template to evaluateout- the output writer
-
-
Method Details
-
getFrame
-
get
Gets the value of a variable.- Specified by:
getin interfaceJexlContext- Parameters:
name- the variable's name- Returns:
- the value
-
set
Sets the value of a variable.- Specified by:
setin interfaceJexlContext- Parameters:
name- the variable's namevalue- the variable's value
-
has
Checks whether a variable is defined in this context.A variable may be defined with a null value; this method checks whether the value is null or if the variable is undefined.
- Specified by:
hasin interfaceJexlContext- Parameters:
name- the variable's name- Returns:
- true if it exists, false otherwise
-
resolveNamespace
Resolves a namespace by its name.- Specified by:
resolveNamespacein interfaceNamespaceResolver- Parameters:
ns- the name- Returns:
- the namespace object
-
include
Includes a call to another template.Evaluates a template using this template initial context and writer.
- Parameters:
template- the template to evaluateargs- the arguments
-
print
-
printComposite
Prints a composite expression.- Parameters:
composite- the composite expression
-