Class TemplateResolution
Result of the execution of a Template Resolver.
A TemplateResolution object is created by implementations of ITemplateResolver
when templates are resolved, and it contains not only the resource representing the resolved
template, but also the template mode to be used and the cache validity to be applied.
The fact that a Template Resolver returns a TemplateResolution
does not necessarily
mean that the resolved template resource exists. It might only be so if the template resolver
is configured to perform an existence check on the resource before returning a resolution
result (by means of calling ITemplateResource.exists()
), which might be configurable on
a per-ITemplateResolver
-implementation basis. Implementations might choose not to check
resource existance by default in order to avoid the possible performance impact of a double access
to the resource.
Objects of this class should not be considered thread-safe.
Note a class with this name existed since 1.0, but it was completely reimplemented in 3.0.0.
- Since:
- 3.0.0
- Author:
- Daniel Fernández
-
Constructor Summary
ConstructorsConstructorDescriptionTemplateResolution
(ITemplateResource templateResource, boolean templateResourceExistenceVerified, TemplateMode templateMode, boolean useDecoupledLogic, ICacheEntryValidity validity) TemplateResolution
(ITemplateResource templateResource, TemplateMode templateMode, ICacheEntryValidity validity) -
Method Summary
Modifier and TypeMethodDescriptionReturns the template mode to be applied to the template, as suggested by theITemplateResolver
.Returns the template resource.boolean
Returns whether the existence of decoupled logic (normally in a separate file) should be checked for this template during parsing.Returns the template resolution validity.boolean
Returns whether the existence of the resource returned by the resolution mechanism has been already verified to actually exist by the template resolver during resolution.
-
Constructor Details
-
TemplateResolution
public TemplateResolution(ITemplateResource templateResource, TemplateMode templateMode, ICacheEntryValidity validity) -
TemplateResolution
public TemplateResolution(ITemplateResource templateResource, boolean templateResourceExistenceVerified, TemplateMode templateMode, boolean useDecoupledLogic, ICacheEntryValidity validity)
-
-
Method Details
-
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 callingITemplateResource.exists()
upon template resolution.- Returns:
- the template resource
-
getTemplateMode
Returns the template mode to be applied to the template, as suggested by the
ITemplateResolver
.Note that this template mode can be ignored if the template being resolved is configured to be executed with a specific template mode regardless of what the template resolver suggests.
- Returns:
- the template mode for the resolved template
-
isTemplateResourceExistenceVerified
public boolean isTemplateResourceExistenceVerified()Returns whether the existence of the resource returned by the resolution mechanism has been already verified to actually exist by the template resolver during resolution.
This allows avoiding further checks in case the
resource.exists()
execution is costly.Note a
false
here does not mean the resource does not exist, but simply that its existence was not verified (true) during resolution.- Returns:
- whether the existence of the resource was verified during resolution.
-
getUseDecoupledLogic
public boolean getUseDecoupledLogic()Returns whether the existence of decoupled logic (normally in a separate file) should be checked for this template during parsing.
Note a
true
here does not mean that a decoupled logic resource has to necessarily exist for this template, only that its existence should be checked and used if it exists.- Returns:
- whether the existence of decoupled logic should be checked.
-
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.
- Returns:
- the validity object
-