Class AbstractDOMOutputProcessor
- All Implemented Interfaces:
DOMOutputProcessor
DOMOutputProcessor
for supporting the DOMOutputter.
Overview
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.
The Stacks
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.
Content Processing
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.
- Since:
- JDOM2
- Author:
- Rolf Lear
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected NodehelperContentDispatcher(FormatStack fstack, NamespaceStack nstack, Document basedoc, Content content) This method contains code which is reused in a number of places.protected AttrprintAttribute(FormatStack fstack, Document basedoc, Attribute attribute) This will handle printing of aAttribute.protected CDATASectionprintCDATA(FormatStack fstack, Document basedoc, CDATA cdata) This will handle printing of aCDATA.protected CommentprintComment(FormatStack fstack, Document basedoc, Comment comment) This will handle printing of aComment.protected voidprintContent(FormatStack fstack, NamespaceStack nstack, Document basedoc, Node target, Walker walker) This will handle printing of a List ofContent.protected DocumentprintDocument(FormatStack fstack, NamespaceStack nstack, Document basedoc, Document doc) This will handle printing of aDocument.protected ElementprintElement(FormatStack fstack, NamespaceStack nstack, Document basedoc, Element element) This will handle printing of anElement.protected EntityReferenceprintEntityRef(FormatStack fstack, Document basedoc, EntityRef entity) This will handle printing of anEntityRef.protected ProcessingInstructionprintProcessingInstruction(FormatStack fstack, Document basedoc, ProcessingInstruction pi) This will handle printing of aProcessingInstruction.protected TextprintText(FormatStack fstack, Document basedoc, Text text) This will handle printing of aText.This will convert the list of JDOMusing the given DOM Document to create the resulting list of DOM Nodes.ContentThis will convert theusing the given DOM Document to create the resulting DOM Attr.AttributeThis will convert theusing the given DOM Document to create the resulting DOM CDATASection.CDATAThis will convert theusing the given DOM Document to create the resulting DOM Comment.CommentThis will convert theto the given DOM Document.DocumentThis will convert theusing the given DOM Document to create the resulting DOM Element.ElementThis will convert theusing the given DOM Document to create the resulting DOM EntityReference.EntityRefprocess(Document basedoc, Format format, ProcessingInstruction pi) This will convert theusing the given DOM Document to create the resulting DOM ProcessingInstruction.ProcessingInstructionThis will convert theusing the given DOM Document to create the resulting DOM Text.TextMethods inherited from class org.jdom2.output.support.AbstractOutputProcessor
buildWalker
-
Constructor Details
-
AbstractDOMOutputProcessor
public AbstractDOMOutputProcessor()
-
-
Method Details
-
process
Description copied from interface:DOMOutputProcessorThis will convert theto the given DOM Document.Document- Specified by:
processin interfaceDOMOutputProcessor- Parameters:
basedoc- The DOM document to use for the conversionformat-Formatinstance specifying output styledoc-Documentto format.- Returns:
- The same DOM Document as the input document, but with the JDOM content converted and added.
-
process
Description copied from interface:DOMOutputProcessorThis will convert theusing the given DOM Document to create the resulting DOM Element.Element- Specified by:
processin interfaceDOMOutputProcessor- Parameters:
basedoc- The DOM document to use for the conversionformat-Formatinstance specifying output styleelement-Elementto format.- Returns:
- The input JDOM Element converted to a DOM Element
-
process
Description copied from interface:DOMOutputProcessorThis will convert the list of JDOMusing the given DOM Document to create the resulting list of DOM Nodes.Content- Specified by:
processin interfaceDOMOutputProcessor- Parameters:
basedoc- The DOM document to use for the conversionformat-Formatinstance specifying output stylelist- JDOMContentto convert.- Returns:
- The input JDOM Content List converted to a List of DOM Nodes
-
process
Description copied from interface:DOMOutputProcessorThis will convert theusing the given DOM Document to create the resulting DOM CDATASection.CDATA- Specified by:
processin interfaceDOMOutputProcessor- Parameters:
basedoc- The DOM document to use for the conversionformat-Formatinstance specifying output stylecdata-CDATAto format.- Returns:
- The input JDOM CDATA converted to a DOM CDATASection
-
process
Description copied from interface:DOMOutputProcessorThis will convert theusing the given DOM Document to create the resulting DOM Text.Text- Specified by:
processin interfaceDOMOutputProcessor- Parameters:
basedoc- The DOM document to use for the conversionformat-Formatinstance specifying output styletext-Textto format.- Returns:
- The input JDOM Text converted to a DOM Text
-
process
Description copied from interface:DOMOutputProcessorThis will convert theusing the given DOM Document to create the resulting DOM Comment.Comment- Specified by:
processin interfaceDOMOutputProcessor- Parameters:
basedoc- The DOM document to use for the conversionformat-Formatinstance specifying output stylecomment-Commentto format.- Returns:
- The input JDOM Comment converted to a DOM Comment
-
process
Description copied from interface:DOMOutputProcessorThis will convert theusing the given DOM Document to create the resulting DOM ProcessingInstruction.ProcessingInstruction- Specified by:
processin interfaceDOMOutputProcessor- Parameters:
basedoc- The DOM document to use for the conversionformat-Formatinstance specifying output stylepi-ProcessingInstructionto format.- Returns:
- The input JDOM ProcessingInstruction converted to a DOM ProcessingInstruction
-
process
Description copied from interface:DOMOutputProcessorThis will convert theusing the given DOM Document to create the resulting DOM EntityReference.EntityRef- Specified by:
processin interfaceDOMOutputProcessor- Parameters:
basedoc- The DOM document to use for the conversionformat-Formatinstance specifying output styleentity-EntityRefto format.- Returns:
- The input JDOM EntityRef converted to a DOM EntityReference
-
process
Description copied from interface:DOMOutputProcessorThis will convert theusing the given DOM Document to create the resulting DOM Attr.Attribute- Specified by:
processin interfaceDOMOutputProcessor- Parameters:
basedoc- The DOM document to use for the conversionformat-Formatinstance specifying output styleattribute-Attributeto format.- Returns:
- The input JDOM Attribute converted to a DOM Attr
-
printDocument
protected Document printDocument(FormatStack fstack, NamespaceStack nstack, Document basedoc, Document doc) This will handle printing of aDocument.- Parameters:
fstack- the FormatStacknstack- the NamespaceStackbasedoc- The org.w3c.dom.Document for creating DOM Nodesdoc-Documentto write.- Returns:
- The input JDOM document converted to a DOM document.
-
printProcessingInstruction
protected ProcessingInstruction printProcessingInstruction(FormatStack fstack, Document basedoc, ProcessingInstruction pi) This will handle printing of aProcessingInstruction.- Parameters:
fstack- the FormatStackbasedoc- The org.w3c.dom.Document for creating DOM Nodespi-ProcessingInstructionto write.- Returns:
- The input JDOM ProcessingInstruction converted to a DOM ProcessingInstruction.
-
printComment
This will handle printing of aComment.- Parameters:
fstack- the FormatStackbasedoc- The org.w3c.dom.Document for creating DOM Nodescomment-Commentto write.- Returns:
- The input JDOM Comment converted to a DOM Comment
-
printEntityRef
This will handle printing of anEntityRef.- Parameters:
fstack- the FormatStackbasedoc- The org.w3c.dom.Document for creating DOM Nodesentity-EntotyRefto write.- Returns:
- The input JDOM EntityRef converted to a DOM EntityReference
-
printCDATA
This will handle printing of aCDATA.- Parameters:
fstack- the FormatStackbasedoc- The org.w3c.dom.Document for creating DOM Nodescdata-CDATAto write.- Returns:
- The input JDOM CDATA converted to a DOM CDATASection
-
printText
This will handle printing of aText.- Parameters:
fstack- the FormatStackbasedoc- The org.w3c.dom.Document for creating DOM Nodestext-Textto write.- Returns:
- The input JDOM Text converted to a DOM Text
-
printAttribute
This will handle printing of aAttribute.- Parameters:
fstack- the FormatStackbasedoc- The org.w3c.dom.Document for creating DOM Nodesattribute-Attributeto write.- Returns:
- The input JDOM Attribute converted to a DOM Attr
-
printElement
protected Element printElement(FormatStack fstack, NamespaceStack nstack, Document basedoc, Element element) This will handle printing of anElement.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.
- Parameters:
fstack- the FormatStacknstack- the NamespaceStackbasedoc- The org.w3c.dom.Document for creating DOM Nodeselement-Elementto write.- Returns:
- The input JDOM Element converted to a DOM Element
-
printContent
protected void printContent(FormatStack fstack, NamespaceStack nstack, Document basedoc, Node target, Walker walker) This will handle printing of a List ofContent. Uses the Walker to ensure formatting.- Parameters:
fstack- the FormatStacknstack- the NamespaceStackbasedoc- The org.w3c.dom.Document for creating DOM Nodestarget- the DOM node this content should be appended to.walker-ListofContentto write.
-
helperContentDispatcher
protected Node helperContentDispatcher(FormatStack fstack, NamespaceStack nstack, Document basedoc, Content content) This method contains code which is reused in a number of places. It simply determines what content is passed in, and dispatches it to the correct print* method.- Parameters:
fstack- The current FormatStacknstack- the NamespaceStackbasedoc- The org.w3c.dom.Document for creating DOM Nodescontent- The content to dispatch- Returns:
- the input JDOM Content converted to a DOM Node.
-