org.n52.security.common.xml
Class DOMSerializer

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

public abstract class DOMSerializer
extends java.lang.Object

Class DOMSerializer is a small 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()
          Method creates a new DOMSerializer.
static DOMSerializer createNew(DOMSerializerOptions options)
          Method creates a new DOMSerializer.
protected static javax.xml.transform.Transformer createTransformer(DOMSerializerOptions options)
          Method creates a new copy Transformer.
static org.w3c.dom.Document removeIndentTextNodes(org.w3c.dom.Document document)
          Method removes the indent text nodes from the dom tree.
 void serialize(org.w3c.dom.Document document, java.io.OutputStream out)
          Method serializes the document to the output stream.
 void serialize(org.w3c.dom.Document document, java.io.Writer out)
          Method serializes the xml document to the writer.
abstract  void serialize(org.w3c.dom.Node node, java.io.OutputStream out)
          Method serializes the node to the output stream.
abstract  void serialize(org.w3c.dom.Node node, java.io.Writer out)
          Method serializes the xml node to the writer.
 byte[] serializeToBytes(org.w3c.dom.Document document)
          Method serializeToBytes converts the document to a byte[].
 byte[] serializeToBytes(org.w3c.dom.Node node)
          Method serializeToBytes converts the node to a byte[].
 java.lang.String serializeToString(org.w3c.dom.Document document)
          Method serializeToString converts the document to a string.
 java.lang.String serializeToString(org.w3c.dom.Node node)
          Method serializeToString 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()
Method creates a new DOMSerializer.

Returns:
DOMSerializer.

createNew

public static DOMSerializer createNew(DOMSerializerOptions options)
Method creates a new DOMSerializer.

Parameters:
options - the options.
Returns:
DOMSerializer.

createTransformer

protected static javax.xml.transform.Transformer createTransformer(DOMSerializerOptions options)
                                                            throws DOMSerializerException
Method creates a new copy Transformer.

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

removeIndentTextNodes

public static org.w3c.dom.Document removeIndentTextNodes(org.w3c.dom.Document document)
Method 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(org.w3c.dom.Document document,
                      java.io.Writer out)
               throws DOMSerializerException
Method serializes the xml document to the writer.

Parameters:
document - the document.
out - the out.
Throws:
DOMSerializerException - if error occurs.

serialize

public void serialize(org.w3c.dom.Document document,
                      java.io.OutputStream out)
               throws DOMSerializerException
Method serializes the document to the output stream.

Parameters:
document - the document.
out - the out.
Throws:
DOMSerializerException - if error occurs.

serializeToBytes

public byte[] serializeToBytes(org.w3c.dom.Document document)
                        throws DOMSerializerException
Method serializeToBytes converts the document to a byte[].

Parameters:
document - the document.
Returns:
byte[].
Throws:
DOMSerializerException - if error occurs.

serializeToBytes

public byte[] serializeToBytes(org.w3c.dom.Node node)
                        throws DOMSerializerException
Method serializeToBytes converts the node to a byte[].

Parameters:
node - the node.
Returns:
byte[].
Throws:
DOMSerializerException - if error occurs.

serialize

public abstract void serialize(org.w3c.dom.Node node,
                               java.io.OutputStream out)
                        throws DOMSerializerException
Method serializes the node to the output stream.

Parameters:
node - the dom node.
out - the out.
Throws:
DOMSerializerException - if error occurs.

serializeToString

public java.lang.String serializeToString(org.w3c.dom.Document document)
                                   throws DOMSerializerException
Method serializeToString converts the document to a string.

Parameters:
document - the document.
Returns:
String.
Throws:
DOMSerializerException - if error occurs.

serializeToString

public java.lang.String serializeToString(org.w3c.dom.Node node)
                                   throws DOMSerializerException
Method serializeToString converts the node to a string.

Parameters:
node - the node.
Returns:
String.
Throws:
DOMSerializerException - if error occurs.

serialize

public abstract void serialize(org.w3c.dom.Node node,
                               java.io.Writer out)
                        throws DOMSerializerException
Method serializes the xml node to the writer.

Parameters:
node - the dom node.
out - the out.
Throws:
DOMSerializerException - if error occurs.


Copyright © 2004-2009 52north.org. All Rights Reserved.