Class AbstractConfigurableTemplateResolver
- Object
-
- org.thymeleaf.templateresolver.AbstractTemplateResolver
-
- org.thymeleaf.templateresolver.AbstractConfigurableTemplateResolver
-
- All Implemented Interfaces:
ITemplateResolver
- Direct Known Subclasses:
ClassLoaderTemplateResolver
,FileTemplateResolver
,ServletContextTemplateResolver
,UrlTemplateResolver
public abstract class AbstractConfigurableTemplateResolver extends AbstractTemplateResolver
Abstract implementation of
ITemplateResolver
extendingAbstractTemplateResolver
and providing a large set of methods for configuring resource name (from template name), template mode, cache validity and character encoding.Unless overriden, this class will always apply the following validity to template resolutions:
- If not cacheable:
NonCacheableCacheEntryValidity
. - If cacheable and TTL not set:
AlwaysValidCacheEntryValidity
. - If cacheable and TTL set:
TTLCacheEntryValidity
.
- Since:
- 3.0.0
- Author:
- Daniel Fernández
-
-
Field Summary
Fields Modifier and Type Field Description static Long
DEFAULT_CACHE_TTL_MS
Default value for the cache TTL: null.static boolean
DEFAULT_CACHEABLE
Default value for the cacheable flag: true.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 AbstractConfigurableTemplateResolver()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addTemplateAlias(String alias, String templateName)
Adds a new template alias to the currently configured ones.void
clearTemplateAliases()
Removes all currently configured template aliases.protected String
computeResourceName(IEngineConfiguration configuration, String ownerTemplate, String template, String prefix, String suffix, boolean forceSuffix, Map<String,String> templateAliases, Map<String,Object> templateResolutionAttributes)
Computes the resource name that will be used for resolving, from the template name and other parameters configured at this configurable resolver.protected String
computeResourceName(IEngineConfiguration configuration, String ownerTemplate, String template, String prefix, String suffix, Map<String,String> templateAliases, Map<String,Object> templateResolutionAttributes)
Deprecated.in 3.0.6.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 abstract ITemplateResource
computeTemplateResource(IEngineConfiguration configuration, String ownerTemplate, String template, String resourceName, String characterEncoding, Map<String,Object> templateResolutionAttributes)
Compute the real resource, once the resource name has been computed using prefix, suffix, and other configured artifacts.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.Set<String>
getCacheablePatterns()
Returns the patterns (as String) specified for establishing which templates have to be considered cacheable.PatternSpec
getCacheablePatternSpec()
Returns the pattern spec specified for establishing which templates have to be considered cacheable.Long
getCacheTTLMs()
Returns the TTL (Time To Live) in cache of templates resolved by this resolver.String
getCharacterEncoding()
Returns the character encoding to be used for reading template resources resolved by this template resolver.Set<String>
getCSSTemplateModePatterns()
Returns the patterns specified for establishing theTemplateMode.CSS
template mode to resolved templates.PatternSpec
getCSSTemplateModePatternSpec()
Returns the pattern spec specified for establishing theTemplateMode.CSS
template mode to resolved templates.boolean
getForceSuffix()
Returns whether the application of the suffix should be forced on the template name.boolean
getForceTemplateMode()
Returns whether the configured template mode should be forced instead of attempting a smart template mode resolution based on template resource name.Set<String>
getHtml5TemplateModePatterns()
Deprecated.Deprecated in 3.0.0.PatternSpec
getHtml5TemplateModePatternSpec()
Deprecated.Deprecated in 3.0.0.Set<String>
getHtmlTemplateModePatterns()
Returns the patterns specified for establishing theTemplateMode1.html
template mode to resolved templates.PatternSpec
getHtmlTemplateModePatternSpec()
Returns the pattern spec specified for establishing theTemplateMode1.html
template mode to resolved templates.Set<String>
getJavaScriptTemplateModePatterns()
Returns the patterns specified for establishing theTemplateMode.JAVASCRIPT
template mode to resolved templates.PatternSpec
getJavaScriptTemplateModePatternSpec()
Returns the pattern spec specified for establishing theTemplateMode.JAVASCRIPT
template mode to resolved templates.Set<String>
getLegacyHtml5TemplateModePatterns()
Deprecated.Deprecated in 3.0.0.PatternSpec
getLegacyHtml5TemplateModePatternSpec()
Deprecated.Deprecated in 3.0.0.Set<String>
getNonCacheablePatterns()
Returns the patterns (as String) specified for establishing which templates have to be considered non cacheable.PatternSpec
getNonCacheablePatternSpec()
Returns the pattern spec specified for establishing which templates have to be considered non cacheable.String
getPrefix()
Returns the (optional) prefix to be added to all template names in order to convert template names into resource names.Set<String>
getRawTemplateModePatterns()
Returns the patterns specified for establishing theTemplateMode.RAW
template mode to resolved templates.PatternSpec
getRawTemplateModePatternSpec()
Returns the pattern spec specified for establishing theTemplateMode.RAW
template mode to resolved templates.String
getSuffix()
Returns the (optional) suffix to be added to all template names in order to convert template names into resource names.Map<String,String>
getTemplateAliases()
Returns the currently configured template aliases.TemplateMode
getTemplateMode()
Returns the template mode to be applied to templates resolved by this template resolver.Set<String>
getTextTemplateModePatterns()
Returns the patterns specified for establishing theTemplateMode.TEXT
template mode to resolved templates.PatternSpec
getTextTemplateModePatternSpec()
Returns the pattern spec specified for establishing theTemplateMode.TEXT
template mode to resolved templates.Set<String>
getValidXhtmlTemplateModePatterns()
Deprecated.Deprecated in 3.0.0.PatternSpec
getValidXhtmlTemplateModePatternSpec()
Deprecated.Deprecated in 3.0.0.Set<String>
getValidXmlTemplateModePatterns()
Deprecated.Deprecated in 3.0.0.PatternSpec
getValidXmlTemplateModePatternSpec()
Deprecated.Deprecated in 3.0.0.Set<String>
getXhtmlTemplateModePatterns()
Deprecated.Deprecated in 3.0.0.PatternSpec
getXhtmlTemplateModePatternSpec()
Deprecated.Deprecated in 3.0.0.Set<String>
getXmlTemplateModePatterns()
Returns the patterns specified for establishing theTemplateMode.XML
template mode to resolved templates.PatternSpec
getXmlTemplateModePatternSpec()
Returns the pattern spec specified for establishing theTemplateMode.XML
template mode to resolved templates.boolean
isCacheable()
Returns whether templates resolved by this resolver have to be considered cacheable or not.void
setCacheable(boolean cacheable)
Sets a new value for the cacheable flag.void
setCacheablePatterns(Set<String> cacheablePatterns)
Sets the new patterns to be applied for establishing which templates have to be considered cacheablevoid
setCacheTTLMs(Long cacheTTLMs)
Sets a new value for the cache TTL for resolved templates.void
setCharacterEncoding(String characterEncoding)
Sets a new character encoding for reading template resources.void
setCSSTemplateModePatterns(Set<String> newCSSTemplateModePatterns)
Sets the new patterns to be applied for establishing theTemplateMode.CSS
template mode as Strings.void
setForceSuffix(boolean forceSuffix)
Sets whether the application of the suffix should be forced on the template name.void
setForceTemplateMode(boolean forceTemplateMode)
Sets whether the configured template mode should be forced instead of attempting a smart template mode resolution based on template resource name.void
setHtml5TemplateModePatterns(Set<String> newHtml5TemplateModePatterns)
Deprecated.Deprecated in 3.0.0.void
setHtmlTemplateModePatterns(Set<String> newHtmlTemplateModePatterns)
Sets the new patterns to be applied for establishing theTemplateMode1.html
template mode as Strings.void
setJavaScriptTemplateModePatterns(Set<String> newJavaScriptTemplateModePatterns)
Sets the new patterns to be applied for establishing theTemplateMode.JAVASCRIPT
template mode as Strings.void
setLegacyHtml5TemplateModePatterns(Set<String> newLegacyHtml5TemplateModePatterns)
Deprecated.Deprecated in 3.0.0.void
setNonCacheablePatterns(Set<String> nonCacheablePatterns)
Sets the new patterns to be applied for establishing which templates have to be considered non cacheablevoid
setPrefix(String prefix)
Sets a new (optional) prefix to be added to all template names in order to convert template names into resource names.void
setRawTemplateModePatterns(Set<String> newRawTemplateModePatterns)
Sets the new patterns to be applied for establishing theTemplateMode.RAW
template mode as Strings.void
setSuffix(String suffix)
Sets a new (optional) suffix to be added to all template names in order to convert template names into resource names.void
setTemplateAliases(Map<String,String> templateAliases)
Sets all the new template aliases to be used.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.void
setTextTemplateModePatterns(Set<String> newTextTemplateModePatterns)
Sets the new patterns to be applied for establishing theTemplateMode.TEXT
template mode as Strings.void
setValidXhtmlTemplateModePatterns(Set<String> newValidXhtmlTemplateModePatterns)
Deprecated.Deprecated in 3.0.0.void
setValidXmlTemplateModePatterns(Set<String> newValidXmlTemplateModePatterns)
Deprecated.Deprecated in 3.0.0.void
setXhtmlTemplateModePatterns(Set<String> newXhtmlTemplateModePatterns)
Deprecated.Deprecated in 3.0.0.void
setXmlTemplateModePatterns(Set<String> newXmlTemplateModePatterns)
Sets the new patterns to be applied for establishing theTemplateMode.XML
template mode as Strings.-
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
-
DEFAULT_CACHEABLE
public static final boolean DEFAULT_CACHEABLE
Default value for the cacheable flag: true.
- See Also:
- Constant Field Values
-
DEFAULT_CACHE_TTL_MS
public static final Long DEFAULT_CACHE_TTL_MS
Default value for the cache TTL: null. This means the parsed template will live in cache until removed by LRU (because of being the oldest entry).
-
-
Method Detail
-
getPrefix
public final String getPrefix()
Returns the (optional) prefix to be added to all template names in order to convert template names into resource names.
- Returns:
- the prefix.
-
setPrefix
public final void setPrefix(String prefix)
Sets a new (optional) prefix to be added to all template names in order to convert template names into resource names.
- Parameters:
prefix
- the prefix to be set.
-
getSuffix
public final String getSuffix()
Returns the (optional) suffix to be added to all template names in order to convert template names into resource names.
Note that this suffix may not be applied to the template name if the template name already ends in a known file name suffix:
.html
,.htm
,.xhtml
,.xml
,.js
,.json
,.css
,.rss
,.atom
,.txt
. If this behaviour needs to be overridden so that suffix is always applied, thesetForceSuffix(boolean)
will need to be set.- Returns:
- the suffix.
-
setSuffix
public final void setSuffix(String suffix)
Sets a new (optional) suffix to be added to all template names in order to convert template names into resource names.
Note that this suffix may not be applied to the template name if the template name already ends in a known file name suffix:
.html
,.htm
,.xhtml
,.xml
,.js
,.json
,.css
,.rss
,.atom
,.txt
. If this behaviour needs to be overridden so that suffix is always applied, thesetForceSuffix(boolean)
will need to be set.- Parameters:
suffix
- the suffix to be set.
-
getForceSuffix
public final boolean getForceSuffix()
Returns whether the application of the suffix should be forced on the template name.
When forced, suffix will be appended to the template name even if the template name ends in a known suffix:
.html
,.htm
,.xhtml
,.xml
,.js
,.json
,.css
,.rss
,.atom
,.txt
.Default value is
.false
- Returns:
- whether the suffix will be forced or not.
- Since:
- 3.0.6
-
setForceSuffix
public final void setForceSuffix(boolean forceSuffix)
Sets whether the application of the suffix should be forced on the template name.
When forced, suffix will be appended to the template name even if the template name ends in a known suffix:
.html
,.htm
,.xhtml
,.xml
,.js
,.json
,.css
,.rss
,.atom
,.txt
.Default value is
.false
- Parameters:
forceSuffix
- whether the suffix should be forced or not.- Since:
- 3.0.6
-
getCharacterEncoding
public final String getCharacterEncoding()
Returns the character encoding to be used for reading template resources resolved by this template resolver.
- Returns:
- the character encoding.
-
setCharacterEncoding
public final void setCharacterEncoding(String characterEncoding)
Sets a new character encoding for reading template resources.
- Parameters:
characterEncoding
- the character encoding to be used.
-
getTemplateMode
public final TemplateMode getTemplateMode()
Returns the template mode to be applied to templates resolved by this template resolver.
If template mode patterns (see
setXhtmlTemplateModePatterns(Set)
,setHtml5TemplateModePatterns(Set)
, etc.) are also set, they have higher priority than the template mode set here (this would act as a default).Note that this template mode also may not be applied if the template resource name ends in a known file name suffix:
.html
,.htm
,.xhtml
,.xml
,.js
,.json
,.css
,.rss
,.atom
,.txt
. If this behaviour needs to be overridden so that template name is always applied, thesetForceTemplateMode(boolean)
will need to be set.- 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.
If template mode patterns (see
setXhtmlTemplateModePatterns(Set)
,setHtml5TemplateModePatterns(Set)
, etc.) are also set, they have higher priority than the template mode set here (this would act as a default).Note that this template mode also may not be applied if the template resource name ends in a known file name suffix:
.html
,.htm
,.xhtml
,.xml
,.js
,.json
,.css
,.rss
,.atom
,.txt
. If this behaviour needs to be overridden so that template name is always applied, thesetForceTemplateMode(boolean)
will need to be set.- 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.If template mode patterns (see
setXhtmlTemplateModePatterns(Set)
,setHtml5TemplateModePatterns(Set)
, etc.) are also set, they have higher priority than the template mode set here (this would act as a default).Note that this template mode also may not be applied if the template resource name ends in a known file name suffix:
.html
,.htm
,.xhtml
,.xml
,.js
,.json
,.css
,.rss
,.atom
,.txt
. If this behaviour needs to be overridden so that template name is always applied, thesetForceTemplateMode(boolean)
will need to be set.- Parameters:
templateMode
- the template mode.
-
getForceTemplateMode
public final boolean getForceTemplateMode()
Returns whether the configured template mode should be forced instead of attempting a smart template mode resolution based on template resource name.
When forced, the configured template mode (
setTemplateMode(TemplateMode)
will be applied even if the template resource name ends in a known suffix:.html
,.htm
,.xhtml
,.xml
,.js
,.json
,.css
,.rss
,.atom
,.txt
.Default value is
.false
- Returns:
- whether the suffix will be forced or not.
- Since:
- 3.0.6
-
setForceTemplateMode
public final void setForceTemplateMode(boolean forceTemplateMode)
Sets whether the configured template mode should be forced instead of attempting a smart template mode resolution based on template resource name.
When forced, the configured template mode (
setTemplateMode(TemplateMode)
will be applied even if the template resource name ends in a known suffix:.html
,.htm
,.xhtml
,.xml
,.js
,.json
,.css
,.rss
,.atom
,.txt
.Default value is
.false
- Parameters:
forceTemplateMode
- whether the configured template mode should be forced or not.- Since:
- 3.0.6
-
isCacheable
public final boolean isCacheable()
Returns whether templates resolved by this resolver have to be considered cacheable or not.
If cacheable patterns (see
setCacheablePatterns(Set)
) are also set, they have higher priority than the value set here (this would act as a default).- Returns:
- whether templates resolved are cacheable or not.
-
setCacheable
public final void setCacheable(boolean cacheable)
Sets a new value for the cacheable flag.
If cacheable patterns (see
setCacheablePatterns(Set)
) are also set, they have higher priority than the value set here (this would act as a default).- Parameters:
cacheable
- whether resolved patterns should be considered cacheable or not.
-
getCacheTTLMs
public final Long getCacheTTLMs()
Returns the TTL (Time To Live) in cache of templates resolved by this resolver.
If a template is resolved as cacheable but cache TTL is null, this means the template will live in cache until evicted by LRU (Least Recently Used) algorithm for being the oldest entry in cache.
- Returns:
- the cache TTL for resolved templates.
-
setCacheTTLMs
public final void setCacheTTLMs(Long cacheTTLMs)
Sets a new value for the cache TTL for resolved templates.
If a template is resolved as cacheable but cache TTL is null, this means the template will live in cache until evicted by LRU (Least Recently Used) algorithm for being the oldest entry in cache.
- Parameters:
cacheTTLMs
- the new cache TTL, or null for using natural LRU eviction.
-
getTemplateAliases
public final Map<String,String> getTemplateAliases()
Returns the currently configured template aliases.
Template aliases allow the use of several (and probably shorter) names for templates.
Aliases are applied to template names before prefix/suffix.
- Returns:
- the map of template aliases.
-
setTemplateAliases
public final void setTemplateAliases(Map<String,String> templateAliases)
Sets all the new template aliases to be used.
Template aliases allow the use of several (and probably shorter) names for templates.
Aliases are applied to template names before prefix/suffix.
- Parameters:
templateAliases
- the new template aliases.
-
addTemplateAlias
public final void addTemplateAlias(String alias, String templateName)
Adds a new template alias to the currently configured ones.
- Parameters:
alias
- the new alias nametemplateName
- the name of the template the alias will be applied to
-
clearTemplateAliases
public final void clearTemplateAliases()
Removes all currently configured template aliases.
-
getXmlTemplateModePatternSpec
public final PatternSpec getXmlTemplateModePatternSpec()
Returns the pattern spec specified for establishing the
TemplateMode.XML
template mode to resolved templates.- Returns:
- the pattern spec
-
getXmlTemplateModePatterns
public final Set<String> getXmlTemplateModePatterns()
Returns the patterns specified for establishing the
TemplateMode.XML
template mode to resolved templates.This is a convenience method equivalent to
getXmlTemplateModePatternSpec()
.getPatterns()- Returns:
- the pattern spec
-
setXmlTemplateModePatterns
public final void setXmlTemplateModePatterns(Set<String> newXmlTemplateModePatterns)
Sets the new patterns to be applied for establishing the
TemplateMode.XML
template mode as Strings.This is a convenience method equivalent to
getXmlTemplateModePatternSpec()
.setPatterns(Set<String>)- Parameters:
newXmlTemplateModePatterns
- the new patterns
-
getHtmlTemplateModePatternSpec
public final PatternSpec getHtmlTemplateModePatternSpec()
Returns the pattern spec specified for establishing the
TemplateMode1.html
template mode to resolved templates.- Returns:
- the pattern spec
- Since:
- 3.0.0
-
getHtmlTemplateModePatterns
public final Set<String> getHtmlTemplateModePatterns()
Returns the patterns specified for establishing the
TemplateMode1.html
template mode to resolved templates.This is a convenience method equivalent to
getHtmlTemplateModePatternSpec()
.getPatterns()- Returns:
- the pattern spec
- Since:
- 3.0.0
-
setHtmlTemplateModePatterns
public final void setHtmlTemplateModePatterns(Set<String> newHtmlTemplateModePatterns)
Sets the new patterns to be applied for establishing the
TemplateMode1.html
template mode as Strings.This is a convenience method equivalent to
getHtmlTemplateModePatternSpec()
.setPatterns(Set<String>)- Parameters:
newHtmlTemplateModePatterns
- the new patterns- Since:
- 3.0.0
-
getJavaScriptTemplateModePatternSpec
public final PatternSpec getJavaScriptTemplateModePatternSpec()
Returns the pattern spec specified for establishing the
TemplateMode.JAVASCRIPT
template mode to resolved templates.- Returns:
- the pattern spec
- Since:
- 3.0.0
-
getJavaScriptTemplateModePatterns
public final Set<String> getJavaScriptTemplateModePatterns()
Returns the patterns specified for establishing the
TemplateMode.JAVASCRIPT
template mode to resolved templates.This is a convenience method equivalent to
getJavaScriptTemplateModePatternSpec()
.getPatterns()- Returns:
- the pattern spec
- Since:
- 3.0.0
-
setJavaScriptTemplateModePatterns
public final void setJavaScriptTemplateModePatterns(Set<String> newJavaScriptTemplateModePatterns)
Sets the new patterns to be applied for establishing the
TemplateMode.JAVASCRIPT
template mode as Strings.This is a convenience method equivalent to
getJavaScriptTemplateModePatternSpec()
.setPatterns(Set<String>)- Parameters:
newJavaScriptTemplateModePatterns
- the new patterns- Since:
- 3.0.0
-
getCSSTemplateModePatternSpec
public final PatternSpec getCSSTemplateModePatternSpec()
Returns the pattern spec specified for establishing the
TemplateMode.CSS
template mode to resolved templates.- Returns:
- the pattern spec
- Since:
- 3.0.0
-
getCSSTemplateModePatterns
public final Set<String> getCSSTemplateModePatterns()
Returns the patterns specified for establishing the
TemplateMode.CSS
template mode to resolved templates.This is a convenience method equivalent to
getCSSTemplateModePatternSpec()
.getPatterns()- Returns:
- the pattern spec
- Since:
- 3.0.0
-
setCSSTemplateModePatterns
public final void setCSSTemplateModePatterns(Set<String> newCSSTemplateModePatterns)
Sets the new patterns to be applied for establishing the
TemplateMode.CSS
template mode as Strings.This is a convenience method equivalent to
getCSSTemplateModePatternSpec()
.setPatterns(Set<String>)- Parameters:
newCSSTemplateModePatterns
- the new patterns- Since:
- 3.0.0
-
getRawTemplateModePatternSpec
public final PatternSpec getRawTemplateModePatternSpec()
Returns the pattern spec specified for establishing the
TemplateMode.RAW
template mode to resolved templates.- Returns:
- the pattern spec
- Since:
- 3.0.0
-
getRawTemplateModePatterns
public final Set<String> getRawTemplateModePatterns()
Returns the patterns specified for establishing the
TemplateMode.RAW
template mode to resolved templates.This is a convenience method equivalent to
getRawTemplateModePatternSpec()
.getPatterns()- Returns:
- the pattern spec
- Since:
- 3.0.0
-
setRawTemplateModePatterns
public final void setRawTemplateModePatterns(Set<String> newRawTemplateModePatterns)
Sets the new patterns to be applied for establishing the
TemplateMode.RAW
template mode as Strings.This is a convenience method equivalent to
getRawTemplateModePatternSpec()
.setPatterns(Set<String>)- Parameters:
newRawTemplateModePatterns
- the new patterns- Since:
- 3.0.0
-
getTextTemplateModePatternSpec
public final PatternSpec getTextTemplateModePatternSpec()
Returns the pattern spec specified for establishing the
TemplateMode.TEXT
template mode to resolved templates.- Returns:
- the pattern spec
- Since:
- 3.0.0
-
getTextTemplateModePatterns
public final Set<String> getTextTemplateModePatterns()
Returns the patterns specified for establishing the
TemplateMode.TEXT
template mode to resolved templates.This is a convenience method equivalent to
getTextTemplateModePatternSpec()
.getPatterns()- Returns:
- the pattern spec
- Since:
- 3.0.0
-
setTextTemplateModePatterns
public final void setTextTemplateModePatterns(Set<String> newTextTemplateModePatterns)
Sets the new patterns to be applied for establishing the
TemplateMode.TEXT
template mode as Strings.This is a convenience method equivalent to
getTextTemplateModePatternSpec()
.setPatterns(Set<String>)- Parameters:
newTextTemplateModePatterns
- the new patterns- Since:
- 3.0.0
-
getValidXmlTemplateModePatternSpec
@Deprecated public final PatternSpec getValidXmlTemplateModePatternSpec()
Deprecated.Deprecated in 3.0.0. Use the methods for theTemplateMode.XML
template mode instead. Will be removed in 3.1Returns the pattern spec specified for establishing the deprecated VALIDXML (validated XML) template mode to resolved templates. Note that, due to the deprecation of this template mode, these patterns will be applied to the
TemplateMode.XML
template mode instead.- Returns:
- the pattern spec
-
getValidXmlTemplateModePatterns
@Deprecated public final Set<String> getValidXmlTemplateModePatterns()
Deprecated.Deprecated in 3.0.0. Use the methods for theTemplateMode.XML
template mode instead. Will be removed in 3.1Returns the patterns specified for establishing the deprecated VALIDXML (validated XML) template mode to resolved templates. Note that, due to the deprecation of this template mode, these patterns will be applied to the
TemplateMode.XML
template mode instead.This is a convenience method equivalent to
getValidXmlTemplateModePatternSpec()
.getPatterns()- Returns:
- the pattern spec
-
setValidXmlTemplateModePatterns
@Deprecated public final void setValidXmlTemplateModePatterns(Set<String> newValidXmlTemplateModePatterns)
Deprecated.Deprecated in 3.0.0. Use the methods for theTemplateMode.XML
template mode instead. Will be removed in 3.1Sets the new patterns to be applied for establishing the deprecated VALIDXML (validated XML) template mode as Strings. Note that, due to the deprecation of this template mode, these patterns will be applied to the
TemplateMode.XML
template mode instead.This is a convenience method equivalent to
getValidXmlTemplateModePatternSpec()
.setPatterns(Set<String>)- Parameters:
newValidXmlTemplateModePatterns
- the new patterns
-
getXhtmlTemplateModePatternSpec
@Deprecated public final PatternSpec getXhtmlTemplateModePatternSpec()
Deprecated.Deprecated in 3.0.0. Use the methods for theTemplateMode.XML
template mode instead. Will be removed in 3.1Returns the pattern spec specified for establishing the deprecated XHTML template mode to resolved templates. Note that, due to the deprecation of this template mode, these patterns will be applied to the
TemplateMode1.html
template mode instead.- Returns:
- the pattern spec
-
getXhtmlTemplateModePatterns
@Deprecated public final Set<String> getXhtmlTemplateModePatterns()
Deprecated.Deprecated in 3.0.0. Use the methods for theTemplateMode.XML
template mode instead. Will be removed in 3.1Returns the patterns specified for establishing the deprecated XHTML template mode to resolved templates. Note that, due to the deprecation of this template mode, these patterns will be applied to the
TemplateMode1.html
template mode instead.This is a convenience method equivalent to
getXhtmlTemplateModePatternSpec()
.getPatterns()- Returns:
- the pattern spec
-
setXhtmlTemplateModePatterns
@Deprecated public final void setXhtmlTemplateModePatterns(Set<String> newXhtmlTemplateModePatterns)
Deprecated.Deprecated in 3.0.0. Use the methods for theTemplateMode.XML
template mode instead. Will be removed in 3.1Sets the new patterns to be applied for establishing the deprecated XHTML template mode as Strings. Note that, due to the deprecation of this template mode, these patterns will be applied to the
TemplateMode1.html
template mode instead.This is a convenience method equivalent to
getXhtmlTemplateModePatternSpec()
.setPatterns(Set<String>)- Parameters:
newXhtmlTemplateModePatterns
- the new patterns
-
getValidXhtmlTemplateModePatternSpec
@Deprecated public final PatternSpec getValidXhtmlTemplateModePatternSpec()
Deprecated.Deprecated in 3.0.0. Use the methods for theTemplateMode.XML
template mode instead. Will be removed in 3.1Returns the pattern spec specified for establishing the deprecated VALIDXHTML (validated XHTML) template mode to resolved templates. Note that, due to the deprecation of this template mode, these patterns will be applied to the
TemplateMode1.html
template mode instead.- Returns:
- the pattern spec
-
getValidXhtmlTemplateModePatterns
@Deprecated public final Set<String> getValidXhtmlTemplateModePatterns()
Deprecated.Deprecated in 3.0.0. Use the methods for theTemplateMode.XML
template mode instead. Will be removed in 3.1Returns the patterns specified for establishing the deprecated VALIDXHTML (validated XHTML) template mode to resolved templates. Note that, due to the deprecation of this template mode, these patterns will be applied to the
TemplateMode1.html
template mode instead.This is a convenience method equivalent to
getValidXhtmlTemplateModePatternSpec()
.getPatterns()- Returns:
- the pattern spec
-
setValidXhtmlTemplateModePatterns
@Deprecated public final void setValidXhtmlTemplateModePatterns(Set<String> newValidXhtmlTemplateModePatterns)
Deprecated.Deprecated in 3.0.0. Use the methods for theTemplateMode.XML
template mode instead. Will be removed in 3.1Sets the new patterns to be applied for establishing the deprecated VALIDXHTML (validated XHTML) template mode as Strings. Note that, due to the deprecation of this template mode, these patterns will be applied to the
TemplateMode1.html
template mode instead.This is a convenience method equivalent to
getValidXhtmlTemplateModePatternSpec()
.setPatterns(Set<String>)- Parameters:
newValidXhtmlTemplateModePatterns
- the new patterns
-
getLegacyHtml5TemplateModePatternSpec
@Deprecated public final PatternSpec getLegacyHtml5TemplateModePatternSpec()
Deprecated.Deprecated in 3.0.0. Use the methods for theTemplateMode.XML
template mode instead. Will be removed in 3.1Returns the pattern spec specified for establishing the deprecated LEGACYHTML5 (non-XML-formed HTML5 that needs HTML-to-XML conversion) template mode to resolved templates. Note that, due to the deprecation of this template mode, these patterns will be applied to the
TemplateMode1.html
template mode instead.- Returns:
- the pattern spec
-
getLegacyHtml5TemplateModePatterns
@Deprecated public final Set<String> getLegacyHtml5TemplateModePatterns()
Deprecated.Deprecated in 3.0.0. Use the methods for theTemplateMode.XML
template mode instead. Will be removed in 3.1Returns the patterns specified for establishing the deprecated LEGACYHTML5 (non-XML-formed HTML5 that needs HTML-to-XML conversion) template mode to resolved templates. Note that, due to the deprecation of this template mode, these patterns will be applied to the
TemplateMode1.html
template mode instead.This is a convenience method equivalent to
getLegacyHtml5TemplateModePatternSpec()
.getPatterns()- Returns:
- the pattern spec
-
setLegacyHtml5TemplateModePatterns
@Deprecated public final void setLegacyHtml5TemplateModePatterns(Set<String> newLegacyHtml5TemplateModePatterns)
Deprecated.Deprecated in 3.0.0. Use the methods for theTemplateMode.XML
template mode instead. Will be removed in 3.1Sets the new patterns to be applied for establishing the deprecated LEGACYHTML5 (non-XML-formed HTML5 that needs HTML-to-XML conversion) template mode as Strings. Note that, due to the deprecation of this template mode, these patterns will be applied to the
TemplateMode1.html
template mode instead.This is a convenience method equivalent to
getLegacyHtml5TemplateModePatternSpec()
.setPatterns(Set<String>)- Parameters:
newLegacyHtml5TemplateModePatterns
- the new patterns
-
getHtml5TemplateModePatternSpec
@Deprecated public final PatternSpec getHtml5TemplateModePatternSpec()
Deprecated.Deprecated in 3.0.0. Use the methods for theTemplateMode.XML
template mode instead. Will be removed in 3.1Returns the pattern spec specified for establishing the deprecated HTML5 (correct, XML-formed HTML5) template mode to resolved templates. Note that, due to the deprecation of this template mode, these patterns will be applied to the
TemplateMode1.html
template mode instead.- Returns:
- the pattern spec
-
getHtml5TemplateModePatterns
@Deprecated public final Set<String> getHtml5TemplateModePatterns()
Deprecated.Deprecated in 3.0.0. Use the methods for theTemplateMode.XML
template mode instead. Will be removed in 3.1Returns the patterns specified for establishing the deprecated HTML5 (correct, XML-formed HTML5) template mode to resolved templates. Note that, due to the deprecation of this template mode, these patterns will be applied to the
TemplateMode1.html
template mode instead.This is a convenience method equivalent to
getHtml5TemplateModePatternSpec()
.getPatterns()- Returns:
- the pattern spec
-
setHtml5TemplateModePatterns
@Deprecated public final void setHtml5TemplateModePatterns(Set<String> newHtml5TemplateModePatterns)
Deprecated.Deprecated in 3.0.0. Use the methods for theTemplateMode.XML
template mode instead. Will be removed in 3.1Sets the new patterns to be applied for establishing the deprecated HTML5 (correct, XML-formed HTML5) template mode as Strings. Note that, due to the deprecation of this template mode, these patterns will be applied to the
TemplateMode1.html
template mode instead.This is a convenience method equivalent to
getHtml5TemplateModePatternSpec()
.setPatterns(Set<String>)- Parameters:
newHtml5TemplateModePatterns
- the new patterns
-
getCacheablePatternSpec
public final PatternSpec getCacheablePatternSpec()
Returns the pattern spec specified for establishing which templates have to be considered cacheable.
These patterns have higher precedence than the cacheable flag (see
setCacheable(boolean)
). Such flag can be considered a default value after cacheable patterns and non-cacheable patterns have been applied.- Returns:
- the pattern spec
-
getCacheablePatterns
public final Set<String> getCacheablePatterns()
Returns the patterns (as String) specified for establishing which templates have to be considered cacheable.
These patterns have higher precedence than the cacheable flag (see
setCacheable(boolean)
). Such flag can be considered a default value after cacheable patterns and non-cacheable patterns have been applied.This is a convenience method equivalent to
getCacheablePatternSpec()
.getPatterns()- Returns:
- the patterns
-
setCacheablePatterns
public final void setCacheablePatterns(Set<String> cacheablePatterns)
Sets the new patterns to be applied for establishing which templates have to be considered cacheable
These patterns have higher precedence than the cacheable flag (see
setCacheable(boolean)
). Such flag can be considered a default value after cacheable patterns and non-cacheable patterns have been applied.This is a convenience method equivalent to
getCacheablePatternSpec()
.setPatterns(Set<String>)- Parameters:
cacheablePatterns
- the new patterns
-
getNonCacheablePatternSpec
public final PatternSpec getNonCacheablePatternSpec()
Returns the pattern spec specified for establishing which templates have to be considered non cacheable.
These patterns have higher precedence than the cacheable flag (see
setCacheable(boolean)
). Such flag can be considered a default value after cacheable patterns and non-cacheable patterns have been applied.- Returns:
- the pattern spec
-
getNonCacheablePatterns
public final Set<String> getNonCacheablePatterns()
Returns the patterns (as String) specified for establishing which templates have to be considered non cacheable.
These patterns have higher precedence than the cacheable flag (see
setCacheable(boolean)
). Such flag can be considered a default value after cacheable patterns and non-cacheable patterns have been applied.This is a convenience method equivalent to
getNonCacheablePatternSpec()
.getPatterns()- Returns:
- the patterns
-
setNonCacheablePatterns
public final void setNonCacheablePatterns(Set<String> nonCacheablePatterns)
Sets the new patterns to be applied for establishing which templates have to be considered non cacheable
These patterns have higher precedence than the cacheable flag (see
setCacheable(boolean)
). Such flag can be considered a default value after cacheable patterns and non-cacheable patterns have been applied.This is a convenience method equivalent to
getNonCacheablePatternSpec()
.setPatterns(Set<String>)- Parameters:
nonCacheablePatterns
- the new patterns
-
computeResourceName
@Deprecated protected String computeResourceName(IEngineConfiguration configuration, String ownerTemplate, String template, String prefix, String suffix, Map<String,String> templateAliases, Map<String,Object> templateResolutionAttributes)
Deprecated.in 3.0.6. UsecomputeResourceName(IEngineConfiguration, String, String, String, String, boolean, Map, Map)
instead. Will be removed in Thymeleaf 3.2.Computes the resource name that will be used for resolving, from the template name and other parameters configured at this configurable resolver.
This method can be overridden by subclasses that need to modify the standard way in which the name of the template resource is computed by default before passing it to the real resource resolution mechanism (in method
computeTemplateResource(IEngineConfiguration, String, String, String, String, Map)
By default, the resource name will be created by first applying the template aliases, and then adding prefix and suffix to the specified template (template name).
- Parameters:
configuration
- the engine configuration in use.ownerTemplate
- the owner template, if the resource being computed is a fragment. Might be null.template
- the template (normally the template name, except for String templates).prefix
- the prefix to be applied.suffix
- the suffix to be applied.templateAliases
- the template aliases map.templateResolutionAttributes
- the template resolution attributes, if any. Might be null.- Returns:
- the resource name that should be used for resolving
-
computeResourceName
protected String computeResourceName(IEngineConfiguration configuration, String ownerTemplate, String template, String prefix, String suffix, boolean forceSuffix, Map<String,String> templateAliases, Map<String,Object> templateResolutionAttributes)
Computes the resource name that will be used for resolving, from the template name and other parameters configured at this configurable resolver.
This method can be overridden by subclasses that need to modify the standard way in which the name of the template resource is computed by default before passing it to the real resource resolution mechanism (in method
computeTemplateResource(IEngineConfiguration, String, String, String, String, Map)
By default, the resource name will be created by first applying the template aliases, and then adding prefix and suffix to the specified template (template name).
- Parameters:
configuration
- the engine configuration in use.ownerTemplate
- the owner template, if the resource being computed is a fragment. Might be null.template
- the template (normally the template name, except for String templates).prefix
- the prefix to be applied.suffix
- the suffix to be applied.forceSuffix
- whether the suffix should be forced or not.templateAliases
- the template aliases map.templateResolutionAttributes
- the template resolution attributes, if any. Might be null.- Returns:
- the resource name that should be used for resolving
- Since:
- 3.0.6
-
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
-
computeTemplateResource
protected final 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).
-
computeTemplateResource
protected abstract ITemplateResource computeTemplateResource(IEngineConfiguration configuration, String ownerTemplate, String template, String resourceName, String characterEncoding, Map<String,Object> templateResolutionAttributes)
Compute the real resource, once the resource name has been computed using prefix, suffix, and other configured artifacts.
- Parameters:
configuration
- the engine configuration in use.ownerTemplate
- the owner template, if the resource being computed is a fragment. Might be null.template
- the template (normally the template name, except for String templates).resourceName
- the resource name, complete with prefix, suffix, aliases, etc.characterEncoding
- the character encoding to be used for reading the resource.templateResolutionAttributes
- the template resolution attributes, if any. Might be null.- Returns:
- the template resource
-
-