Package com.twelvemonkeys.xml
Class DOMSerializer
- java.lang.Object
-
- com.twelvemonkeys.xml.DOMSerializer
-
public final class DOMSerializer extends java.lang.ObjectDOMImplementationLSbacked implementation.- Version:
- $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/xml/DOMSerializer.java#2 $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classDOMSerializer.Support
-
Field Summary
Fields Modifier and Type Field Description private org.w3c.dom.ls.LSOutputoutputprivate static java.lang.StringPARAM_PRETTY_PRINTprivate static java.lang.StringPARAM_XML_DECLARATIONprivate org.w3c.dom.ls.LSSerializerserializer
-
Constructor Summary
Constructors Modifier Constructor Description privateDOMSerializer()DOMSerializer(java.io.OutputStream pStream, java.lang.String pEncoding)Creates a serializer using the given byte stream and encoding.DOMSerializer(java.io.Writer pStream)Creates a serializer using the given character stream and encoding.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleangetPrettyPrint()voidserialize(org.w3c.dom.Document pDocument)Serializes the entire document.voidserialize(org.w3c.dom.Node pNode)Serializes the given node, along with any subnodes.private voidserializeImpl(org.w3c.dom.Node pNode, boolean pOmitDecl)voidsetPrettyPrint(boolean pPrettyPrint)Specifies wether the serializer should use indentation and optimize for readability.private voidsetXMLDeclaration(boolean pXMLDeclaration)
-
-
-
Field Detail
-
PARAM_PRETTY_PRINT
private static final java.lang.String PARAM_PRETTY_PRINT
- See Also:
- Constant Field Values
-
PARAM_XML_DECLARATION
private static final java.lang.String PARAM_XML_DECLARATION
- See Also:
- Constant Field Values
-
serializer
private final org.w3c.dom.ls.LSSerializer serializer
-
output
private final org.w3c.dom.ls.LSOutput output
-
-
Constructor Detail
-
DOMSerializer
private DOMSerializer()
-
DOMSerializer
public DOMSerializer(java.io.OutputStream pStream, java.lang.String pEncoding)Creates a serializer using the given byte stream and encoding.- Parameters:
pStream- the byte stream.pEncoding- the encoding.- Throws:
java.lang.IllegalStateException- if noDOMImplementationwith the right features can be instantiated.
-
DOMSerializer
public DOMSerializer(java.io.Writer pStream)
Creates a serializer using the given character stream and encoding.- Parameters:
pStream- the characted stream.- Throws:
java.lang.IllegalStateException- if noDOMImplementationwith the right features can be instantiated.
-
-
Method Detail
-
setPrettyPrint
public void setPrettyPrint(boolean pPrettyPrint)
Specifies wether the serializer should use indentation and optimize for readability.Note: This is a hint, and may be ignored by DOM implementations.
- Parameters:
pPrettyPrint-trueto enable pretty printing
-
getPrettyPrint
public boolean getPrettyPrint()
-
setXMLDeclaration
private void setXMLDeclaration(boolean pXMLDeclaration)
-
serialize
public void serialize(org.w3c.dom.Document pDocument)
Serializes the entire document.- Parameters:
pDocument- the document.
-
serialize
public void serialize(org.w3c.dom.Node pNode)
Serializes the given node, along with any subnodes. Will not emit XML declaration.- Parameters:
pNode- the top node.
-
serializeImpl
private void serializeImpl(org.w3c.dom.Node pNode, boolean pOmitDecl)
-
-