org.n52.security.common.xml
Class DOMSerializer

java.lang.Object
  extended by org.n52.security.common.xml.DOMSerializer

public abstract class DOMSerializer
extends Object

Utility calls responsible for serializing xml documents to output streams.

Usage:

Use DOMSerializer.createNew() to create a new instance of a DOMSerializier and then use one of the serialize methods.

A DOMSerializer shall be never hold as member variable, please create them only local.

Version:
$Revision: $
Author:
Marko Reiprecht Created on 24.03.2008

Constructor Summary
DOMSerializer()
           
 
Method Summary
static DOMSerializer createNew()
           
static DOMSerializer createNew(DOMSerializerOptions options)
           
protected static Transformer createTransformer(DOMSerializerOptions options)
          Creates a new copy Transformer.
static Document removeIndentTextNodes(Document document)
          Removes the indent text nodes from the dom tree.
 void serialize(Document document, OutputStream out)
          Serializes the document to the output stream.
 void serialize(Document document, Writer out)
          Serializes the xml document to the writer.
abstract  void serialize(Node node, OutputStream out)
          Serializes the node to the output stream.
abstract  void serialize(Node node, Writer out)
          Serializes the xml node to the writer.
 byte[] serializeToBytes(Document document)
          Converts the document to a byte[].
 byte[] serializeToBytes(Node node)
          Converts the node to a byte[].
 String serializeToString(Document document)
          Converts the document to a String.
 String serializeToString(Node node)
          Converts the node to a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMSerializer

public DOMSerializer()
Method Detail

createNew

public static DOMSerializer createNew()

createNew

public static DOMSerializer createNew(DOMSerializerOptions options)

createTransformer

protected static Transformer createTransformer(DOMSerializerOptions options)
                                        throws DOMSerializerException
Creates a new copy Transformer.

Parameters:
options - the options.
Returns:
Transformer.
Throws:
DOMSerializerException - if the copy transformer can't be created.

removeIndentTextNodes

public static Document removeIndentTextNodes(Document document)
Removes the indent text nodes from the dom tree.

The semantic of this "cleanup" method is to remove any text nodes, which has element silblings. So if the xml schemata contains nodes, which support "mixed-content" this method removes the mixed-content text nodes. Please use this method only in Situations where you know that the algorithm works.

Parameters:
document - the document.
Returns:
Document.

serialize

public void serialize(Document document,
                      Writer out)
               throws DOMSerializerException
Serializes the xml document to the writer.

Throws:
DOMSerializerException - if error occurs.

serialize

public void serialize(Document document,
                      OutputStream out)
               throws DOMSerializerException
Serializes the document to the output stream.

Throws:
DOMSerializerException - if error occurs.

serializeToBytes

public byte[] serializeToBytes(Document document)
                        throws DOMSerializerException
Converts the document to a byte[].

Throws:
DOMSerializerException - if error occurs.

serializeToBytes

public byte[] serializeToBytes(Node node)
                        throws DOMSerializerException
Converts the node to a byte[].

Throws:
DOMSerializerException - if error occurs.

serialize

public abstract void serialize(Node node,
                               OutputStream out)
                        throws DOMSerializerException
Serializes the node to the output stream.

Throws:
DOMSerializerException - if error occurs.

serializeToString

public String serializeToString(Document document)
                         throws DOMSerializerException
Converts the document to a String.

Throws:
DOMSerializerException - if error occurs.

serializeToString

public String serializeToString(Node node)
                         throws DOMSerializerException
Converts the node to a String.

Throws:
DOMSerializerException - if error occurs.

serialize

public abstract void serialize(Node node,
                               Writer out)
                        throws DOMSerializerException
Serializes the xml node to the writer.

Throws:
DOMSerializerException - if error occurs.


Copyright © 2004–2014 52north.org. All rights reserved.