public abstract class AbstractEngineContext extends Object implements IEngineContext
Utility abstract class partially implementing IEngineContext
.
This class is meant to be used as a base for implementations of IEngineContext
. Note however that creating
an implementation of IEngineContext
can be very complex and normally unneeded. The default
implementations should suffice for most scenarios.
Note this abstract implementation does not implement basic variable-management methods such as those coming from
the IContext
interface because that is considered the responsibility of the implementing subclasses.
Modifier | Constructor and Description |
---|---|
protected |
AbstractEngineContext(IEngineConfiguration configuration,
Map<String,Object> templateResolutionAttributes,
Locale locale) |
Modifier and Type | Method and Description |
---|---|
String |
buildLink(String base,
Map<String,Object> parameters)
Computes link to be used on a template.
|
IEngineConfiguration |
getConfiguration()
Returns the
IEngineConfiguration (engine configuration) corresponding to the
ITemplateEngine instance this expression context is meant to be used with. |
IExpressionObjects |
getExpressionObjects()
Returns the
IExpressionObjects instance to be used for retrieving (and maybe building
lazily) expression objects (${#expobj}) to be used at Standard Thymeleaf Expressions. |
IdentifierSequences |
getIdentifierSequences()
Returns the
IdentifierSequences object set to be used at the current point of execution. |
Locale |
getLocale()
Returns the locale that should be used for processing the template.
|
String |
getMessage(Class<?> origin,
String key,
Object[] messageParameters,
boolean useAbsentMessageRepresentation)
Computes an externalized (internationalized, i18n) message to be used on a template.
|
IModelFactory |
getModelFactory()
Returns the model factory that can be used for creating or modifying events.
|
TemplateMode |
getTemplateMode()
Returns the template mode of the template currently being processed.
|
Map<String,Object> |
getTemplateResolutionAttributes()
Returns the map of configuration items that have been specified at the process(...) methods of
ITemplateEngine , aimed at further configuring the template being used and its
resolution by means of the ITemplateResolver s. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decreaseLevel, increaseLevel, isVariableLocal, level, removeVariable, setInliner, setSelectionTarget, setTemplateData, setVariable, setVariables
getInliner, getSelectionTarget, getTemplateData, getTemplateStack, hasSelectionTarget
containsVariable, getVariable, getVariableNames
protected AbstractEngineContext(IEngineConfiguration configuration, Map<String,Object> templateResolutionAttributes, Locale locale)
public final IEngineConfiguration getConfiguration()
IExpressionContext
Returns the IEngineConfiguration
(engine configuration) corresponding to the
ITemplateEngine
instance this expression context is meant to be used with.
getConfiguration
in interface IExpressionContext
public final Map<String,Object> getTemplateResolutionAttributes()
ITemplateContext
Returns the map of configuration items that have been specified at the process(...) methods of
ITemplateEngine
, aimed at further configuring the template being used and its
resolution by means of the ITemplateResolver
s.
getTemplateResolutionAttributes
in interface ITemplateContext
public final Locale getLocale()
IContext
Returns the locale that should be used for processing the template.
public final IExpressionObjects getExpressionObjects()
IExpressionContext
Returns the IExpressionObjects
instance to be used for retrieving (and maybe building
lazily) expression objects (${#expobj}) to be used at Standard Thymeleaf Expressions.
getExpressionObjects
in interface IExpressionContext
public final TemplateMode getTemplateMode()
ITemplateContext
Returns the template mode of the template currently being processed.
Note that the TemplateMode
returned here corresponds with origin of the elements or nodes being
currently processed. This is, if a processor is being executed for an element inserted from an external
template (via a th:insert, for example), then this method will return the template mode
for the template in which the inserted fragment lives, not the one it was inserted into.
getTemplateMode
in interface ITemplateContext
public final IModelFactory getModelFactory()
ITemplateContext
Returns the model factory that can be used for creating or modifying events.
This is actually a convenience method completely equivalent to calling
IExpressionContext.getConfiguration()
and then IEngineConfiguration.getModelFactory(TemplateMode)
using as template mode the result of ITemplateContext.getTemplateMode()
.
getModelFactory
in interface ITemplateContext
public final String getMessage(Class<?> origin, String key, Object[] messageParameters, boolean useAbsentMessageRepresentation)
ITemplateContext
Computes an externalized (internationalized, i18n) message to be used on a template.
This method is meant to be called mainly by processors that need to output externalized messages.
getMessage
in interface ITemplateContext
origin
- the origin class to be used for message resolution. When calling from a processor, this
is normally the processor class itself. See IMessageResolver
.key
- the key of the message to be retrieved.messageParameters
- the parameters to be applied to the requested message.useAbsentMessageRepresentation
- whether an absent message representation should be returned in
the case that the message does not exist or not
(see IMessageResolver
).public final String buildLink(String base, Map<String,Object> parameters)
ITemplateContext
Computes link to be used on a template.
This method is meant to be called mainly by processors or expressions that need to output links.
buildLink
in interface ITemplateContext
base
- the base of the link URL to be built, i.e. its path. Can be null.parameters
- the (optional) URL parameters.public final IdentifierSequences getIdentifierSequences()
ITemplateContext
Returns the IdentifierSequences
object set to be used at the current point of execution.
getIdentifierSequences
in interface ITemplateContext
Copyright © 2016 The THYMELEAF team. All rights reserved.