Class DefaultTemplateResolver
- Object
-
- org.thymeleaf.templateresolver.AbstractTemplateResolver
-
- org.thymeleaf.templateresolver.DefaultTemplateResolver
-
- All Implemented Interfaces:
ITemplateResolver
public class DefaultTemplateResolver extends AbstractTemplateResolver
Implementation of
ITemplateResolver
that extendsAbstractTemplateResolver
and acts as a default template resolver, always returning the same specified text in the form of aStringTemplateResource
instance.This template resolver will consider its resolved templates always cacheable.
Also, the
TemplateMode1.html
template mode will be used by default.- Since:
- 3.0.0
- Author:
- Daniel Fernández
-
-
Field Summary
Fields Modifier and Type Field Description static TemplateMode
DEFAULT_TEMPLATE_MODE
Default template mode:TemplateMode1.html
-
Fields inherited from class org.thymeleaf.templateresolver.AbstractTemplateResolver
DEFAULT_EXISTENCE_CHECK, DEFAULT_USE_DECOUPLED_LOGIC
-
-
Constructor Summary
Constructors Constructor Description DefaultTemplateResolver()
Creates a new instance of this template resolver.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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.String
getTemplate()
Returns the text that will always be returned by this template resolver as the resolved template.TemplateMode
getTemplateMode()
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.void
setTemplateMode(String templateMode)
Sets the template mode to be applied to templates resolved by this resolver.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 Detail
-
DEFAULT_TEMPLATE_MODE
public static final TemplateMode DEFAULT_TEMPLATE_MODE
Default template mode:
TemplateMode1.html
-
-
Method Detail
-
getTemplateMode
public final TemplateMode getTemplateMode()
Returns the template mode to be applied to templates resolved by this template resolver.
- Returns:
- the template mode to be used.
-
setTemplateMode
public final void setTemplateMode(TemplateMode templateMode)
Sets the template mode to be applied to templates resolved by this resolver.
- Parameters:
templateMode
- the template mode.
-
setTemplateMode
public final void setTemplateMode(String templateMode)
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
public String 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
public void setTemplate(String template)
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
-
-