Class AbstractTemplateHandler
- Object
-
- org.thymeleaf.engine.AbstractTemplateHandler
-
- All Implemented Interfaces:
ITemplateHandler
- Direct Known Subclasses:
ModelBuilderTemplateHandler
,OutputTemplateHandler
public abstract class AbstractTemplateHandler extends Object implements ITemplateHandler
Basic abstract implementation of
ITemplateHandler
that takes care of the whole contract of this interface and offers a good base for the easy implementation of custom template handlers.All
handleX()
implementations in this class are set to simply delegate to the next handler in the chain, so that subclasses can override only the handling methods that are really relevant to them.- Since:
- 3.0.0
- Author:
- Daniel Fernández
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractTemplateHandler()
Create a new instance of this handler, not specifying the 'next' handler.protected
AbstractTemplateHandler(ITemplateHandler next)
Create a new instance of this handler, specifying the handler that will be used as next step in the chain.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ITemplateContext
getContext()
Return the processing context corresponding to the template execution for which the template handler instance has been created.protected ITemplateHandler
getNext()
Return the next handler in the chain, so that events can be delegated to it.void
handleCDATASection(ICDATASection cdataSection)
void
handleCloseElement(ICloseElementTag closeElementTag)
void
handleComment(IComment comment)
void
handleDocType(IDocType docType)
void
handleOpenElement(IOpenElementTag openElementTag)
void
handleProcessingInstruction(IProcessingInstruction processingInstruction)
void
handleStandaloneElement(IStandaloneElementTag standaloneElementTag)
void
handleTemplateEnd(ITemplateEnd templateEnd)
void
handleTemplateStart(ITemplateStart templateStart)
void
handleText(IText text)
void
handleXMLDeclaration(IXMLDeclaration xmlDeclaration)
void
setContext(ITemplateContext context)
Set the processing context to be used, including template name, context, and also the engine configuration.void
setNext(ITemplateHandler next)
Set the next handler in the chain, so that events can be (optionally) delegated to it.
-
-
-
Constructor Detail
-
AbstractTemplateHandler
protected AbstractTemplateHandler(ITemplateHandler next)
Create a new instance of this handler, specifying the handler that will be used as next step in the chain.
- Parameters:
next
- the next step in the chain.
-
AbstractTemplateHandler
protected AbstractTemplateHandler()
Create a new instance of this handler, not specifying the 'next' handler.
-
-
Method Detail
-
setNext
public void setNext(ITemplateHandler next)
Set the next handler in the chain, so that events can be (optionally) delegated to it.
This method is called when the chain of template handlers is conformed, always before starting the parsing and processing of a template.
- Specified by:
setNext
in interfaceITemplateHandler
- Parameters:
next
- the next handler in the chain.
-
setContext
public void setContext(ITemplateContext context)
Set the processing context to be used, including template name, context, and also the engine configuration.
This method is called always before starting the parsing and processing of a template.
- Specified by:
setContext
in interfaceITemplateHandler
- Parameters:
context
- the processing context.
-
getNext
protected final ITemplateHandler getNext()
Return the next handler in the chain, so that events can be delegated to it.
- Returns:
- the next handler in the chain.
-
getContext
protected final ITemplateContext getContext()
Return the processing context corresponding to the template execution for which the template handler instance has been created.
- Returns:
- the processing context
-
handleTemplateStart
public void handleTemplateStart(ITemplateStart templateStart)
- Specified by:
handleTemplateStart
in interfaceITemplateHandler
-
handleTemplateEnd
public void handleTemplateEnd(ITemplateEnd templateEnd)
- Specified by:
handleTemplateEnd
in interfaceITemplateHandler
-
handleXMLDeclaration
public void handleXMLDeclaration(IXMLDeclaration xmlDeclaration)
- Specified by:
handleXMLDeclaration
in interfaceITemplateHandler
-
handleDocType
public void handleDocType(IDocType docType)
- Specified by:
handleDocType
in interfaceITemplateHandler
-
handleCDATASection
public void handleCDATASection(ICDATASection cdataSection)
- Specified by:
handleCDATASection
in interfaceITemplateHandler
-
handleComment
public void handleComment(IComment comment)
- Specified by:
handleComment
in interfaceITemplateHandler
-
handleText
public void handleText(IText text)
- Specified by:
handleText
in interfaceITemplateHandler
-
handleStandaloneElement
public void handleStandaloneElement(IStandaloneElementTag standaloneElementTag)
- Specified by:
handleStandaloneElement
in interfaceITemplateHandler
-
handleOpenElement
public void handleOpenElement(IOpenElementTag openElementTag)
- Specified by:
handleOpenElement
in interfaceITemplateHandler
-
handleCloseElement
public void handleCloseElement(ICloseElementTag closeElementTag)
- Specified by:
handleCloseElement
in interfaceITemplateHandler
-
handleProcessingInstruction
public void handleProcessingInstruction(IProcessingInstruction processingInstruction)
- Specified by:
handleProcessingInstruction
in interfaceITemplateHandler
-
-