public abstract class AbstractContext extends Object implements IContext
Abstract class for IContext implementations, providing some of the
features required to implement this interface.
| Modifier and Type | Field and Description |
|---|---|
static String |
EXEC_INFO_VARIABLE_NAME
Name of the variable containing the "execution info" object.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractContext()
Create an instance without specifying a locale.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addContextExecutionInfo(String templateName)
Adds the context execution info to the variables map.
|
protected abstract IContextExecutionInfo |
buildContextExecutionInfo(String templateName)
Creates the specific instance of
IContextExecutionInfo to be added
to the context as the execInfo variable. |
void |
clearVariables()
Removes from the map all the context variables currently set.
|
Locale |
getLocale()
Returns the locale that will be used for template execution.
|
VariablesMap<String,Object> |
getVariables()
Returns the
VariablesMap object containing the variables that will be
available for the execution of expressions inside templates. |
void |
setLocale(Locale locale)
Set the locale to be used for template execution.
|
void |
setVariable(String name,
Object value)
Adds a variable to the current set of context variables.
|
void |
setVariables(Map<String,?> additionalVariables)
Adds a set of variables to the current set of context variables.
|
public static final String EXEC_INFO_VARIABLE_NAME
Name of the variable containing the "execution info" object.
protected AbstractContext()
Create an instance without specifying a locale. Using this constructor, the default locale (Locale.getDefault()) will be used.
public Locale getLocale()
IContextReturns the locale that will be used for template execution. This locale will determine the language of the externalized messages resolved by the message resolvers.
public void setLocale(Locale locale)
Set the locale to be used for template execution.
The locale specified using this method overrides the one that might have been set using a constructor.
locale - the locale to be set.public final VariablesMap<String,Object> getVariables()
IContext
Returns the VariablesMap object containing the variables that will be
available for the execution of expressions inside templates.
getVariables in interface IContextpublic final void setVariable(String name, Object value)
Adds a variable to the current set of context variables.
name - the name of the variable.value - the value of the variable.public final void setVariables(Map<String,?> additionalVariables)
Adds a set of variables to the current set of context variables.
additionalVariables - the new variables to be added.public final void clearVariables()
Removes from the map all the context variables currently set.
public final void addContextExecutionInfo(String templateName)
Adds the context execution info to the variables map.
This IContext implementation adds an object of the
ContextExecutionInfo class with variable name execInfo.
addContextExecutionInfo in interface IContexttemplateName - the name of the template being executedprotected abstract IContextExecutionInfo buildContextExecutionInfo(String templateName)
Creates the specific instance of IContextExecutionInfo to be added
to the context as the execInfo variable.
templateName - the name of the template being executedCopyright © 2016 The THYMELEAF team. All rights reserved.