Milyn-Smooks Version 0.4

org.milyn.delivery.serialize
Interface SerializationUnit

All Superinterfaces:
ContentDeliveryUnit
All Known Implementing Classes:
AbstractSerializationUnit

public interface SerializationUnit
extends ContentDeliveryUnit

W3C Node Serailization interface definition.

Implementations of this interface are applied to the content during the Serialisation phase.

This interface allows element targeted (by device, profile, DTD info etc) serialization code to be implemented. It gives control over how an element is "printed" to the target device.

All implementations must contain a public constructor that takes a CDRDef instance as a parameter. For this reason condsider extending AbstractSerializationUnit for convienience (your IDE should auto-add the constructor).

Serialization Units are defined in the .cdrl file (in .cdrar file(s)) in the very same way as any other content delivery resource (Assembly Units, Transformation Units, DTDs etc).

Implementations must be stateless in nature.

Only one Serialisation Unit is applied to each element. If more than one Serialization Unit is applicable to a given element, the most specific Serialization Unit is choosen. See CDRDefSortComparator.

See Delivery Overview.

Author:
tfennelly

Method Summary
 boolean writeChildElements()
          Write the child elements of the element this SerializationUnit is being applied to.
 void writeElementCDATA(org.w3c.dom.CDATASection cdata, java.io.Writer writer, ContainerRequest containerRequest)
          Write element CDATA section.
 void writeElementComment(org.w3c.dom.Comment comment, java.io.Writer writer, ContainerRequest containerRequest)
          Write element comment.
 void writeElementEnd(org.w3c.dom.Element element, java.io.Writer writer, ContainerRequest containerRequest)
          Write the element end portion; close the element.
 void writeElementEntityRef(org.w3c.dom.EntityReference entityRef, java.io.Writer writer, ContainerRequest containerRequest)
          Write element entity reference object.
 void writeElementNode(org.w3c.dom.Node node, java.io.Writer writer, ContainerRequest containerRequest)
          Write element Node object.
 void writeElementStart(org.w3c.dom.Element element, java.io.Writer writer, ContainerRequest containerRequest)
          Write the element start portion; the element name and it's attributes.
 void writeElementText(org.w3c.dom.Text text, java.io.Writer writer, ContainerRequest containerRequest)
          Write element text.
 
Methods inherited from interface org.milyn.delivery.ContentDeliveryUnit
getDetailDescription, getShortDescription
 

Method Detail

writeElementStart

public void writeElementStart(org.w3c.dom.Element element,
                              java.io.Writer writer,
                              ContainerRequest containerRequest)
                       throws java.io.IOException
Write the element start portion; the element name and it's attributes.

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

Parameters:
element - The element start to write.
writer - The writer to be written to.
containerRequest - ContainerRequest instance for the delivery context.
Throws:
java.io.IOException - Exception writing output.

writeElementEnd

public void writeElementEnd(org.w3c.dom.Element element,
                            java.io.Writer writer,
                            ContainerRequest containerRequest)
                     throws java.io.IOException
Write the element end portion; close the element.

EG: </a>

Parameters:
element - The element end to write.
writer - The writer to be written to.
containerRequest - ContainerRequest instance for the delivery context.
Throws:
java.io.IOException - Exception writing output.

writeElementText

public void writeElementText(org.w3c.dom.Text text,
                             java.io.Writer writer,
                             ContainerRequest containerRequest)
                      throws java.io.IOException
Write element text.

Parameters:
text - The Text object to write.
writer - The writer to be written to.
containerRequest - ContainerRequest instance for the delivery context.
Throws:
java.io.IOException - Exception writing output.

writeElementComment

public void writeElementComment(org.w3c.dom.Comment comment,
                                java.io.Writer writer,
                                ContainerRequest containerRequest)
                         throws java.io.IOException
Write element comment.

Parameters:
comment - The comment o write.
writer - The writer to be written to.
containerRequest - ContainerRequest instance for the delivery context.
Throws:
java.io.IOException - Exception writing output.

writeElementEntityRef

public void writeElementEntityRef(org.w3c.dom.EntityReference entityRef,
                                  java.io.Writer writer,
                                  ContainerRequest containerRequest)
                           throws java.io.IOException
Write element entity reference object.

Parameters:
entityRef - The entity reference to write.
writer - The writer to be written to.
containerRequest - ContainerRequest instance for the delivery context.
Throws:
java.io.IOException - Exception writing output.

writeElementCDATA

public void writeElementCDATA(org.w3c.dom.CDATASection cdata,
                              java.io.Writer writer,
                              ContainerRequest containerRequest)
                       throws java.io.IOException
Write element CDATA section.

Parameters:
cdata - The CDATA section to write.
writer - The writer to be written to.
containerRequest - ContainerRequest instance for the delivery context.
Throws:
java.io.IOException - Exception writing output.

writeElementNode

public void writeElementNode(org.w3c.dom.Node node,
                             java.io.Writer writer,
                             ContainerRequest containerRequest)
                      throws java.io.IOException
Write element Node object.

Called to write DOM types not covered by the other methods on this interface.

Parameters:
node - The node to write.
writer - The writer to be written to.
containerRequest - ContainerRequest instance for the delivery context.
Throws:
java.io.IOException - Exception writing output.

writeChildElements

public boolean writeChildElements()
Write the child elements of the element this SerializationUnit is being applied to.

Returns:
True if the child elements are to be writen, otherwise false.

Milyn-Smooks Version 0.4