|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Objectorg.thymeleaf.processor.AbstractProcessor
public abstract class AbstractProcessor
Common abstract superclass for all processors, including utility methods for easily resolving template- and class-based externalized messages. This class also takes care of processor precedence.
Constructor Summary | |
---|---|
AbstractProcessor()
|
Method Summary | |
---|---|
int |
compareTo(IProcessor o)
Compare (and therefore order) processors according to their precedence. |
protected abstract ProcessorResult |
doProcess(Arguments arguments,
ProcessorMatchingContext processorMatchingContext,
Node node)
|
protected String |
getMessage(Arguments arguments,
String messageKey,
Object[] messageParameters)
Resolves a message, trying to resolve it first as a template message (see getMessageForTemplate(Arguments, 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,
String messageKey,
Object[] messageParameters)
Resolves the specified message as a template message. |
abstract int |
getPrecedence()
|
ProcessorResult |
process(Arguments arguments,
ProcessorMatchingContext processorMatchingContext,
Node node)
Processes a node. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.thymeleaf.processor.IProcessor |
---|
getMatcher |
Constructor Detail |
---|
public AbstractProcessor()
Method Detail |
---|
protected String getMessage(Arguments arguments, String messageKey, Object[] messageParameters)
Resolves a message, trying to resolve it first as a template message
(see getMessageForTemplate(Arguments, 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).
arguments
- the execution arguments, containing Template Engine configuration and
execution context.messageKey
- the message keymessageParameters
- the (optional) message parameters
protected String getMessageForTemplate(Arguments arguments, 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).
arguments
- the execution arguments, containing Template Engine configuration and
execution context.messageKey
- the message keymessageParameters
- the (optional) message parameters
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 attribute 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).
arguments
- the execution arguments, containing Template Engine configuration and
execution context.messageKey
- the message keymessageParameters
- the (optional) message parameters
public abstract int getPrecedence()
public int compareTo(IProcessor o)
Compare (and therefore order) processors according to their precedence.
Be careful: This implementation of compareTo breaks (o1.compareTo(o2) == 0) == (o1.equals(o2)), as two different processors can have the same precedence.
compareTo
in interface Comparable<IProcessor>
o
- the object to compare to
public final ProcessorResult process(Arguments arguments, ProcessorMatchingContext processorMatchingContext, Node node)
IProcessor
Processes a node. This node is supposed to have already positively matched this processor's applicability.
process
in interface IProcessor
arguments
- the Arguments object to be applied.processorMatchingContext
- the matching context.node
- the node to be processed.
protected abstract ProcessorResult doProcess(Arguments arguments, ProcessorMatchingContext processorMatchingContext, Node node)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |