Package org.jdom.output
Class DOMOutputter
- java.lang.Object
-
- org.jdom.output.DOMOutputter
-
public class DOMOutputter extends Object
Outputs a JDOMorg.jdom.Documentas a DOMorg.w3c.dom.Document. Also provides methods to output other types of JDOM Content in the equivalent DOM nodes.There are two versions of most functions, one that creates an independent DOM node using the DOMAdapter to create a new org.w3c.dom.Document. The other version creates the new DOM Nodes using the supplied org.w3c.dom.Document instance.
-
-
Constructor Summary
Constructors Constructor Description DOMOutputter()This creates a new DOMOutputter which will attempt to first locate a DOM implementation to use via JAXP, and if JAXP does not exist or there's a problem, will fall back to the default parser.DOMOutputter(String adapterClass)Deprecated.useDOMOutputter(DOMAdapter)instead.DOMOutputter(DOMAdapter adapter)This creates a new DOMOutputter using the specified DOMAdapter implementation as a way to choose the underlying parser.DOMOutputter(DOMAdapter adapter, Format format, DOMOutputProcessor processor)The complete constructor for specifying a custom DOMAdaptor, Format, and DOMOutputProcessor.DOMOutputter(DOMOutputProcessor processor)This creates a new DOMOutputter which uses the defalt (JAXP) DOM implementation but with a custom processor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DOMAdaptergetDOMAdapter()Get the DOMAdapter currently set for this DOMOutputter.DOMOutputProcessorgetDOMOutputProcessor()Get the current DOMOutputProcessorbooleangetForceNamespaceAware()Deprecated.All DOMOutputters are always NamesapceAware.FormatgetFormat()Get the Format instance currently used by this DOMOutputter.List<Node>output(List<? extends Content> list)This converts the JDOMAttributeparameter to a DOM Attr Node, returning the DOM version.Attroutput(Attribute attribute)This converts the JDOMAttributeparameter to a DOM Attr Node, returning the DOM version.CDATASectionoutput(CDATA cdata)This converts the JDOMCDATAparameter to a DOM CDATASection Node, returning the DOM version.Commentoutput(Comment comment)This converts the JDOMProcessingInstructionparameter to a DOM ProcessingInstruction, returning the DOM version.DocumentTypeoutput(DocType doctype)This converts the JDOMDocTypeparameter to a DOM DocumentType, returning the DOM version.Documentoutput(Document document)This converts the JDOMDocumentparameter to a DOM Document, returning the DOM version.Elementoutput(Element element)This converts the JDOMElementparameter to a DOM Element, returning the DOM version.EntityReferenceoutput(EntityRef entity)This converts the JDOMEntityRefparameter to a DOM EntityReference Node, returning the DOM version.ProcessingInstructionoutput(ProcessingInstruction pi)This converts the JDOMProcessingInstructionparameter to a DOM ProcessingInstruction, returning the DOM version.Textoutput(Text text)This converts the JDOMTextparameter to a DOM Text Node, returning the DOM version.List<Node>output(Document basedoc, List<? extends Content> list)This converts the list of JDOMContentin to a list of DOM Nodes, returning the DOM version.Attroutput(Document basedoc, Attribute attribute)This converts the JDOMAttributeparameter to a DOM Attr Node, returning the DOM version.CDATASectionoutput(Document basedoc, CDATA cdata)This converts the JDOMCDATAparameter to a DOM CDATASection Node, returning the DOM version.Commentoutput(Document basedoc, Comment comment)This converts the JDOMProcessingInstructionparameter to a DOM ProcessingInstruction, returning the DOM version.Elementoutput(Document basedoc, Element element)This converts the JDOMElementparameter to a DOM Element, returning the DOM version.EntityReferenceoutput(Document basedoc, EntityRef entity)This converts the JDOMEntityRefparameter to a DOM EntityReference Node, returning the DOM version.ProcessingInstructionoutput(Document basedoc, ProcessingInstruction pi)This converts the JDOMProcessingInstructionparameter to a DOM ProcessingInstruction, returning the DOM version.Textoutput(Document basedoc, Text text)This converts the JDOMTextparameter to a DOM Text Node, returning the DOM version.voidsetDOMAdapter(DOMAdapter adapter)Set the DOMAdapter currently set for this DOMOutputter.voidsetDOMOutputProcessor(DOMOutputProcessor processor)Set a new DOMOutputProcessor for this DOMOutputter.voidsetForceNamespaceAware(boolean flag)Deprecated.All DOMOutputters are now always NamespaceAware.voidsetFormat(Format format)Set a new Format instance for this DOMOutputter
-
-
-
Constructor Detail
-
DOMOutputter
public DOMOutputter()
This creates a new DOMOutputter which will attempt to first locate a DOM implementation to use via JAXP, and if JAXP does not exist or there's a problem, will fall back to the default parser.
-
DOMOutputter
public DOMOutputter(DOMOutputProcessor processor)
This creates a new DOMOutputter which uses the defalt (JAXP) DOM implementation but with a custom processor.- Parameters:
processor- the custom processor to use.- Since:
- JDOM2
-
DOMOutputter
public DOMOutputter(DOMAdapter adapter, Format format, DOMOutputProcessor processor)
The complete constructor for specifying a custom DOMAdaptor, Format, and DOMOutputProcessor.- Parameters:
adapter- The adapter to use to create the base Document instance (null implies the default).format- The output Format to use (null implies the default).processor- The custom mechanism for doing the output (null implies the default).- Since:
- JDOM2
-
DOMOutputter
@Deprecated public DOMOutputter(String adapterClass)
Deprecated.useDOMOutputter(DOMAdapter)instead.This creates a new DOMOutputter using the specified DOMAdapter implementation as a way to choose the underlying parser.- Parameters:
adapterClass-Stringname of class to use for DOM output- Throws:
IllegalArgumentException- if the adapter could not be instantiated. (it should be JDOMException, but that would require a change to this deprecated method's signature...
-
DOMOutputter
public DOMOutputter(DOMAdapter adapter)
This creates a new DOMOutputter using the specified DOMAdapter implementation as a way to choose the underlying parser.If the specified adapter is not thread-safe then the user should ensure that the adapter instance is never shared between multiple DOMOutputters. The default DOMAdapter
JAXPDOMAdapteris thread-safe.- Parameters:
adapter- the DOMAdapter instance to use for creating the base org.w3c.dom.Document Specify the null value to get the default adapter.- Since:
- JDOM2
-
-
Method Detail
-
getDOMAdapter
public DOMAdapter getDOMAdapter()
Get the DOMAdapter currently set for this DOMOutputter.- Returns:
- the current DOMAdapter.
- Since:
- JDOM2
-
setDOMAdapter
public void setDOMAdapter(DOMAdapter adapter)
Set the DOMAdapter currently set for this DOMOutputter.- Parameters:
adapter- the new DOMAdapter to use (null implies the default).- Since:
- JDOM2
-
getFormat
public Format getFormat()
Get the Format instance currently used by this DOMOutputter.- Returns:
- the current Format instance
- Since:
- JDOM2
-
setFormat
public void setFormat(Format format)
Set a new Format instance for this DOMOutputter- Parameters:
format- the new Format instance to use (null implies the default)- Since:
- JDOM2
-
getDOMOutputProcessor
public DOMOutputProcessor getDOMOutputProcessor()
Get the current DOMOutputProcessor- Returns:
- the current DOMOutputProcessor
- Since:
- JDOM2
-
setDOMOutputProcessor
public void setDOMOutputProcessor(DOMOutputProcessor processor)
Set a new DOMOutputProcessor for this DOMOutputter.- Parameters:
processor- the new processor to set (null implies the default)- Since:
- JDOM2
-
setForceNamespaceAware
@Deprecated public void setForceNamespaceAware(boolean flag)
Deprecated.All DOMOutputters are now always NamespaceAware.Controls how NO_NAMESPACE nodes are handled. If true the outputter always creates a namespace aware DOM.- Parameters:
flag- true to force NamespaceAware
-
getForceNamespaceAware
@Deprecated public boolean getForceNamespaceAware()
Deprecated.All DOMOutputters are always NamesapceAware. Always true.Returns whether DOMs will be constructed with namespaces even when the source document has elements all in the empty namespace.- Returns:
- the forceNamespaceAware flag value
-
output
public Document output(Document document) throws JDOMException
This converts the JDOMDocumentparameter to a DOM Document, returning the DOM version. The DOM implementation is the one supplied by the current DOMAdapter.- Parameters:
document-Documentto output.- Returns:
- an
org.w3c.dom.Documentversion - Throws:
JDOMException- if output failed.
-
output
public DocumentType output(DocType doctype) throws JDOMException
This converts the JDOMDocTypeparameter to a DOM DocumentType, returning the DOM version. The DOM implementation is the one supplied by the current DOMAdapter.Unlike the other DOM Nodes, you cannot use a DOM Document to simply create a DOM DocumentType Node, it has to be created at the same time as the DOM Document instance. As a result, there is no version of this method that takes a DOM Document instance.
- Parameters:
doctype-DocTypeto output.- Returns:
- an
org.w3c.dom.DocumentTypeversion - Throws:
JDOMException- if output failed.- Since:
- JDOM2
-
output
public Element output(Element element) throws JDOMException
This converts the JDOMElementparameter to a DOM Element, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
element-Elementto output.- Returns:
- an
org.w3c.dom.Elementversion - Throws:
JDOMException- if output failed.
-
output
public Text output(Text text) throws JDOMException
This converts the JDOMTextparameter to a DOM Text Node, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
text-Textto output.- Returns:
- an
org.w3c.dom.Textversion - Throws:
JDOMException- if output failed.- Since:
- JDOM2
-
output
public CDATASection output(CDATA cdata) throws JDOMException
This converts the JDOMCDATAparameter to a DOM CDATASection Node, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
cdata-CDATAto output.- Returns:
- an
org.w3c.dom.CDATASectionversion - Throws:
JDOMException- if output failed.- Since:
- JDOM2
-
output
public ProcessingInstruction output(ProcessingInstruction pi) throws JDOMException
This converts the JDOMProcessingInstructionparameter to a DOM ProcessingInstruction, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
pi-ProcessingInstructionto output.- Returns:
- an
org.w3c.dom.Elementversion - Throws:
JDOMException- if output failed.- Since:
- JDOM2
-
output
public Comment output(Comment comment) throws JDOMException
This converts the JDOMProcessingInstructionparameter to a DOM ProcessingInstruction, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
comment-Commentto output.- Returns:
- an
org.w3c.dom.Commentversion - Throws:
JDOMException- if output failed.- Since:
- JDOM2
-
output
public EntityReference output(EntityRef entity) throws JDOMException
This converts the JDOMEntityRefparameter to a DOM EntityReference Node, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
entity-EntityRefto output.- Returns:
- an
org.w3c.dom.EntityReferenceversion - Throws:
JDOMException- if output failed.- Since:
- JDOM2
-
output
public Attr output(Attribute attribute) throws JDOMException
This converts the JDOMAttributeparameter to a DOM Attr Node, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
attribute-Attributeto output.- Returns:
- an
org.w3c.dom.Attrversion - Throws:
JDOMException- if output failed.- Since:
- JDOM2
-
output
public List<Node> output(List<? extends Content> list) throws JDOMException
This converts the JDOMAttributeparameter to a DOM Attr Node, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
list-Attributeto output.- Returns:
- an
org.w3c.dom.Attrversion - Throws:
JDOMException- if output failed.- Since:
- JDOM2
-
output
public Element output(Document basedoc, Element element) throws JDOMException
This converts the JDOMElementparameter to a DOM Element, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
basedoc- The DOM Document to use for creating DOM Nodes.element-Elementto output.- Returns:
- an
org.w3c.dom.Elementversion - Throws:
JDOMException- if output failed.- Since:
- JDOM2
-
output
public Text output(Document basedoc, Text text) throws JDOMException
This converts the JDOMTextparameter to a DOM Text Node, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
basedoc- The DOM Document to use for creating DOM Nodes.text-Textto output.- Returns:
- an
org.w3c.dom.Textversion - Throws:
JDOMException- if output failed.- Since:
- JDOM2
-
output
public CDATASection output(Document basedoc, CDATA cdata) throws JDOMException
This converts the JDOMCDATAparameter to a DOM CDATASection Node, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
basedoc- The DOM Document to use for creating DOM Nodes.cdata-CDATAto output.- Returns:
- an
org.w3c.dom.CDATASectionversion - Throws:
JDOMException- if output failed.- Since:
- JDOM2
-
output
public ProcessingInstruction output(Document basedoc, ProcessingInstruction pi) throws JDOMException
This converts the JDOMProcessingInstructionparameter to a DOM ProcessingInstruction, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
basedoc- The DOM Document to use for creating DOM Nodes.pi-ProcessingInstructionto output.- Returns:
- an
org.w3c.dom.Elementversion - Throws:
JDOMException- if output failed.- Since:
- JDOM2
-
output
public Comment output(Document basedoc, Comment comment) throws JDOMException
This converts the JDOMProcessingInstructionparameter to a DOM ProcessingInstruction, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
basedoc- The DOM Document to use for creating DOM Nodes.comment-Commentto output.- Returns:
- an
org.w3c.dom.Commentversion - Throws:
JDOMException- if output failed.- Since:
- JDOM2
-
output
public EntityReference output(Document basedoc, EntityRef entity) throws JDOMException
This converts the JDOMEntityRefparameter to a DOM EntityReference Node, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
basedoc- The DOM Document to use for creating DOM Nodes.entity-EntityRefto output.- Returns:
- an
org.w3c.dom.EntityReferenceversion - Throws:
JDOMException- if output failed.- Since:
- JDOM2
-
output
public Attr output(Document basedoc, Attribute attribute) throws JDOMException
This converts the JDOMAttributeparameter to a DOM Attr Node, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
basedoc- The DOM Document to use for creating DOM Nodes.attribute-Attributeto output.- Returns:
- an
org.w3c.dom.Attrversion - Throws:
JDOMException- if output failed.- Since:
- JDOM2
-
output
public List<Node> output(Document basedoc, List<? extends Content> list) throws JDOMException
This converts the list of JDOMContentin to a list of DOM Nodes, returning the DOM version. The DOM Node will be linked to an independent DOM Document instance supplied by the current DOMAdapter- Parameters:
basedoc- The DOM Document to use for creating DOM Nodes.list- of JDOM Content to output.- Returns:
- a List of
org.w3c.dom.Node - Throws:
JDOMException- if output failed.- Since:
- JDOM2
-
-