Class DOMSerializer


  • public final class DOMSerializer
    extends java.lang.Object
    DOMImplementationLS backed implementation.
    Version:
    $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/xml/DOMSerializer.java#2 $
    Author:
    Harald Kuhr, last modified by $Author: haku $
    • Constructor Summary

      Constructors 
      Constructor Description
      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
      boolean getPrettyPrint()  
      void serialize​(org.w3c.dom.Document pDocument)
      Serializes the entire document.
      void serialize​(org.w3c.dom.Node pNode)
      Serializes the given node, along with any subnodes.
      void setPrettyPrint​(boolean pPrettyPrint)
      Specifies wether the serializer should use indentation and optimize for readability.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • 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 no DOMImplementation with 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 no DOMImplementation with 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 - true to enable pretty printing
      • getPrettyPrint

        public boolean getPrettyPrint()
      • 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.