Class DefaultTemplateResolver
- All Implemented Interfaces:
ITemplateResolver
Implementation of ITemplateResolver that extends AbstractTemplateResolver
and acts as a default template resolver, always returning the same specified text in the form of
a StringTemplateResource instance.
This template resolver will consider its resolved templates always cacheable.
Also, the TemplateMode.HTML template mode will be used by default.
- Since:
- 3.0.0
- Author:
- Daniel Fernández
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TemplateModeDefault template mode:TemplateMode.HTMLFields inherited from class org.thymeleaf.templateresolver.AbstractTemplateResolver
DEFAULT_EXISTENCE_CHECK, DEFAULT_USE_DECOUPLED_LOGIC -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected TemplateModecomputeTemplateMode(IEngineConfiguration configuration, String ownerTemplate, String template, Map<String, Object> templateResolutionAttributes) Computes the template mode that should be applied to a template, according to existing configuration.protected ITemplateResourcecomputeTemplateResource(IEngineConfiguration configuration, String ownerTemplate, String template, Map<String, Object> templateResolutionAttributes) Computes the resolved template resource.protected ICacheEntryValiditycomputeValidity(IEngineConfiguration configuration, String ownerTemplate, String template, Map<String, Object> templateResolutionAttributes) Computes the validity to be applied to the template resolution.Returns the text that will always be returned by this template resolver as the resolved template.final TemplateModeReturns the template mode to be applied to templates resolved by this template resolver.voidsetTemplate(String template) Set the text that will be returned as the resolved template.final voidsetTemplateMode(String templateMode) Sets the template mode to be applied to templates resolved by this resolver.final voidsetTemplateMode(TemplateMode templateMode) Sets the template mode to be applied to templates resolved by this resolver.Methods inherited from class org.thymeleaf.templateresolver.AbstractTemplateResolver
computeResolvable, getCheckExistence, getName, getOrder, getResolvablePatterns, getResolvablePatternSpec, getUseDecoupledLogic, resolveTemplate, setCheckExistence, setName, setOrder, setResolvablePatterns, setUseDecoupledLogic
-
Field Details
-
DEFAULT_TEMPLATE_MODE
Default template mode:
TemplateMode.HTML
-
-
Constructor Details
-
DefaultTemplateResolver
public DefaultTemplateResolver()Creates a new instance of this template resolver.
-
-
Method Details
-
getTemplateMode
Returns the template mode to be applied to templates resolved by this template resolver.
- Returns:
- the template mode to be used.
-
setTemplateMode
Sets the template mode to be applied to templates resolved by this resolver.
- Parameters:
templateMode- the template mode.
-
setTemplateMode
Sets the template mode to be applied to templates resolved by this resolver.
Allowed templates modes are defined by the
TemplateModeclass.- Parameters:
templateMode- the template mode.
-
getTemplate
Returns the text that will always be returned by this template resolver as the resolved template.
- Returns:
- the text to be returned as template.
-
setTemplate
Set the text that will be returned as the resolved template.
- Parameters:
template- the text to be returned as template.
-
computeTemplateResource
protected ITemplateResource computeTemplateResource(IEngineConfiguration configuration, String ownerTemplate, String template, Map<String, Object> templateResolutionAttributes) Description copied from class:AbstractTemplateResolverComputes the resolved template resource.
- Specified by:
computeTemplateResourcein classAbstractTemplateResolver- Parameters:
configuration- the engine configuration.ownerTemplate- the owner template, if the resource being computed is a fragment. Might be null.template- the template to be resolved (usually its name).templateResolutionAttributes- the template resolution attributes, if any. Might be null.- Returns:
- the template resource, or null if this template cannot be resolved (or the resource does not exist).
-
computeTemplateMode
protected TemplateMode computeTemplateMode(IEngineConfiguration configuration, String ownerTemplate, String template, Map<String, Object> templateResolutionAttributes) Description copied from class:AbstractTemplateResolverComputes the template mode that should be applied to a template, according to existing configuration.
- Specified by:
computeTemplateModein classAbstractTemplateResolver- Parameters:
configuration- the engine configuration.ownerTemplate- the owner template, if the resource being computed is a fragment. Might be null.template- the template to be resolved (usually its name).templateResolutionAttributes- the template resolution attributes, if any. Might be null.- Returns:
- the template mode proposed by the template resolver for the resolved template.
-
computeValidity
protected ICacheEntryValidity computeValidity(IEngineConfiguration configuration, String ownerTemplate, String template, Map<String, Object> templateResolutionAttributes) Description copied from class:AbstractTemplateResolverComputes the validity to be applied to the template resolution. This includes determining whether the template can be cached or not, and also in what circumstances (for instance, for how much time) can its cache entry be considered valid.
- Specified by:
computeValidityin classAbstractTemplateResolver- Parameters:
configuration- the engine configuration.ownerTemplate- the owner template, if the resource being computed is a fragment. Might be null.template- the template to be resolved (usually its name).templateResolutionAttributes- the template resolution attributes, if any. Might be null.- Returns:
- the validity
-