org.thymeleaf.processor.tag
Class AbstractTagProcessor

Object
  extended by org.thymeleaf.processor.tag.AbstractTagProcessor
All Implemented Interfaces:
ITagProcessor
Direct Known Subclasses:
AbstractConditionalVisibilityTagProcessor, AbstractIterationTagProcessor, AbstractLocalVariableDefinitionTagProcessor, AbstractMarkupSubstitutionTagProcessor, AbstractNoOpTagProcessor, AbstractRemovalTagProcessor, AbstractSelectionTargetTagProcessor, AbstractTextInlinerTagProcessor

public abstract class AbstractTagProcessor
extends Object
implements ITagProcessor

Base convenience implementation of ITagProcessor returning empty sets for all of the interface's methods and allowing easy access to internationalization features by providing methods for obtaining both template messages and processor messages.

This class provides a more convenient extension point for tag processors, allowing the developer only to override the methods that are really needed.

Since:
1.0
Author:
Daniel Fernández

Constructor Summary
AbstractTagProcessor()
           
 
Method Summary
protected  String getMessage(Arguments arguments, TemplateResolution templateResolution, String messageKey, Object[] messageParameters)
           Resolves a message, trying to resolve it first as a template message (see getMessageForTemplate(Arguments, TemplateResolution, String, Object[])) and, if not found, as a processor message (see getMessageForProcessor(Arguments, String, Object[]).
protected  String getMessageForProcessor(Arguments arguments, String messageKey, Object[] messageParameters)
           Resolves the specified message as a processor message.
protected  String getMessageForTemplate(Arguments arguments, TemplateResolution templateResolution, String messageKey, Object[] messageParameters)
           Resolves the specified message as a template message.
 Set<Class<? extends IValueProcessor>> getValueProcessorDependencies()
           Return this processor's dependencies.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.thymeleaf.processor.tag.ITagProcessor
getTagApplicabilities, process
 

Constructor Detail

AbstractTagProcessor

public AbstractTagProcessor()
Method Detail

getValueProcessorDependencies

public Set<Class<? extends IValueProcessor>> getValueProcessorDependencies()
Description copied from interface: ITagProcessor

Return this processor's dependencies.

The dependencies are the set of value processors (IValueProcessor objects) this tag processor needs for being executed. This has to be declared for dialect validation purposes at configuration time.

Specified by:
getValueProcessorDependencies in interface ITagProcessor
Returns:
the set of value processor dependencies.

getMessage

protected String getMessage(Arguments arguments,
                            TemplateResolution templateResolution,
                            String messageKey,
                            Object[] messageParameters)

Resolves a message, trying to resolve it first as a template message (see getMessageForTemplate(Arguments, TemplateResolution, String, Object[])) and, if not found, as a processor message (see getMessageForProcessor(Arguments, String, Object[]).

This method always returns a result: if no message is found for the specified key, a default placeholder message is returned (as a String).

Parameters:
arguments - the execution arguments, containing Template Engine configuration and execution context.
templateResolution - the result of resolving the template by the Template Resolvers.
messageKey - the message key
messageParameters - the (optional) message parameters
Returns:
the resolved message

getMessageForTemplate

protected String getMessageForTemplate(Arguments arguments,
                                       TemplateResolution templateResolution,
                                       String messageKey,
                                       Object[] messageParameters)

Resolves the specified message as a template message.

Template messages are resolved by the Message Resolver (IMessageResolver) instances configured at the Template Engine (executed in chain) in exactly the same way as, for example, a #{...} expression would when using the Standard Dialect or the SpringStandard Dialect.

This method always returns a result: if no message is found for the specified key, a default placeholder message is returned (as a String).

Parameters:
arguments - the execution arguments, containing Template Engine configuration and execution context.
templateResolution - the result of resolving the template by the Template Resolvers.
messageKey - the message key
messageParameters - the (optional) message parameters
Returns:
the resolved message

getMessageForProcessor

protected String getMessageForProcessor(Arguments arguments,
                                        String messageKey,
                                        Object[] messageParameters)

Resolves the specified message as a processor message.

Processor messages appear on .properties files that usually live in the same package (i.e. source folder) as the processor class itself, and have the same base name (for example, for a com.something.MyProc processor we can have com/something/MyProc_en.properties, com/something/MyProc_es.properties, com/something/MyProc.properties (for defaults), etc.). This allows the encapsulation and packing of processors along with all of its required internationalization resources.

If no message is found for the specified key in a .properties file with the same base name as the tag processor, then its superclasses are also examined.

This method always returns a result: if at the end no message is found for the specified key, a default placeholder message is returned (as a String).

Parameters:
arguments - the execution arguments, containing Template Engine configuration and execution context.
messageKey - the message key
messageParameters - the (optional) message parameters
Returns:
the resolved message


Copyright © 2011 The THYMELEAF team. All Rights Reserved.