public final class TemplateData extends Object
Class containing all the data related to a template that is currently being processed.
Objects of this class are meant to be a part of the ITemplateContext
instances
offered by the engine to processing artifacts such as processors, pre-/post-processors, etc.
These objects contain some metadata about the template being processed, and also the template resource
itself, coming from the TemplateResolution
produced by template resolvers (ITemplateResolver
).
The template contained usually represents the template name, but can be the entire
template contents if the template has been resolved by a
StringTemplateResolver
or an analogous implementation of
ITemplateResolver
.
Objects of this class should not be considered thread-safe.
TemplateSpec
,
TemplateResolution
Modifier and Type | Method and Description |
---|---|
String |
getTemplate()
Returns the template (usually the template name).
|
TemplateMode |
getTemplateMode()
Returns the template mode the template is being processed with.
|
ITemplateResource |
getTemplateResource()
Returns the template resource.
|
Set<String> |
getTemplateSelectors()
Returns the template selectors, if there are any.
|
ICacheEntryValidity |
getValidity()
Returns the template resolution validity.
|
boolean |
hasTemplateSelectors()
Returns whether this spec has template selectors specified or not.
|
public String getTemplate()
Returns the template (usually the template name).
This template normally represents the template name, but can be the entire template
contents if the template was specified as a String and resolved by a
StringTemplateResolver
or equivalent.
public boolean hasTemplateSelectors()
Returns whether this spec has template selectors specified or not.
public Set<String> getTemplateSelectors()
Returns the template selectors, if there are any.
Template selectors allow the possibility to process only a part of the specified template, expressing this selection in a syntax similar to jQuery, CSS or XPath selectors. Note this is only available for markup template modes (HTML, XML). For more info on template selectors syntax, have a look at AttoParser's markup selectors documentation.
public ITemplateResource getTemplateResource()
Returns the template resource.
Template resource instances are usually created by implementations of
ITemplateResolver
.
Note that, even if this resource object will never be null, the existence of the
resource object does not necessarily imply the existence of the resource itself unless
the template resolver was configured for calling ITemplateResource.exists()
upon
template resolution.
public TemplateMode getTemplateMode()
Returns the template mode the template is being processed with.
Most times this template mode is the one suggested by the
ITemplateResolver
that resolved the template, but
in those times that a template mode was forced by specifying it at a
TemplateSpec
object or at a call to the TemplateManager
,
these will override the template mode suggested by the template resolver.
public ICacheEntryValidity getValidity()
Returns the template resolution validity.
This validity establishes whether the template can be included in the template cache, and also for how long its resolution will be considered valid.
When a cached template is not considered valid, its cache entry is discarded and it is resolved again.
Copyright © 2016 The THYMELEAF team. All rights reserved.