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 TemplateMode
Default template mode:TemplateMode.HTML
Fields inherited from class org.thymeleaf.templateresolver.AbstractTemplateResolver
DEFAULT_EXISTENCE_CHECK, DEFAULT_USE_DECOUPLED_LOGIC
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected TemplateMode
computeTemplateMode
(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 ITemplateResource
computeTemplateResource
(IEngineConfiguration configuration, String ownerTemplate, String template, Map<String, Object> templateResolutionAttributes) Computes the resolved template resource.protected ICacheEntryValidity
computeValidity
(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 TemplateMode
Returns the template mode to be applied to templates resolved by this template resolver.void
setTemplate
(String template) Set the text that will be returned as the resolved template.final void
setTemplateMode
(String templateMode) Sets the template mode to be applied to templates resolved by this resolver.final void
setTemplateMode
(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
TemplateMode
class.- 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:AbstractTemplateResolver
Computes the resolved template resource.
- Specified by:
computeTemplateResource
in 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:AbstractTemplateResolver
Computes the template mode that should be applied to a template, according to existing configuration.
- Specified by:
computeTemplateMode
in 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:AbstractTemplateResolver
Computes 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:
computeValidity
in 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
-