org.thymeleaf.templateresolver
Class TemplateResolution

Object
  extended by org.thymeleaf.templateresolver.TemplateResolution

public final class TemplateResolution
extends Object

Result of the execution of a Template Resolver.

A TemplateResolution object is created by implementations of ITemplateResolver when templates are resolved, and it contains:

The fact that a Template Resolver returns a TemplateResolution does not necessarily mean that the template will be effectively be resolved by the Template Resolver. For this, the Resource Resolver will also need to be able to resolve the declared template's resource.

Since:
1.0
Author:
Daniel Fernández

Constructor Summary
TemplateResolution(String templateName, String resourceName, IResourceResolver resourceResolver, String characterEncoding, TemplateMode templateMode, boolean cacheable, Long cacheTTLMs)
           
 
Method Summary
 Long getCacheTTLMs()
           Returns the TTL of the template in the cache, in milliseconds.
 String getCharacterEncoding()
           Returns the character encoding that should be used for reading the template (using the Resource Resolver).
 String getResourceName()
           Returns the resource name.
 IResourceResolver getResourceResolver()
           Returns the resource resolver that should be used for actually reading the template (using the provided resource name, see getResourceName()).
 TemplateMode getTemplateMode()
           Returns the template mode to be applied.
 String getTemplateName()
           Returns the template name.
 boolean isCacheable()
           Returns whether the template can be cached or not.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateResolution

public TemplateResolution(String templateName,
                          String resourceName,
                          IResourceResolver resourceResolver,
                          String characterEncoding,
                          TemplateMode templateMode,
                          boolean cacheable,
                          Long cacheTTLMs)
Method Detail

getTemplateName

public String getTemplateName()

Returns the template name.

This should be the same name used for calling the TemplateEngine.process(String, org.thymeleaf.context.IContext) method.

Returns:
the template name.

getResourceName

public String getResourceName()

Returns the resource name.

The resource name is the identifier that will be used for actually reading the template by means of the Resource Resolver (see getResourceResolver()).

This resource name will typically be computed by the Template Resolver from the template name. For example, a Template Resolver could have a prefix and a suffix configured so that starting from the template name "home" it returns the resource name "/WEB-INF/templates/web/home.html", which can be then read by a ClassLoaderResourceResolver instance.

Returns:
the resource name.

getResourceResolver

public IResourceResolver getResourceResolver()

Returns the resource resolver that should be used for actually reading the template (using the provided resource name, see getResourceName()).

Returns:
the resource resolver.

getCharacterEncoding

public String getCharacterEncoding()

Returns the character encoding that should be used for reading the template (using the Resource Resolver).

Returns:
the character encoding.

getTemplateMode

public TemplateMode getTemplateMode()

Returns the template mode to be applied. This template mode (TemplateMode) determines whether the template is to be considered XML, VALIDXML, XHTML, VALIDXHTML, HTML5 or LEGACYHTML5.

Returns:
the template mode.

isCacheable

public boolean isCacheable()

Returns whether the template can be cached or not.

If true, the result of parsing this template (DOM tree) will be included into the Parsed Template Cache.

Returns:
whether the template can be cache dor not.

getCacheTTLMs

public Long getCacheTTLMs()

Returns the TTL of the template in the cache, in milliseconds.

This method should return null if isCacheable() returns false.

If isCacheable() returns true and this method returns null, it means the cache entry will live in cache until it is removed by the LRU algorithm (because of being the oldest of entries).

Returns:
the TTL of the template in the cache, in milliseconds.


Copyright © 2011 The THYMELEAF team. All Rights Reserved.