Package org.thymeleaf.context
Class AbstractContext
- java.lang.Object
-
- org.thymeleaf.context.AbstractContext
-
- All Implemented Interfaces:
IContext
- Direct Known Subclasses:
AbstractExpressionContext,Context,WebContext
public abstract class AbstractContext extends java.lang.Object implements IContext
Abstract base class for most
IContextimplementations.Note a class with this name existed since 1.0, but it was completely reimplemented in Thymeleaf 3.0
- Since:
- 3.0.0
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractContext()protectedAbstractContext(java.util.Locale locale)protectedAbstractContext(java.util.Locale locale, java.util.Map<java.lang.String,java.lang.Object> variables)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearVariables()Removes all the variables from the context.booleancontainsVariable(java.lang.String name)Checks whether a specific variable is already contained in this context or not.java.util.LocalegetLocale()Returns the locale that should be used for processing the template.java.lang.ObjectgetVariable(java.lang.String name)Retrieve a specific variable, by name.java.util.Set<java.lang.String>getVariableNames()Get a list with all the names of variables contained at this context.voidremoveVariable(java.lang.String name)Removes a variable from the context.voidsetLocale(java.util.Locale locale)Sets the locale to be used.voidsetVariable(java.lang.String name, java.lang.Object value)Sets a new variable into the context.voidsetVariables(java.util.Map<java.lang.String,java.lang.Object> variables)Sets several variables at a time into the context.
-
-
-
Method Detail
-
getLocale
public final java.util.Locale getLocale()
Description copied from interface:IContextReturns the locale that should be used for processing the template.
-
containsVariable
public final boolean containsVariable(java.lang.String name)
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
public final java.util.Set<java.lang.String> 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
public final java.lang.Object getVariable(java.lang.String name)
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
public void setLocale(java.util.Locale locale)
Sets the locale to be used.
- Parameters:
locale- the locale.
-
setVariable
public void setVariable(java.lang.String name, java.lang.Object value)Sets a new variable into the context.
- Parameters:
name- the name of the variable.value- the value of the variable.
-
setVariables
public void setVariables(java.util.Map<java.lang.String,java.lang.Object> variables)
Sets several variables at a time into the context.
- Parameters:
variables- the variables to be set.
-
removeVariable
public void removeVariable(java.lang.String name)
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.
-
-