Class AbstractEngineContext
- All Implemented Interfaces:
IContext,IEngineContext,IExpressionContext,ITemplateContext
- Direct Known Subclasses:
EngineContext,WebEngineContext
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.
- Since:
- 3.0.0
- Author:
- Daniel Fernández
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractEngineContext(IEngineConfiguration configuration, Map<String, Object> templateResolutionAttributes, Locale locale) -
Method Summary
Modifier and TypeMethodDescriptionfinal StringComputes link to be used on a template.final IEngineConfigurationReturns theIEngineConfiguration(engine configuration) corresponding to theITemplateEngineinstance this expression context is meant to be used with.final IExpressionObjectsReturns theIExpressionObjectsinstance to be used for retrieving (and maybe building lazily) expression objects (${#expobj}) to be used at Standard Thymeleaf Expressions.final IdentifierSequencesReturns theIdentifierSequencesobject set to be used at the current point of execution.final LocaleReturns the locale that should be used for processing the template.final StringgetMessage(Class<?> origin, String key, Object[] messageParameters, boolean useAbsentMessageRepresentation) Computes an externalized (internationalized, i18n) message to be used on a template.final IModelFactoryReturns the model factory that can be used for creating or modifying events.final TemplateModeReturns the template mode of the template currently being processed.Returns the map of configuration items that have been specified at theprocess(...)methods ofITemplateEngine, aimed at further configuring the template being used and its resolution by means of theITemplateResolvers.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.thymeleaf.context.IContext
containsVariable, getVariable, getVariableNamesMethods inherited from interface org.thymeleaf.context.IEngineContext
decreaseLevel, getElementStackAbove, increaseLevel, isVariableLocal, level, removeVariable, setElementTag, setInliner, setSelectionTarget, setTemplateData, setVariable, setVariablesMethods inherited from interface org.thymeleaf.context.ITemplateContext
getElementStack, getInliner, getSelectionTarget, getTemplateData, getTemplateStack, hasSelectionTarget
-
Constructor Details
-
AbstractEngineContext
protected AbstractEngineContext(IEngineConfiguration configuration, Map<String, Object> templateResolutionAttributes, Locale locale)
-
-
Method Details
-
getConfiguration
Description copied from interface:IExpressionContextReturns the
IEngineConfiguration(engine configuration) corresponding to theITemplateEngineinstance this expression context is meant to be used with.- Specified by:
getConfigurationin interfaceIExpressionContext- Returns:
- the engine configuration.
-
getTemplateResolutionAttributes
Description copied from interface:ITemplateContextReturns the map of configuration items that have been specified at the
process(...)methods ofITemplateEngine, aimed at further configuring the template being used and its resolution by means of theITemplateResolvers.- Specified by:
getTemplateResolutionAttributesin interfaceITemplateContext- Returns:
- the template resolution attributes map
-
getLocale
Description copied from interface:IContextReturns the locale that should be used for processing the template.
-
getExpressionObjects
Description copied from interface:IExpressionContextReturns the
IExpressionObjectsinstance to be used for retrieving (and maybe building lazily) expression objects (${#expobj}) to be used at Standard Thymeleaf Expressions.- Specified by:
getExpressionObjectsin interfaceIExpressionContext- Returns:
- the expression objects instance.
-
getTemplateMode
Description copied from interface:ITemplateContextReturns the template mode of the template currently being processed.
Note that the
TemplateModereturned 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 ath: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.- Specified by:
getTemplateModein interfaceITemplateContext- Returns:
- the template mode of the elements or nodes being currently processed.
-
getModelFactory
Description copied from interface:ITemplateContextReturns 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 thenIEngineConfiguration.getModelFactory(TemplateMode)using as template mode the result ofITemplateContext.getTemplateMode().- Specified by:
getModelFactoryin interfaceITemplateContext- Returns:
- the model factory
-
getMessage
public final String getMessage(Class<?> origin, String key, Object[] messageParameters, boolean useAbsentMessageRepresentation) Description copied from interface:ITemplateContextComputes 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.
- Specified by:
getMessagein interfaceITemplateContext- Parameters:
origin- the origin class to be used for message resolution. When calling from a processor, this is normally the processor class itself. SeeIMessageResolver.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 (seeIMessageResolver).- Returns:
- the requested message, correctly formatted. Or an absent message representation, or
nullif no absent message representations are allowed.
-
buildLink
Description copied from interface:ITemplateContextComputes link to be used on a template.
This method is meant to be called mainly by processors or expressions that need to output links.
- Specified by:
buildLinkin interfaceITemplateContext- Parameters:
base- the base of the link URL to be built, i.e. its path. Can be null.parameters- the (optional) URL parameters.- Returns:
- the built URL, or an exception if no link builders are able to build this link.
-
getIdentifierSequences
Description copied from interface:ITemplateContextReturns the
IdentifierSequencesobject set to be used at the current point of execution.- Specified by:
getIdentifierSequencesin interfaceITemplateContext- Returns:
- the identifier sequences object.
-