Class ConsumeSerializerVisitor
- java.lang.Object
-
- org.smooks.engine.delivery.sax.ng.SimpleSerializerVisitor
-
- org.smooks.engine.delivery.sax.ng.ConsumeSerializerVisitor
-
- All Implemented Interfaces:
ContentHandler
,DOMElementVisitor
,DOMVisitAfter
,DOMVisitBefore
,DOMVisitor
,AfterVisitor
,BeforeVisitor
,ChildrenVisitor
,ElementVisitor
,SaxNgVisitor
,SerializerVisitor
,Visitor
- Direct Known Subclasses:
SystemConsumeSerializerVisitor
public class ConsumeSerializerVisitor extends SimpleSerializerVisitor implements DOMElementVisitor
Consumes a node and serializes it to the execution result stream.Once this
ConsumeSerializerVisitor
consumes a node, no otherConsumeSerializerVisitor
instance, including thisConsumeSerializerVisitor
, can re-serialize the node.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ConsumeSerializerVisitor.ElementMemento
-
Field Summary
Fields Modifier and Type Field Description protected Boolean
closeEmptyElements
-
Fields inherited from class org.smooks.engine.delivery.sax.ng.SimpleSerializerVisitor
domSerializer, rewriteEntities
-
-
Constructor Summary
Constructors Constructor Description ConsumeSerializerVisitor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeElement(Element element, Writer writer, ExecutionContext executionContext)
protected void
onWrite(Consumer<Writer> writerConsumer, ExecutionContext executionContext, Node node)
void
setCloseEmptyElements(Optional<Boolean> closeEmptyElements)
void
visitAfter(Element element, ExecutionContext executionContext)
Visits the end of anElement
.void
visitBefore(Element element, ExecutionContext executionContext)
Visits the beginning of anElement
.void
visitChildElement(Element childElement, ExecutionContext executionContext)
Visits a childElement
.void
visitChildText(CharacterData characterData, ExecutionContext executionContext)
Visits the character data of anElement
.void
writeStartElement(Element element, ExecutionContext executionContext)
-
Methods inherited from class org.smooks.engine.delivery.sax.ng.SimpleSerializerVisitor
postConstruct, setRewriteEntities, writeCharacterData, writeChildElements, writeElementCDATA, writeElementComment, writeElementEntityRef, writeElementNode, writeEndElement, writeStartElement
-
-
-
-
Field Detail
-
closeEmptyElements
protected Boolean closeEmptyElements
-
-
Method Detail
-
setCloseEmptyElements
@Inject public void setCloseEmptyElements(@Named("close.empty.elements") Optional<Boolean> closeEmptyElements)
-
writeStartElement
public void writeStartElement(Element element, ExecutionContext executionContext)
-
closeElement
protected void closeElement(Element element, Writer writer, ExecutionContext executionContext)
-
visitBefore
public void visitBefore(Element element, ExecutionContext executionContext) throws SmooksException
Description copied from interface:BeforeVisitor
Visits the beginning of anElement
.- Specified by:
visitBefore
in interfaceBeforeVisitor
- Specified by:
visitBefore
in interfaceDOMVisitBefore
- Overrides:
visitBefore
in classSimpleSerializerVisitor
- Parameters:
element
- theElement
representing the beginning of the fragment. TheElement
's ancestors are traversable unless the global configuration parametermaintain.element.stack
is set to false. TheElement
's child nodes are not traversable.executionContext
- the currentExecutionContext
- Throws:
SmooksException
- Element processing failure.
-
visitChildText
public void visitChildText(CharacterData characterData, ExecutionContext executionContext) throws SmooksException
Description copied from interface:ChildrenVisitor
Visits 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 theSaxNgVisitor
implementation withorg.smooks.engine.delivery.sax.annotation.StreamResultWriter
, or stash the character data in aTextAccumulatorMemento
and restore theTextAccumulatorMemento
inAfterVisitor.visitAfter(Element, ExecutionContext)
.- Specified by:
visitChildText
in interfaceChildrenVisitor
- Overrides:
visitChildText
in classSimpleSerializerVisitor
- Parameters:
characterData
- thenode
which includes character data but not any childElement
s. TheElement
's ancestors are traversable unless the global configuration parametermaintain.element.stack
is set to false.executionContext
- the currentExecutionContext
- Throws:
SmooksException
-
visitChildElement
public void visitChildElement(Element childElement, ExecutionContext executionContext) throws SmooksException
Description copied from interface:ChildrenVisitor
Visits a childElement
. This method is invoked once for each childElement
.- Specified by:
visitChildElement
in interfaceChildrenVisitor
- Overrides:
visitChildElement
in classSimpleSerializerVisitor
- Parameters:
childElement
- the childElementElement
's ancestors are traversable unless the global configuration parametermaintain.element.stack
is set to false. TheElement
's child nodes are not traversable.executionContext
- the currentExecutionContext
- Throws:
SmooksException
-
visitAfter
public void visitAfter(Element element, ExecutionContext executionContext) throws SmooksException
Description copied from interface:AfterVisitor
Visits the end of anElement
.- Specified by:
visitAfter
in interfaceAfterVisitor
- Specified by:
visitAfter
in interfaceDOMVisitAfter
- Overrides:
visitAfter
in classSimpleSerializerVisitor
- Parameters:
element
- theElement
representing the end of the fragment. TheElement
's ancestors are traversable unless the global configuration parametermaintain.element.stack
is set to false. TheElement
's child nodes are traversable if one of the following conditions are met:max.node.depth
global config parameter is set to 0 or greater than 1, or- this
AfterVisitor
implementsParameterizedVisitor.getMaxNodeDepth()
which returns an integer greater than 1
executionContext
- the currentExecutionContext
- Throws:
SmooksException
- Element processing failure.
-
onWrite
protected void onWrite(Consumer<Writer> writerConsumer, ExecutionContext executionContext, Node node)
-
-