Class SimpleSerializerVisitor
- java.lang.Object
-
- org.smooks.engine.delivery.sax.ng.SimpleSerializerVisitor
-
- All Implemented Interfaces:
ContentHandler,AfterVisitor,BeforeVisitor,ChildrenVisitor,ElementVisitor,SaxNgVisitor,SerializerVisitor,Visitor
- Direct Known Subclasses:
ConsumeSerializerVisitor
public class SimpleSerializerVisitor extends Object implements SerializerVisitor, ElementVisitor
Serializes a node to the execution sink stream.
-
-
Field Summary
Fields Modifier and Type Field Description protected DomSerializerdomSerializerprotected BooleanrewriteEntities
-
Constructor Summary
Constructors Constructor Description SimpleSerializerVisitor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidpostConstruct()voidsetRewriteEntities(Optional<Boolean> rewriteEntities)voidvisitAfter(Element element, ExecutionContext executionContext)Visits the end of anElement.voidvisitBefore(Element element, ExecutionContext executionContext)Visits the beginning of anElement.voidvisitChildElement(Element childElement, ExecutionContext executionContext)Visits a childElement.voidvisitChildText(CharacterData characterData, ExecutionContext executionContext)Visits the character data of anElement.voidwriteCharacterData(Node node, Writer writer, ExecutionContext executionContext)Write element text.booleanwriteChildElements()Write the child elements of the element this SerializationUnit is being applied to.voidwriteElementCDATA(CDATASection cdata, Writer writer, ExecutionContext executionContext)Write element CDATA section.voidwriteElementComment(Comment comment, Writer writer, ExecutionContext executionContext)Write element comment.voidwriteElementEntityRef(EntityReference entityRef, Writer writer, ExecutionContext executionContext)Write element entity reference object.voidwriteElementNode(Node node, Writer writer, ExecutionContext executionContext)Write element Node object.voidwriteEndElement(Element element, Writer writer, ExecutionContext executionContext)Write the element end portion; close the element.voidwriteStartElement(Element element, Writer writer, ExecutionContext executionContext)Write the element start portion; the element name and it's attributes.
-
-
-
Field Detail
-
domSerializer
protected DomSerializer domSerializer
-
rewriteEntities
protected Boolean rewriteEntities
-
-
Method Detail
-
postConstruct
@PostConstruct public void postConstruct()
-
setRewriteEntities
@Inject public void setRewriteEntities(@Named("entities.rewrite") Optional<Boolean> rewriteEntities)
-
writeStartElement
public void writeStartElement(Element element, Writer writer, ExecutionContext executionContext) throws IOException
Description copied from interface:SerializerVisitorWrite the element start portion; the element name and it's attributes. EG: <a href="http://www.x.com">- Specified by:
writeStartElementin interfaceSerializerVisitor- 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.
-
writeEndElement
public void writeEndElement(Element element, Writer writer, ExecutionContext executionContext) throws IOException
Description copied from interface:SerializerVisitorWrite the element end portion; close the element. EG: </a>- Specified by:
writeEndElementin interfaceSerializerVisitor- 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.
-
writeCharacterData
public void writeCharacterData(Node node, Writer writer, ExecutionContext executionContext) throws IOException
Description copied from interface:SerializerVisitorWrite element text.- Specified by:
writeCharacterDatain interfaceSerializerVisitor- Parameters:
node- The Text object to write.writer- The writer to be written to.executionContext- ExecutionContext instance for the delivery context.- Throws:
IOException- Exception writing output.
-
writeElementComment
public void writeElementComment(Comment comment, Writer writer, ExecutionContext executionContext) throws IOException
Description copied from interface:SerializerVisitorWrite element comment.- Specified by:
writeElementCommentin interfaceSerializerVisitor- Parameters:
comment- The comment o write.writer- The writer to be written to.executionContext- ExecutionContext instance for the delivery context.- Throws:
IOException- Exception writing output.
-
writeElementEntityRef
public void writeElementEntityRef(EntityReference entityRef, Writer writer, ExecutionContext executionContext) throws IOException
Description copied from interface:SerializerVisitorWrite element entity reference object.- Specified by:
writeElementEntityRefin interfaceSerializerVisitor- Parameters:
entityRef- The entity reference to write.writer- The writer to be written to.executionContext- ExecutionContext instance for the delivery context.- Throws:
IOException- Exception writing output.
-
writeElementCDATA
public void writeElementCDATA(CDATASection cdata, Writer writer, ExecutionContext executionContext) throws IOException
Description copied from interface:SerializerVisitorWrite element CDATA section.- Specified by:
writeElementCDATAin interfaceSerializerVisitor- Parameters:
cdata- The CDATA section to write.writer- The writer to be written to.executionContext- ExecutionContext instance for the delivery context.- Throws:
IOException- Exception writing output.
-
writeElementNode
public void writeElementNode(Node node, Writer writer, ExecutionContext executionContext) throws IOException
Description copied from interface:SerializerVisitorWrite element Node object. Called to write DOM types not covered by the other methods on this interface.- Specified by:
writeElementNodein interfaceSerializerVisitor- Parameters:
node- The node to write.writer- The writer to be written to.executionContext- ExecutionContext instance for the delivery context.- Throws:
IOException- Exception writing output.
-
writeChildElements
public boolean writeChildElements()
Description copied from interface:SerializerVisitorWrite the child elements of the element this SerializationUnit is being applied to.- Specified by:
writeChildElementsin interfaceSerializerVisitor- Returns:
- True if the child elements are to be writen, otherwise false.
-
visitAfter
public void visitAfter(Element element, ExecutionContext executionContext)
Description copied from interface:AfterVisitorVisits the end of anElement.- Specified by:
visitAfterin interfaceAfterVisitor- Parameters:
element- theElementrepresenting the end of the fragment. TheElement's ancestors are traversable unless the global configuration parametermaintain.element.stackis set to false. TheElement's child nodes are traversable if one of the following conditions are met:max.node.depthglobal config parameter is set to 0 or greater than 1, or- this
AfterVisitorimplementsParameterizedVisitor.getMaxNodeDepth()which returns an integer greater than 1
executionContext- the currentExecutionContext
-
visitChildText
public void visitChildText(CharacterData characterData, ExecutionContext executionContext)
Description copied from interface:ChildrenVisitorVisits the character data of anElement. This method is invoked once for each chunk of character data. A shortcut for collecting character data is to annotate theSaxNgVisitorimplementation withorg.smooks.engine.delivery.sax.annotation.StreamResultWriter, or stash the character data in aTextAccumulatorMementoand restore theTextAccumulatorMementoinAfterVisitor.visitAfter(Element, ExecutionContext).- Specified by:
visitChildTextin interfaceChildrenVisitor- Parameters:
characterData- thenodewhich includes character data but not any childElements. TheElement's ancestors are traversable unless the global configuration parametermaintain.element.stackis set to false.executionContext- the currentExecutionContext
-
visitChildElement
public void visitChildElement(Element childElement, ExecutionContext executionContext)
Description copied from interface:ChildrenVisitorVisits a childElement. This method is invoked once for each childElement.- Specified by:
visitChildElementin interfaceChildrenVisitor- Parameters:
childElement- the childElementElement's ancestors are traversable unless the global configuration parametermaintain.element.stackis set to false. TheElement's child nodes are not traversable.executionContext- the currentExecutionContext
-
visitBefore
public void visitBefore(Element element, ExecutionContext executionContext)
Description copied from interface:BeforeVisitorVisits the beginning of anElement.- Specified by:
visitBeforein interfaceBeforeVisitor- Parameters:
element- theElementrepresenting the beginning of the fragment. TheElement's ancestors are traversable unless the global configuration parametermaintain.element.stackis set to false. TheElement's child nodes are not traversable.executionContext- the currentExecutionContext
-
-