Class TestEngineTemplateResolver
- java.lang.Object
-
- org.thymeleaf.testing.templateengine.engine.resolver.TestEngineTemplateResolver
-
- All Implemented Interfaces:
ITemplateResolver
public class TestEngineTemplateResolver extends java.lang.Object implements ITemplateResolver
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringnameprivate java.lang.Integerorderstatic java.lang.StringTEST_TEMPLATE_CONVERSION_CHARSET
-
Constructor Summary
Constructors Constructor Description TestEngineTemplateResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetName()Returns the name of the template resolverjava.lang.IntegergetOrder()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.TemplateResolutionresolveTemplate(IEngineConfiguration configuration, java.lang.String ownerTemplate, java.lang.String template, java.util.Map<java.lang.String,java.lang.Object> templateResolutionAttributes)Tries to resolve a template.voidsetName(java.lang.String name)Sets a new name for the Template Resolver.voidsetOrder(java.lang.Integer order)Sets a new order for the template engine in the chain.
-
-
-
Field Detail
-
TEST_TEMPLATE_CONVERSION_CHARSET
public static final java.lang.String TEST_TEMPLATE_CONVERSION_CHARSET
- See Also:
- Constant Field Values
-
name
private java.lang.String name
-
order
private java.lang.Integer order
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the name of the template resolver
- Specified by:
getNamein interfaceITemplateResolver- Returns:
- the name of the template resolver
-
setName
public void setName(java.lang.String name)
Sets a new name for the Template Resolver.
- Parameters:
name- the new name
-
getOrder
public java.lang.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.
- Specified by:
getOrderin interfaceITemplateResolver- Returns:
- the order in which this template resolver will be called in the chain.
-
setOrder
public void setOrder(java.lang.Integer order)
Sets a new order for the template engine in the chain. Order should start with 1.
- Parameters:
order- the new order.
-
resolveTemplate
public TemplateResolution resolveTemplate(IEngineConfiguration configuration, java.lang.String ownerTemplate, java.lang.String template, java.util.Map<java.lang.String,java.lang.Object> templateResolutionAttributes)
Description copied from interface:ITemplateResolverTries to resolve a template.
The method arguments contain all the info needed for trying to resolve the template. The Template Resolver will apply its configuration (prefixes/suffixes, template mode patterns, cache configurations, etc) and return a
TemplateResolutionobject.The
ownerTemplate, which might be null, will be specified when the template is resolved in order to be used as a fragent to be inserted into a higher level template (the owner). Most template resolver implementations will simply ignore this argument, but others might change their resolution results depending on the owner template that is inserting the resolved fragment.The fact that a Template Resolver returns a
TemplateResolutiondoes 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 callingITemplateResource.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.Note that the template selectors that might be used for a executing or inserting a template are not specified to the template resolver. The reason is template selectors are applied by the parser, not the template resolvers, and allowing the resolver to take any decisions based on template selectors (like e.g. omitting some output from the resource) could harm the correctness of the selection operation performed by the parser.
- Specified by:
resolveTemplatein interfaceITemplateResolver- Parameters:
configuration- the engine configuration.ownerTemplate- the containing template from which we want to resolve a new one as a fragment. Can be null.template- the template to be resolved (usually its name).templateResolutionAttributes- the template resolution attributes to be used (usually coming from aTemplateSpecinstance. Can be null.- Returns:
- a TemplateResolution object (which might represent an existing resource or not), or null if the template could not be resolved.
-
-