public class DefaultTemplateResolver extends AbstractTemplateResolver
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.
Modifier and Type | Field and Description |
---|---|
static TemplateMode |
DEFAULT_TEMPLATE_MODE
Default template mode:
TemplateMode.HTML |
DEFAULT_EXISTENCE_CHECK, DEFAULT_USE_DECOUPLED_LOGIC
Constructor and Description |
---|
DefaultTemplateResolver()
Creates a new instance of this template resolver.
|
Modifier and Type | Method and 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.
|
computeResolvable, getCheckExistence, getName, getOrder, getResolvablePatterns, getResolvablePatternSpec, getUseDecoupledLogic, resolveTemplate, setCheckExistence, setName, setOrder, setResolvablePatterns, setUseDecoupledLogic
public static final TemplateMode DEFAULT_TEMPLATE_MODE
Default template mode: TemplateMode.HTML
public DefaultTemplateResolver()
Creates a new instance of this template resolver.
public final TemplateMode getTemplateMode()
Returns the template mode to be applied to templates resolved by this template resolver.
public final void setTemplateMode(TemplateMode templateMode)
Sets the template mode to be applied to templates resolved by this resolver.
templateMode
- the template mode.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.
templateMode
- the template mode.public String getTemplate()
Returns the text that will always be returned by this template resolver as the resolved template.
public void setTemplate(String template)
Set the text that will be returned as the resolved template.
template
- the text to be returned as template.protected ITemplateResource computeTemplateResource(IEngineConfiguration configuration, String ownerTemplate, String template, Map<String,Object> templateResolutionAttributes)
AbstractTemplateResolver
Computes the resolved template resource.
computeTemplateResource
in class AbstractTemplateResolver
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.protected TemplateMode computeTemplateMode(IEngineConfiguration configuration, String ownerTemplate, String template, Map<String,Object> templateResolutionAttributes)
AbstractTemplateResolver
Computes the template mode that should be applied to a template, according to existing configuration.
computeTemplateMode
in class AbstractTemplateResolver
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.protected ICacheEntryValidity computeValidity(IEngineConfiguration configuration, String ownerTemplate, String template, Map<String,Object> templateResolutionAttributes)
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.
computeValidity
in class AbstractTemplateResolver
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.Copyright © 2016 The THYMELEAF team. All rights reserved.