com.skaringa.javaxml.handler.dom
Class DOMOutputHandler

java.lang.Object
  extended by com.skaringa.javaxml.handler.AbstractDocumentOutputHandler
      extended by com.skaringa.javaxml.handler.dom.DOMOutputHandler
All Implemented Interfaces:
DocumentOutputHandlerInterface

public final class DOMOutputHandler
extends AbstractDocumentOutputHandler
implements DocumentOutputHandlerInterface

A concrete DocumentOutputHandlerInterface. It writes the output events to a DOM tree. It is used for serialization of Java objects into XML documents.


Constructor Summary
DOMOutputHandler()
          Construct a new DOMOutputHandler.
DOMOutputHandler(org.w3c.dom.Document doc)
          Construct a new DOMOutputHandler with a given document.
DOMOutputHandler(org.w3c.dom.Document doc, org.w3c.dom.Element elem)
          Construct a new DOMOutputHandler with a given document and element.
 
Method Summary
 void appendText(java.lang.String text)
          Append text to the current element.
 void endDocument()
          End the document.
 void endElement(java.lang.String name)
          End the current element.
 org.w3c.dom.Document getDocument()
          Get the document.
 void startDocument()
          Start a new document.
 void startElement(java.lang.String name)
          Start a new element without attributes at the current element.
 void startElement(java.lang.String name, org.xml.sax.Attributes attrs)
          Start a new element at the current element.
 
Methods inherited from class com.skaringa.javaxml.handler.AbstractDocumentOutputHandler
appendNamespaceDeclarations, getProperties, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.skaringa.javaxml.handler.DocumentOutputHandlerInterface
getProperties, setProperties
 

Constructor Detail

DOMOutputHandler

public DOMOutputHandler(org.w3c.dom.Document doc,
                        org.w3c.dom.Element elem)
Construct a new DOMOutputHandler with a given document and element. This allows to insert the result of the serialization into an existing document.

Parameters:
doc - The DOM document.
elem - The parent element to insert output below.

DOMOutputHandler

public DOMOutputHandler(org.w3c.dom.Document doc)
Construct a new DOMOutputHandler with a given document. The result of the serialization is inserted below its root element.

Parameters:
doc - The DOM document.

DOMOutputHandler

public DOMOutputHandler()
Construct a new DOMOutputHandler. A new DOM document is created during serialization.

Method Detail

getDocument

public org.w3c.dom.Document getDocument()
Get the document.

Returns:
The DOM document.

startDocument

public void startDocument()
Description copied from interface: DocumentOutputHandlerInterface
Start a new document.

Specified by:
startDocument in interface DocumentOutputHandlerInterface
See Also:
DocumentOutputHandlerInterface.startDocument()

endDocument

public void endDocument()
Description copied from interface: DocumentOutputHandlerInterface
End the document.

Specified by:
endDocument in interface DocumentOutputHandlerInterface
See Also:
DocumentOutputHandlerInterface.endDocument()

startElement

public void startElement(java.lang.String name,
                         org.xml.sax.Attributes attrs)
Description copied from interface: DocumentOutputHandlerInterface
Start a new element at the current element.

Specified by:
startElement in interface DocumentOutputHandlerInterface
Parameters:
name - The name of the element.
attrs - The attributes of the element.
See Also:
DocumentOutputHandlerInterface.startElement(String, Attributes)

startElement

public void startElement(java.lang.String name)
Description copied from interface: DocumentOutputHandlerInterface
Start a new element without attributes at the current element.

Specified by:
startElement in interface DocumentOutputHandlerInterface
Parameters:
name - The name of the element.
See Also:
DocumentOutputHandlerInterface.startElement(String)

appendText

public void appendText(java.lang.String text)
Description copied from interface: DocumentOutputHandlerInterface
Append text to the current element.

Specified by:
appendText in interface DocumentOutputHandlerInterface
Parameters:
text - The text to append.
See Also:
DocumentOutputHandlerInterface.appendText(String)

endElement

public void endElement(java.lang.String name)
Description copied from interface: DocumentOutputHandlerInterface
End the current element.

Specified by:
endElement in interface DocumentOutputHandlerInterface
Parameters:
name - The name of the element.
See Also:
DocumentOutputHandlerInterface.endElement(String)