jimm.twice.xml.dom
Class Document

java.lang.Object
  extended byjimm.twice.xml.dom.Document

public class Document
extends java.lang.Object

This is a simple document class that only supports what we need. For example, there is no epilogue (misc. tags after the close of the root node).

To turn the document into an XML string, call toString.

Author:
Jim Menard, jimm@io.com

Field Summary
protected  Doctype doctype
           
protected  java.util.ArrayList prolog
           
protected  Node rootNode
           
 
Constructor Summary
Document()
          Constructor.
 
Method Summary
 void addToProlog(Element element)
          Add element to prolog.
 Node getRootNode()
           
 Node setRoot(Element element)
          Creates a new node using the specified element, makes that node the root of the document, and returns the node.
 void setRootNode(Node node)
           
 java.lang.String toString()
           
 void writeTo(java.io.OutputStream out)
          Writes this document as XML to the specified OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

prolog

protected java.util.ArrayList prolog

doctype

protected Doctype doctype

rootNode

protected Node rootNode
Constructor Detail

Document

public Document()
Constructor.

Method Detail

addToProlog

public void addToProlog(Element element)
Add element to prolog. All syntax checks have already been made by the parser.


getRootNode

public Node getRootNode()

setRootNode

public void setRootNode(Node node)

setRoot

public Node setRoot(Element element)
Creates a new node using the specified element, makes that node the root of the document, and returns the node.

Parameters:
element - an XML element
Returns:
the new node

writeTo

public void writeTo(java.io.OutputStream out)
             throws java.io.IOException
Writes this document as XML to the specified OutputStream.

Parameters:
out - a OutputStream
Throws:
java.io.IOException

toString

public java.lang.String toString()