CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.xml
Class JavaxDOMOutput

java.lang.Object
  extended by ch.randelshofer.xml.JavaxDOMOutput
All Implemented Interfaces:
DOMOutput

public class JavaxDOMOutput
extends java.lang.Object
implements DOMOutput

DOMOutput.

Version:
1.0 February 17, 2004 Created.
Author:
Werner Randelshofer

Constructor Summary
JavaxDOMOutput(DOMFactory factory)
          Creates a new instance.
 
Method Summary
 void addComment(java.lang.String comment)
          Adds a comment to the current element of the DOM Document.
 void addElement(java.lang.String tagName)
          Puts a new element into the DOM Document.
 void addText(java.lang.String text)
          Adds a text to current element of the DOM Document.
 void closeElement()
          Closes the current element of the DOM Document.
 void save(java.io.OutputStream out)
          Writes the contents of the DOMOutput into the specified output stream.
 void save(java.io.Writer out)
          Writes the contents of the DOMOutput into the specified output stream.
 void setAttribute(java.lang.String name, boolean value)
          Adds an attribute to current element of the DOM Document.
 void setAttribute(java.lang.String name, double value)
          Adds an attribute to current element of the DOM Document.
 void setAttribute(java.lang.String name, float value)
          Adds an attribute to current element of the DOM Document.
 void setAttribute(java.lang.String name, int value)
          Adds an attribute to current element of the DOM Document.
 void setAttribute(java.lang.String name, java.lang.String value)
          Adds an attribute to current element of the DOM Document.
 void writeObject(java.lang.Object o)
          Writes an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaxDOMOutput

public JavaxDOMOutput(DOMFactory factory)
               throws java.io.IOException
Creates a new instance.

Throws:
java.io.IOException
Method Detail

save

public void save(java.io.OutputStream out)
          throws java.io.IOException
Writes the contents of the DOMOutput into the specified output stream.

Throws:
java.io.IOException

save

public void save(java.io.Writer out)
          throws java.io.IOException
Writes the contents of the DOMOutput into the specified output stream.

Throws:
java.io.IOException

addElement

public void addElement(java.lang.String tagName)
Puts a new element into the DOM Document. The new element is added as a child to the current element in the DOM document. Then it becomes the current element. The element must be closed using closeElement.

Specified by:
addElement in interface DOMOutput

closeElement

public void closeElement()
Closes the current element of the DOM Document. The parent of the current element becomes the current element.

Specified by:
closeElement in interface DOMOutput
Throws:
java.lang.IllegalArgumentException - if the provided tagName does not match the tag name of the element.

addComment

public void addComment(java.lang.String comment)
Adds a comment to the current element of the DOM Document.

Specified by:
addComment in interface DOMOutput

addText

public void addText(java.lang.String text)
Adds a text to current element of the DOM Document. Note: Multiple consecutives texts will be merged.

Specified by:
addText in interface DOMOutput

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)
Adds an attribute to current element of the DOM Document.

Specified by:
setAttribute in interface DOMOutput

setAttribute

public void setAttribute(java.lang.String name,
                         int value)
Adds an attribute to current element of the DOM Document.

Specified by:
setAttribute in interface DOMOutput

setAttribute

public void setAttribute(java.lang.String name,
                         boolean value)
Adds an attribute to current element of the DOM Document.

Specified by:
setAttribute in interface DOMOutput

setAttribute

public void setAttribute(java.lang.String name,
                         float value)
Adds an attribute to current element of the DOM Document.

Specified by:
setAttribute in interface DOMOutput

setAttribute

public void setAttribute(java.lang.String name,
                         double value)
Adds an attribute to current element of the DOM Document.

Specified by:
setAttribute in interface DOMOutput

writeObject

public void writeObject(java.lang.Object o)
Description copied from interface: DOMOutput
Writes an object.

Specified by:
writeObject in interface DOMOutput

(c) Werner Randelshofer.
All rights reserved.