com.jme.util.export.xml
Class DOMSerializer

java.lang.Object
  extended by com.jme.util.export.xml.DOMSerializer

public class DOMSerializer
extends java.lang.Object

The DOMSerializer was based primarily off the DOMSerializer.java class from the "Java and XML" 3rd Edition book by Brett McLaughlin, and Justin Edelson. Some modifications were made to support formatting of elements and attributes.

Version:
$Revision: 4207 $, $Date: 2009-03-29 16:19:16 +0100 (Sun, 29 Mar 2009) $
Author:
Brett McLaughlin, Justin Edelson - Original creation for "Java and XML" book., Doug Daniels (dougnukem) - adjustments for XML formatting

Constructor Summary
DOMSerializer()
           
 
Method Summary
 void serialize(org.w3c.dom.Document doc, java.io.File file)
          Serialize doc to out
 void serialize(org.w3c.dom.Document doc, java.io.OutputStream out)
          Serialize doc to out
 void serialize(org.w3c.dom.Document doc, java.io.Writer writer)
          Deprecated. this method does not set the encoding correctly.
 void setEncoding(java.lang.String encoding)
          Set the encoding used by this serializer.
 void setIndent(int indent)
          Set the number of spaces to use for indentation.
 void setLineSeparator(java.lang.String lineSeparator)
          Set the line separator that will be used when serializing documents.
 
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

serialize

public void serialize(org.w3c.dom.Document doc,
                      java.io.File file)
               throws java.io.IOException
Serialize doc to out

Parameters:
doc - the document to serialize.
file - the file to serialize to.
Throws:
java.io.IOException

serialize

public void serialize(org.w3c.dom.Document doc,
                      java.io.OutputStream out)
               throws java.io.IOException
Serialize doc to out

Parameters:
doc - the document to serialize.
out - the stream to serialize to.
Throws:
java.io.IOException

serialize

@Deprecated
public void serialize(org.w3c.dom.Document doc,
                                 java.io.Writer writer)
               throws java.io.IOException
Deprecated. this method does not set the encoding correctly.

Serialize doc to writer

Parameters:
doc - the document to serialize.
writer - the writer to serialize to.
Throws:
java.io.IOException

setEncoding

public void setEncoding(java.lang.String encoding)
Set the encoding used by this serializer.

Parameters:
encoding - the encoding to use, passing in null results in the default encoding (UTF-8) being set.
Throws:
IllegalCharsetNameException - if the given charset name is illegal.
UnsupportedCharsetException - if the given charset is not supported by the current JVM.

setIndent

public void setIndent(int indent)
Set the number of spaces to use for indentation.

The default is to use 4 spaces.

Parameters:
indent - the number of spaces to use for indentation, values less than or equal to zero result in no indentation being used.

setLineSeparator

public void setLineSeparator(java.lang.String lineSeparator)
Set the line separator that will be used when serializing documents.

If this is not called then the serializer uses a default based on the line.separator system property.

Parameters:
lineSeparator - the line separator to set.