|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object org.thymeleaf.templateresolver.AbstractTemplateResolver
public abstract class AbstractTemplateResolver
Convenience base class for all Template Resolvers.
This class allows configuration of:
Constructor Summary | |
---|---|
AbstractTemplateResolver()
|
Method Summary | |
---|---|
protected void |
checkInitialized()
Check the template resolver is initialized, and throw an exception if it is not. |
protected void |
checkNotInitialized()
Check the template resolver is not initialized, and throw an exception if it is. |
protected abstract String |
computeCharacterEncoding(TemplateProcessingParameters templateProcessingParameters)
Computes the character encoding that should be applied when reading template resource, according to existing configuration. |
protected boolean |
computeResolvable(TemplateProcessingParameters templateProcessingParameters)
Computes whether a template can be resolved by this resolver or not, applying the corresponding patterns. |
protected abstract String |
computeResourceName(TemplateProcessingParameters templateProcessingParameters)
Computes the resource name from the template name, applying aliases, prefix/suffix, or any other artifacts the Template Resolver might need to apply. |
protected abstract IResourceResolver |
computeResourceResolver(TemplateProcessingParameters templateProcessingParameters)
Computes the resource resolver that should be applied to a template, according to existing configuration. |
protected abstract String |
computeTemplateMode(TemplateProcessingParameters templateProcessingParameters)
Computes the template mode that should be applied to a template, according to existing configuration. |
protected abstract ITemplateResolutionValidity |
computeValidity(TemplateProcessingParameters templateProcessingParameters)
Computes the validity to be applied to the template resolution. |
String |
getName()
Returns the name of the template resolver |
Integer |
getOrder()
Returns the order in which this template resolver will be asked to resolve templates as a part of the chain of resolvers configured into the template engine. |
java.util.Set<String> |
getResolvablePatterns()
Returns the patterns (as String) specified for establishing which templates can be resolved by this template resolver. |
PatternSpec |
getResolvablePatternSpec()
Returns the pattern spec specified for establishing which templates can be resolved by this template resolver. |
void |
initialize()
Initialize this template resolver. |
protected void |
initializeSpecific()
Initialize specific aspects of a subclass. |
protected boolean |
isInitialized()
|
TemplateResolution |
resolveTemplate(TemplateProcessingParameters templateProcessingParameters)
Tries to resolve a template. |
void |
setName(String name)
Sets a new name for the Template Resolver. |
void |
setOrder(Integer order)
Sets a new order for the template engine in the chain. |
void |
setResolvablePatterns(java.util.Set<String> resolvablePatterns)
Sets the new patterns to be applied for establishing which templates can be resolved by this template resolver. |
protected String |
unsafeGetName()
Uninitialized method meant only for use by subclasses. |
protected Integer |
unsafeGetOrder()
Unsynchronized method meant only for use by subclasses. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractTemplateResolver()
Method Detail |
---|
protected final boolean isInitialized()
public final void initialize()
Initialize this template resolver.
Once initialized the configuration parameters of this template resolvers cannot be changed.
Initialization is automatically triggered by the Template Engine before processing the first template.
initialize
in interface ITemplateResolver
protected void initializeSpecific()
Initialize specific aspects of a subclass. This method is called during initialization
of TemplateResolver (initialize()
) and is meant for being overridden by subclasses.
protected final void checkNotInitialized()
Check the template resolver is not initialized, and throw an exception if it is.
Calling this method allows to protect calls to methods that change the configuration, ensuring the template resolver has not been initialized yet.
protected final void checkInitialized()
Check the template resolver is initialized, and throw an exception if it is not.
Calling this method allows to protect calls to methods that need the template resolver to be already initialized.
public String getName()
Returns the name of the template resolver
getName
in interface ITemplateResolver
protected String unsafeGetName()
Uninitialized method meant only for use by subclasses.
public void setName(String name)
Sets a new name for the Template Resolver.
name
- the new namepublic Integer getOrder()
Returns the order in which this template resolver will be asked to resolve templates as a part of the chain of resolvers configured into the template engine.
Order should start with 1.
getOrder
in interface ITemplateResolver
protected Integer unsafeGetOrder()
Unsynchronized method meant only for use by subclasses.
public void setOrder(Integer order)
Sets a new order for the template engine in the chain. Order should start with 1.
order
- the new order.public PatternSpec getResolvablePatternSpec()
Returns the pattern spec specified for establishing which templates can be resolved by this template resolver. For those templates which names do not match this patterns, the Template Resolver will return null.
This allows for a fast discard of those templates that the developer might know for sure that will not be resolvable by the Resource Resolver used by this Template Resolver, so that an execution of the resource resolver is not needed.
public java.util.Set<String> getResolvablePatterns()
Returns the patterns (as String) specified for establishing which templates can be resolved by this template resolver. For those templates which names do not match this patterns, the Template Resolver will return null.
This allows for a fast discard of those templates that the developer might know for sure that will not be resolvable by the Resource Resolver used by this Template Resolver, so that an execution of the resource resolver is not needed.
This is a convenience method equivalent to getResolvablePatternSpec()
.getPatterns()
public void setResolvablePatterns(java.util.Set<String> resolvablePatterns)
Sets the new patterns to be applied for establishing which templates can be resolved by this template resolver. For those templates which names do not match this patterns, the Template Resolver will return null.
This allows for a fast discard of those templates that the developer might know for sure that will not be resolvable by the Resource Resolver used by this Template Resolver, so that an execution of the resource resolver is not needed.
This is a convenience method equivalent to getResolvablePatternSpec()
.setPatterns(Set
resolvablePatterns
- the new patternspublic TemplateResolution resolveTemplate(TemplateProcessingParameters templateProcessingParameters)
ITemplateResolver
Tries to resolve a template.
The templateProcessingParameters parameter contains all the info needed for trying to
resolve the template (esp. the template name). The Template Resolver
will apply its configuration (prefixes/suffixes, template mode patterns,
cache configurations, etc) and return a TemplateResolution
object.
This method can return null if the template resolver is completely certain
that a template cannot be resolved by it. But returning a result does not
mean the contrary, because it could be that the IResourceResolver
object returned in the result is not effectively able to resolve the
resource corresponding to this template. As sometimes this cannot be known in
advance (the template resource would have to be read two times
for that), it will not be until the Template Engine executes the Resource
Resolver that it will know whether the template was correctly resolved by
a Template Resolver or not.
resolveTemplate
in interface ITemplateResolver
templateProcessingParameters
- the information required to resolve a template
protected boolean computeResolvable(TemplateProcessingParameters templateProcessingParameters)
Computes whether a template can be resolved by this resolver or not, applying the corresponding patterns. Meant only for use by subclasses.
templateProcessingParameters
- the template processing parameters
protected abstract String computeResourceName(TemplateProcessingParameters templateProcessingParameters)
Computes the resource name from the template name, applying aliases, prefix/suffix, or any other artifacts the Template Resolver might need to apply.
templateProcessingParameters
- the template processing parameters
protected abstract IResourceResolver computeResourceResolver(TemplateProcessingParameters templateProcessingParameters)
Computes the resource resolver that should be applied to a template, according to existing configuration.
templateProcessingParameters
- the template processing parameters
protected abstract String computeCharacterEncoding(TemplateProcessingParameters templateProcessingParameters)
Computes the character encoding that should be applied when reading template resource, according to existing configuration.
templateProcessingParameters
- the template processing parameters
protected abstract String computeTemplateMode(TemplateProcessingParameters templateProcessingParameters)
Computes the template mode that should be applied to a template, according to existing configuration.
templateProcessingParameters
- the template processing parameters
protected abstract ITemplateResolutionValidity computeValidity(TemplateProcessingParameters templateProcessingParameters)
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.
templateProcessingParameters
- the template processing parameters
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |