org.milyn.templating.freemarker
Class FreeMarkerTemplateProcessor

java.lang.Object
  extended by org.milyn.templating.AbstractTemplateProcessor
      extended by org.milyn.templating.freemarker.FreeMarkerTemplateProcessor
All Implemented Interfaces:
ContentHandler, DOMElementVisitor, DOMVisitAfter, DOMVisitBefore, DOMVisitor, Consumer, Producer, SAXElementVisitor, SAXVisitAfter, SAXVisitBefore, SAXVisitChildren, SAXVisitor, Visitor

public class FreeMarkerTemplateProcessor
extends AbstractTemplateProcessor
implements SAXElementVisitor, Consumer

FreeMarker template application ProcessingUnit.

See FreeMarkerContentHandlerFactory.

NOTE that this visitor supports the extra "useNodeModel" parameter when using DOM based filtering. When set to true (default=false), the targeted DOM element will be attached to the model that is passed to the FreeMarker templating engine. This allows the DOM model to be referenced from within the FreeMarker template, with the targeted element name being the "root" name when forming expressions. See freemarker.org for more info.

Author:
tfennelly

Nested Class Summary
 
Nested classes/interfaces inherited from class org.milyn.templating.AbstractTemplateProcessor
AbstractTemplateProcessor.Action, AbstractTemplateProcessor.ActionDecoder
 
Field Summary
 
Fields inherited from class org.milyn.templating.AbstractTemplateProcessor
TEMPLATE_SPLIT_PI
 
Constructor Summary
protected FreeMarkerTemplateProcessor()
          Default constructor.
  FreeMarkerTemplateProcessor(TemplatingConfiguration templatingConfiguration)
          Programmatically configure the FreeMarker Templating Visitor.
 
Method Summary
 boolean consumes(Object object)
           
protected  void loadTemplate(SmooksResourceConfiguration config)
           
 void onChildElement(SAXElement element, SAXElement childElement, ExecutionContext executionContext)
           
 void onChildText(SAXElement element, SAXText childText, ExecutionContext executionContext)
           
protected  void visit(Element element, ExecutionContext executionContext)
          Apply the template for DOM.
 void visitAfter(Element element, ExecutionContext executionContext)
           
 void visitAfter(SAXElement element, ExecutionContext executionContext)
           
 void visitBefore(Element element, ExecutionContext executionContext)
           
 void visitBefore(SAXElement element, ExecutionContext executionContext)
           
 
Methods inherited from class org.milyn.templating.AbstractTemplateProcessor
applyTemplateBefore, getAction, getBindBeanId, getBindId, getEncoding, getOutputStreamResource, getProducts, initialize, processTemplateAction, processTemplateAction, setTemplatingConfiguration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FreeMarkerTemplateProcessor

protected FreeMarkerTemplateProcessor()
Default constructor.


FreeMarkerTemplateProcessor

public FreeMarkerTemplateProcessor(TemplatingConfiguration templatingConfiguration)
Programmatically configure the FreeMarker Templating Visitor.

Parameters:
templatingConfiguration - The templating configuration.
Method Detail

loadTemplate

protected void loadTemplate(SmooksResourceConfiguration config)
                     throws IOException
Specified by:
loadTemplate in class AbstractTemplateProcessor
Throws:
IOException

consumes

public boolean consumes(Object object)
Specified by:
consumes in interface Consumer

visitBefore

public void visitBefore(Element element,
                        ExecutionContext executionContext)
                 throws SmooksException
Specified by:
visitBefore in interface DOMVisitBefore
Overrides:
visitBefore in class AbstractTemplateProcessor
Throws:
SmooksException

visitAfter

public void visitAfter(Element element,
                       ExecutionContext executionContext)
                throws SmooksException
Specified by:
visitAfter in interface DOMVisitAfter
Overrides:
visitAfter in class AbstractTemplateProcessor
Throws:
SmooksException

visit

protected void visit(Element element,
                     ExecutionContext executionContext)
              throws SmooksException
Apply the template for DOM.

Specified by:
visit in class AbstractTemplateProcessor
Parameters:
element - The targeted DOM Element.
executionContext - The Smooks execution context.
Throws:
SmooksException - Failed to apply template. See cause.

visitBefore

public void visitBefore(SAXElement element,
                        ExecutionContext executionContext)
                 throws SmooksException,
                        IOException
Specified by:
visitBefore in interface SAXVisitBefore
Throws:
SmooksException
IOException

onChildText

public void onChildText(SAXElement element,
                        SAXText childText,
                        ExecutionContext executionContext)
                 throws SmooksException,
                        IOException
Specified by:
onChildText in interface SAXVisitChildren
Throws:
SmooksException
IOException

onChildElement

public void onChildElement(SAXElement element,
                           SAXElement childElement,
                           ExecutionContext executionContext)
                    throws SmooksException,
                           IOException
Specified by:
onChildElement in interface SAXVisitChildren
Throws:
SmooksException
IOException

visitAfter

public void visitAfter(SAXElement element,
                       ExecutionContext executionContext)
                throws SmooksException,
                       IOException
Specified by:
visitAfter in interface SAXVisitAfter
Throws:
SmooksException
IOException


Copyright © 2014. All Rights Reserved.