org.milyn.delivery.dom.serialize
Class GhostElementSerializationUnit

java.lang.Object
  extended by org.milyn.delivery.dom.serialize.DefaultSerializationUnit
      extended by org.milyn.delivery.dom.serialize.GhostElementSerializationUnit
All Implemented Interfaces:
ContentHandler, SerializationUnit, SAXElementVisitor, SAXVisitAfter, SAXVisitBefore, SAXVisitChildren, SAXVisitor, Visitor

public class GhostElementSerializationUnit
extends DefaultSerializationUnit
implements SAXElementVisitor

Ghost element serialization unit.

A ghost element can be used to "wrap" other DOM content. The Ghost element itself is not serialized, but it's child content is.

Author:
tom.fennelly@gmail.com

Constructor Summary
GhostElementSerializationUnit()
           
 
Method Summary
static Element createElement(Document ownerDocument)
          Utility method for creating a <ghost-element/> element.
 void onChildElement(SAXElement element, SAXElement childElement, ExecutionContext executionContext)
          Process the onChildElement event for the targeted element.
 void onChildText(SAXElement element, SAXText childText, ExecutionContext executionContext)
          Process the onChildText event for the targeted element.
 void visitAfter(SAXElement element, ExecutionContext executionContext)
          Visit the supplied element after visiting its child elements.
 void visitBefore(SAXElement element, ExecutionContext executionContext)
          Visit the supplied element before visiting its child elements.
 void writeElementEnd(Element element, Writer writer, ExecutionContext executionContext)
          Write the element end portion; close the element.
 void writeElementStart(Element element, Writer writer, ExecutionContext executionContext)
          Write the element start portion; the element name and it's attributes.
 
Methods inherited from class org.milyn.delivery.dom.serialize.DefaultSerializationUnit
setCloseEmptyElements, writeAttributes, writeChildElements, writeElementCDATA, writeElementComment, writeElementEnd, writeElementEntityRef, writeElementNode, writeElementStart, writeElementText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GhostElementSerializationUnit

public GhostElementSerializationUnit()
Method Detail

writeElementStart

public void writeElementStart(Element element,
                              Writer writer,
                              ExecutionContext executionContext)
                       throws IOException
Description copied from interface: SerializationUnit
Write the element start portion; the element name and it's attributes.

EG: <a href="http://www.x.com">

Specified by:
writeElementStart in interface SerializationUnit
Overrides:
writeElementStart in class DefaultSerializationUnit
Parameters:
element - The element start to write.
writer - The writer to be written to.
executionContext - ExecutionContext instance for the delivery context.
Throws:
IOException - Exception writing output.

writeElementEnd

public void writeElementEnd(Element element,
                            Writer writer,
                            ExecutionContext executionContext)
                     throws IOException
Description copied from interface: SerializationUnit
Write the element end portion; close the element.

EG: </a>

Specified by:
writeElementEnd in interface SerializationUnit
Overrides:
writeElementEnd in class DefaultSerializationUnit
Parameters:
element - The element end to write.
writer - The writer to be written to.
executionContext - ExecutionContext instance for the delivery context.
Throws:
IOException - Exception writing output.

createElement

public static Element createElement(Document ownerDocument)
Utility method for creating a <ghost-element/> element.

Parameters:
ownerDocument - The owner document.
Returns:
The <ghost-element/> element.

visitBefore

public void visitBefore(SAXElement element,
                        ExecutionContext executionContext)
                 throws SmooksException,
                        IOException
Description copied from interface: SAXVisitBefore
Visit the supplied element before visiting its child elements.

Specified by:
visitBefore in interface SAXVisitBefore
Parameters:
element - The SAX element being visited.
executionContext - Execution context.
Throws:
SmooksException - Event processing failure.
IOException - Error writing event to output writer.

onChildText

public void onChildText(SAXElement element,
                        SAXText childText,
                        ExecutionContext executionContext)
                 throws SmooksException,
                        IOException
Description copied from interface: SAXVisitChildren
Process the onChildText event for the targeted element.

Be careful when caching element data. This is not a DOM.

Specified by:
onChildText in interface SAXVisitChildren
Parameters:
element - The element containing the text (parent). The targeted element.
childText - The text.
executionContext - Execution context.
Throws:
SmooksException - Event processing failure.
IOException - Error writing event to output writer.

onChildElement

public void onChildElement(SAXElement element,
                           SAXElement childElement,
                           ExecutionContext executionContext)
                    throws SmooksException,
                           IOException
Description copied from interface: SAXVisitChildren
Process the onChildElement event for the targeted element.

Be careful when caching element data. This is not a DOM.

Specified by:
onChildElement in interface SAXVisitChildren
Parameters:
element - The element containing the child element (parent). The targeted element.
childElement - The child element just added to the targeted element.
executionContext - Execution context.
Throws:
SmooksException - Event processing failure.
IOException - Error writing event to output writer.

visitAfter

public void visitAfter(SAXElement element,
                       ExecutionContext executionContext)
                throws SmooksException,
                       IOException
Description copied from interface: SAXVisitAfter
Visit the supplied element after visiting its child elements.

Specified by:
visitAfter in interface SAXVisitAfter
Parameters:
element - The SAX element being visited.
executionContext - Execution context.
Throws:
SmooksException - Event processing failure.
IOException - Error writing event to output writer.


Copyright © 2008. All Rights Reserved.