public class TemplateContext extends Object
| Constructor and Description |
|---|
TemplateContext()
Creates a new template context.
|
TemplateContext(TemplateContext parentContext)
Creates a new template context with the given parent context.
|
TemplateContext(TemplateContext parentContext,
boolean temporary)
Creates a new template context with the given parent context.
|
| Modifier and Type | Method and Description |
|---|---|
TemplateContext |
addAccessor(Class<?> clazz,
Accessor accessor)
Adds an accessor to this context.
|
TemplateContext |
addFilter(String name,
Filter filter)
Adds a filter to this context.
|
TemplateContext |
addPlugin(String name,
Plugin plugin)
Adds a plugin to this context.
|
TemplateContext |
addProvider(TemplateProvider templateProvider)
Deprecated.
Use
addTemplateProvider(TemplateProvider) instead |
TemplateContext |
addTemplateProvider(TemplateProvider templateProvider)
Adds a template provider to this context.
|
Object |
get(String name)
Returns the object with the given name.
|
<T> T |
get(String name,
Class<?> requestedClass)
Returns the object with the given name, if its class is assignable to the
given class.
|
Accessor |
getAccessor(Class<?> clazz)
Returns the accessor for the given class.
|
Filter |
getFilter(String name)
Returns the filter with the given name.
|
Plugin |
getPlugin(String name)
Returns the plugin with the given name.
|
Template |
getTemplate(String name)
Returns the template with the given name.
|
TemplateContext |
mergeContext(TemplateContext templateContext)
Merges the accessors, filters, plugins, template providers, and template
objects into this context.
|
void |
set(String name,
Object value)
Sets the object with the given name to the given value.
|
void |
set(String name,
Object value,
boolean setInParent)
Sets the object with the given name to the given value.
|
public TemplateContext()
public TemplateContext(TemplateContext parentContext)
parentContext - The parent contextpublic TemplateContext(TemplateContext parentContext, boolean temporary)
parentContext - The parent contextpublic TemplateContext addAccessor(Class<?> clazz, Accessor accessor)
clazz - The class to add the accessor foraccessor - The accessor to addpublic TemplateContext addFilter(String name, Filter filter)
name - The name of the filter to addfilter - The filter to addpublic TemplateContext addPlugin(String name, Plugin plugin)
name - The name of the plugin to addplugin - The plugin to add@Deprecated public TemplateContext addProvider(TemplateProvider templateProvider)
addTemplateProvider(TemplateProvider) insteadtemplateProvider - The template provider to addpublic TemplateContext addTemplateProvider(TemplateProvider templateProvider)
templateProvider - The template provider to addpublic Accessor getAccessor(Class<?> clazz)
clazz - The class to get the accessor fornull if no accessor
could be found for the given classpublic Filter getFilter(String name)
name - The name of the filter to getnull if no filter could be foundpublic Plugin getPlugin(String name)
name - The name of the plugin to getnull if no plugin could be foundpublic Object get(String name)
name - The name of the object to getnull if no object could be foundpublic <T> T get(String name, Class<?> requestedClass)
T - The requested type of the objectname - The name of the object to getrequestedClass - The requested classnull if no object could be found, or if
the real class of the object can not be assigned to the requested
classpublic void set(String name, Object value)
name - The name of the objectvalue - The value of the objectpublic void set(String name, Object value, boolean setInParent)
setInParent is true, the object is also set in this context’s
parent context, if there is one.name - The name of the objectvalue - The value of the objectsetInParent - true to set the object in the parent context, false otherwisepublic Template getTemplate(String name)
name - The name of the templatenull if no template could be foundpublic TemplateContext mergeContext(TemplateContext templateContext)
templateContext - The context to mergeCopyright © 2026. All rights reserved.