com.calitha.xml
Class DocumentXMLSerializer

java.lang.Object
  extended by com.calitha.xml.DocumentXMLSerializer
All Implemented Interfaces:
IDocumentXMLSerializer

public class DocumentXMLSerializer
extends Object
implements IDocumentXMLSerializer

This class reprents a serializer of Document objects to XML output.

The output can eiter be a Writer, OutputStream, File or String by using one of the overloaded serialize methods.

By default the serializer is configured to use these settings:

These settings can be overridden by using one of the setter methods.

Author:
Robert van Loenhout

Constructor Summary
DocumentXMLSerializer()
          Creates a document serializer.
 
Method Summary
 Charset getEncoding()
          Determines the encoding character set.
 boolean isIndenting()
          Determines if indenting will be used when formatting the output.
 boolean isNamespaces()
          Determines if namespaces are supported.
 boolean isPreserveSpace()
          Determines if space is preserved.
 String serialize(Document document)
          Serialized the document to a string.
 void serialize(File file, Document document)
          Serializes the document to a file.
 void serialize(OutputStream out, Document document)
          Serializes the document to an output stream.
 void serialize(Writer writer, Document document)
          Serialize the document to a writer.
 void setEncoding(Charset encoding)
          Sets the encoding character set.
 void setIndenting(boolean indenting)
          Setting this to true will cause indenting to be used when formatting the output.
 void setNamespaces(boolean namespaces)
          Sets the namespace support
 void setPreserveSpace(boolean preserveSpace)
          Setting this to true will make space be preserved.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentXMLSerializer

public DocumentXMLSerializer()
Creates a document serializer.

Method Detail

getEncoding

public Charset getEncoding()
Description copied from interface: IDocumentXMLSerializer
Determines the encoding character set.

Specified by:
getEncoding in interface IDocumentXMLSerializer
Returns:
character set

setEncoding

public void setEncoding(Charset encoding)
Description copied from interface: IDocumentXMLSerializer
Sets the encoding character set.

Specified by:
setEncoding in interface IDocumentXMLSerializer
Parameters:
encoding - character set

isPreserveSpace

public boolean isPreserveSpace()
Description copied from interface: IDocumentXMLSerializer
Determines if space is preserved.

Specified by:
isPreserveSpace in interface IDocumentXMLSerializer
Returns:
true if space is preserved

setPreserveSpace

public void setPreserveSpace(boolean preserveSpace)
Description copied from interface: IDocumentXMLSerializer
Setting this to true will make space be preserved.

Specified by:
setPreserveSpace in interface IDocumentXMLSerializer
Parameters:
preserveSpace - preserve space value

isNamespaces

public boolean isNamespaces()
Description copied from interface: IDocumentXMLSerializer
Determines if namespaces are supported.

Specified by:
isNamespaces in interface IDocumentXMLSerializer
Returns:
namespaces support

setNamespaces

public void setNamespaces(boolean namespaces)
Description copied from interface: IDocumentXMLSerializer
Sets the namespace support

Specified by:
setNamespaces in interface IDocumentXMLSerializer
Parameters:
namespaces - new namespaces support value

isIndenting

public boolean isIndenting()
Description copied from interface: IDocumentXMLSerializer
Determines if indenting will be used when formatting the output.

Specified by:
isIndenting in interface IDocumentXMLSerializer
Returns:
true if indenting is used

setIndenting

public void setIndenting(boolean indenting)
Description copied from interface: IDocumentXMLSerializer
Setting this to true will cause indenting to be used when formatting the output.

Specified by:
setIndenting in interface IDocumentXMLSerializer
Parameters:
indenting - indenting value

serialize

public void serialize(Writer writer,
                      Document document)
               throws IOException
Description copied from interface: IDocumentXMLSerializer
Serialize the document to a writer.

Specified by:
serialize in interface IDocumentXMLSerializer
Parameters:
writer - writer
document - document
Throws:
IOException - if an I/O error occurs

serialize

public void serialize(OutputStream out,
                      Document document)
               throws IOException
Description copied from interface: IDocumentXMLSerializer
Serializes the document to an output stream.

Specified by:
serialize in interface IDocumentXMLSerializer
Parameters:
out - output stream
document - document
Throws:
IOException - if an I/O error occurs

serialize

public void serialize(File file,
                      Document document)
               throws IOException
Description copied from interface: IDocumentXMLSerializer
Serializes the document to a file.

Specified by:
serialize in interface IDocumentXMLSerializer
Parameters:
file - file
document - document
Throws:
IOException - if an I/O error occurs

serialize

public String serialize(Document document)
                 throws IOException
Description copied from interface: IDocumentXMLSerializer
Serialized the document to a string.

Specified by:
serialize in interface IDocumentXMLSerializer
Parameters:
document - document
Returns:
string
Throws:
IOException - if an I/O error occurs