public abstract class AbstractDOMOutputProcessor extends AbstractOutputProcessor implements DOMOutputProcessor
DOMOutputProcessor
for supporting the DOMOutputter
.
This class is marked abstract even though all methods are fully implemented.
The process*(...)
methods are public because they match the
DOMOutputProcessor interface but the remaining methods are all protected.
People who want to create a custom DOMOutputProcessor for DOMOutputter
are able to extend this class and modify any functionality they want. Before
sub-classing this you should first check to see if the Format
class
can get you the results you want.
Subclasses of this should have reentrant methods. This is easiest to accomplish simply by not allowing any instance fields. If your sub-class has an instance field/variable, then it's probably broken.
One significant feature of this implementation is that it creates and
maintains both a NamespaceStack
and FormatStack
that are
managed in the
printElement(FormatStack, NamespaceStack, org.w3c.dom.Document, Element)
method. The stacks are pushed and popped in that method only. They
significantly improve the performance and readability of the code.
The NamespaceStack is only sent through to the
printElement(FormatStack, NamespaceStack, org.w3c.dom.Document, Element)
and
printContent(FormatStack, NamespaceStack, org.w3c.dom.Document, org.w3c.dom.Node, Walker)
methods, but the FormatStack is pushed through to all print* Methods.
This class delegates the formatting of the content to the Walker classes
and you can create your own custom walker by overriding the
AbstractOutputProcessor.buildWalker(FormatStack, List, boolean)
method.
DOMOutputter
,
DOMOutputProcessor
Constructor and Description |
---|
AbstractDOMOutputProcessor() |
Modifier and Type | Method and Description |
---|---|
protected org.w3c.dom.Node |
helperContentDispatcher(FormatStack fstack,
NamespaceStack nstack,
org.w3c.dom.Document basedoc,
Content content)
This method contains code which is reused in a number of places.
|
protected org.w3c.dom.Attr |
printAttribute(FormatStack fstack,
org.w3c.dom.Document basedoc,
Attribute attribute)
This will handle printing of a
Attribute . |
protected org.w3c.dom.CDATASection |
printCDATA(FormatStack fstack,
org.w3c.dom.Document basedoc,
CDATA cdata)
This will handle printing of a
CDATA . |
protected org.w3c.dom.Comment |
printComment(FormatStack fstack,
org.w3c.dom.Document basedoc,
Comment comment)
This will handle printing of a
Comment . |
protected void |
printContent(FormatStack fstack,
NamespaceStack nstack,
org.w3c.dom.Document basedoc,
org.w3c.dom.Node target,
Walker walker)
This will handle printing of a List of
Content . |
protected org.w3c.dom.Document |
printDocument(FormatStack fstack,
NamespaceStack nstack,
org.w3c.dom.Document basedoc,
Document doc)
This will handle printing of a
Document . |
protected org.w3c.dom.Element |
printElement(FormatStack fstack,
NamespaceStack nstack,
org.w3c.dom.Document basedoc,
Element element)
This will handle printing of an
Element . |
protected org.w3c.dom.EntityReference |
printEntityRef(FormatStack fstack,
org.w3c.dom.Document basedoc,
EntityRef entity)
This will handle printing of an
EntityRef . |
protected org.w3c.dom.ProcessingInstruction |
printProcessingInstruction(FormatStack fstack,
org.w3c.dom.Document basedoc,
ProcessingInstruction pi)
This will handle printing of a
ProcessingInstruction . |
protected org.w3c.dom.Text |
printText(FormatStack fstack,
org.w3c.dom.Document basedoc,
Text text)
This will handle printing of a
Text . |
org.w3c.dom.Attr |
process(org.w3c.dom.Document basedoc,
Format format,
Attribute attribute)
This will convert the
using the given DOM
Document to create the resulting DOM Attr. |
org.w3c.dom.CDATASection |
process(org.w3c.dom.Document basedoc,
Format format,
CDATA cdata)
This will convert the
using the given DOM
Document to create the resulting DOM CDATASection. |
org.w3c.dom.Comment |
process(org.w3c.dom.Document basedoc,
Format format,
Comment comment)
This will convert the
using the given DOM
Document to create the resulting DOM Comment. |
org.w3c.dom.Document |
process(org.w3c.dom.Document basedoc,
Format format,
Document doc)
This will convert the
to the given DOM
Document. |
org.w3c.dom.Element |
process(org.w3c.dom.Document basedoc,
Format format,
Element element)
This will convert the
using the given DOM
Document to create the resulting DOM Element. |
org.w3c.dom.EntityReference |
process(org.w3c.dom.Document basedoc,
Format format,
EntityRef entity)
This will convert the
using the given DOM
Document to create the resulting DOM EntityReference. |
java.util.List<org.w3c.dom.Node> |
process(org.w3c.dom.Document basedoc,
Format format,
java.util.List<? extends Content> list)
This will convert the list of JDOM
using the
given DOM Document to create the resulting list of DOM Nodes. |
org.w3c.dom.ProcessingInstruction |
process(org.w3c.dom.Document basedoc,
Format format,
ProcessingInstruction pi)
This will convert the
using
the given DOM Document to create the resulting DOM ProcessingInstruction. |
org.w3c.dom.Text |
process(org.w3c.dom.Document basedoc,
Format format,
Text text)
This will convert the
using the given DOM
Document to create the resulting DOM Text. |
buildWalker
public org.w3c.dom.Document process(org.w3c.dom.Document basedoc, Format format, Document doc)
DOMOutputProcessor
Document
to the given DOM
Document.
process
in interface DOMOutputProcessor
basedoc
- The DOM document to use for the conversionformat
- Format
instance specifying output styledoc
- Document
to format.public org.w3c.dom.Element process(org.w3c.dom.Document basedoc, Format format, Element element)
DOMOutputProcessor
Element
using the given DOM
Document to create the resulting DOM Element.process
in interface DOMOutputProcessor
basedoc
- The DOM document to use for the conversionformat
- Format
instance specifying output styleelement
- Element
to format.public java.util.List<org.w3c.dom.Node> process(org.w3c.dom.Document basedoc, Format format, java.util.List<? extends Content> list)
DOMOutputProcessor
Content
using the
given DOM Document to create the resulting list of DOM Nodes.process
in interface DOMOutputProcessor
basedoc
- The DOM document to use for the conversionformat
- Format
instance specifying output stylelist
- JDOM Content
to convert.public org.w3c.dom.CDATASection process(org.w3c.dom.Document basedoc, Format format, CDATA cdata)
DOMOutputProcessor
CDATA
using the given DOM
Document to create the resulting DOM CDATASection.process
in interface DOMOutputProcessor
basedoc
- The DOM document to use for the conversionformat
- Format
instance specifying output stylecdata
- CDATA
to format.public org.w3c.dom.Text process(org.w3c.dom.Document basedoc, Format format, Text text)
DOMOutputProcessor
Text
using the given DOM
Document to create the resulting DOM Text.process
in interface DOMOutputProcessor
basedoc
- The DOM document to use for the conversionformat
- Format
instance specifying output styletext
- Text
to format.public org.w3c.dom.Comment process(org.w3c.dom.Document basedoc, Format format, Comment comment)
DOMOutputProcessor
Comment
using the given DOM
Document to create the resulting DOM Comment.process
in interface DOMOutputProcessor
basedoc
- The DOM document to use for the conversionformat
- Format
instance specifying output stylecomment
- Comment
to format.public org.w3c.dom.ProcessingInstruction process(org.w3c.dom.Document basedoc, Format format, ProcessingInstruction pi)
DOMOutputProcessor
ProcessingInstruction
using
the given DOM Document to create the resulting DOM ProcessingInstruction.process
in interface DOMOutputProcessor
basedoc
- The DOM document to use for the conversionformat
- Format
instance specifying output stylepi
- ProcessingInstruction
to format.public org.w3c.dom.EntityReference process(org.w3c.dom.Document basedoc, Format format, EntityRef entity)
DOMOutputProcessor
EntityRef
using the given DOM
Document to create the resulting DOM EntityReference.process
in interface DOMOutputProcessor
basedoc
- The DOM document to use for the conversionformat
- Format
instance specifying output styleentity
- EntityRef
to format.public org.w3c.dom.Attr process(org.w3c.dom.Document basedoc, Format format, Attribute attribute)
DOMOutputProcessor
Attribute
using the given DOM
Document to create the resulting DOM Attr.process
in interface DOMOutputProcessor
basedoc
- The DOM document to use for the conversionformat
- Format
instance specifying output styleattribute
- Attribute
to format.protected org.w3c.dom.Document printDocument(FormatStack fstack, NamespaceStack nstack, org.w3c.dom.Document basedoc, Document doc)
Document
.fstack
- the FormatStacknstack
- the NamespaceStackbasedoc
- The org.w3c.dom.Document for creating DOM Nodesdoc
- Document
to write.protected org.w3c.dom.ProcessingInstruction printProcessingInstruction(FormatStack fstack, org.w3c.dom.Document basedoc, ProcessingInstruction pi)
ProcessingInstruction
.fstack
- the FormatStackbasedoc
- The org.w3c.dom.Document for creating DOM Nodespi
- ProcessingInstruction
to write.protected org.w3c.dom.Comment printComment(FormatStack fstack, org.w3c.dom.Document basedoc, Comment comment)
Comment
.fstack
- the FormatStackbasedoc
- The org.w3c.dom.Document for creating DOM Nodescomment
- Comment
to write.protected org.w3c.dom.EntityReference printEntityRef(FormatStack fstack, org.w3c.dom.Document basedoc, EntityRef entity)
EntityRef
.fstack
- the FormatStackbasedoc
- The org.w3c.dom.Document for creating DOM Nodesentity
- EntotyRef
to write.protected org.w3c.dom.CDATASection printCDATA(FormatStack fstack, org.w3c.dom.Document basedoc, CDATA cdata)
CDATA
.fstack
- the FormatStackbasedoc
- The org.w3c.dom.Document for creating DOM Nodescdata
- CDATA
to write.protected org.w3c.dom.Text printText(FormatStack fstack, org.w3c.dom.Document basedoc, Text text)
Text
.fstack
- the FormatStackbasedoc
- The org.w3c.dom.Document for creating DOM Nodestext
- Text
to write.protected org.w3c.dom.Attr printAttribute(FormatStack fstack, org.w3c.dom.Document basedoc, Attribute attribute)
Attribute
.fstack
- the FormatStackbasedoc
- The org.w3c.dom.Document for creating DOM Nodesattribute
- Attribute
to write.protected org.w3c.dom.Element printElement(FormatStack fstack, NamespaceStack nstack, org.w3c.dom.Document basedoc, Element element)
Element
.
This method arranges for outputting the Element infrastructure including Namespace Declarations and Attributes.
The actual formatting of the content is managed by the Walker created for the Element's content.
fstack
- the FormatStacknstack
- the NamespaceStackbasedoc
- The org.w3c.dom.Document for creating DOM Nodeselement
- Element
to write.protected void printContent(FormatStack fstack, NamespaceStack nstack, org.w3c.dom.Document basedoc, org.w3c.dom.Node target, Walker walker)
Content
. Uses the Walker
to ensure formatting.fstack
- the FormatStacknstack
- the NamespaceStackbasedoc
- The org.w3c.dom.Document for creating DOM Nodestarget
- the DOM node this content should be appended to.walker
- List
of Content
to write.protected org.w3c.dom.Node helperContentDispatcher(FormatStack fstack, NamespaceStack nstack, org.w3c.dom.Document basedoc, Content content)
fstack
- The current FormatStacknstack
- the NamespaceStackbasedoc
- The org.w3c.dom.Document for creating DOM Nodescontent
- The content to dispatchCopyright © 2021 Jason Hunter, Brett McLaughlin. All Rights Reserved.