Package org.thymeleaf.context
Class AbstractContext
Object
org.thymeleaf.context.AbstractContext
- All Implemented Interfaces:
IContext
- Direct Known Subclasses:
AbstractExpressionContext,Context,WebContext
Abstract base class for most IContext implementations.
Note a class with this name existed since 1.0, but it was completely reimplemented in Thymeleaf 3.0
- Since:
- 3.0.0
- Author:
- Daniel Fernández
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedAbstractContext(Locale locale) protectedAbstractContext(Locale locale, Map<String, Object> variables) -
Method Summary
Modifier and TypeMethodDescriptionvoidRemoves all the variables from the context.final booleancontainsVariable(String name) Checks whether a specific variable is already contained in this context or not.final LocaleReturns the locale that should be used for processing the template.final ObjectgetVariable(String name) Retrieve a specific variable, by name.Get a list with all the names of variables contained at this context.voidremoveVariable(String name) Removes a variable from the context.voidSets the locale to be used.voidsetVariable(String name, Object value) Sets a new variable into the context.voidsetVariables(Map<String, Object> variables) Sets several variables at a time into the context.
-
Constructor Details
-
AbstractContext
protected AbstractContext() -
AbstractContext
-
AbstractContext
-
-
Method Details
-
getLocale
Description copied from interface:IContextReturns the locale that should be used for processing the template.
-
containsVariable
Description copied from interface:IContextChecks whether a specific variable is already contained in this context or not.
- Specified by:
containsVariablein interfaceIContext- Parameters:
name- the name of the variable to be checked.- Returns:
trueif the variable is already contained,falseif not.
-
getVariableNames
Description copied from interface:IContextGet a list with all the names of variables contained at this context.
- Specified by:
getVariableNamesin interfaceIContext- Returns:
- the variable names.
-
getVariable
Description copied from interface:IContextRetrieve a specific variable, by name.
- Specified by:
getVariablein interfaceIContext- Parameters:
name- the name of the variable to be retrieved.- Returns:
- the variable's value.
-
setLocale
Sets the locale to be used.
- Parameters:
locale- the locale.
-
setVariable
Sets a new variable into the context.
- Parameters:
name- the name of the variable.value- the value of the variable.
-
setVariables
Sets several variables at a time into the context.
- Parameters:
variables- the variables to be set.
-
removeVariable
Removes a variable from the context.
- Parameters:
name- the name of the variable to be removed.
-
clearVariables
public void clearVariables()Removes all the variables from the context.
-