proper.xml
Class Document

java.lang.Object
  extended by proper.xml.Document
All Implemented Interfaces:
java.lang.Cloneable

public class Document
extends java.lang.Object
implements java.lang.Cloneable

A simple XML document. Just for representing a simple tree-structure. Validating can be set to TRUE, but an internal DOCTYPE is not retrieved

Version:
$Revision: 1.2 $
Author:
FracPete
See Also:
setValidate(boolean), getDoctype()

Constructor Summary
Document()
          initializes the document with empty processing instructions and a "root" root node
Document(Document doc)
          initializes the object with the given Document
Document(java.lang.String pi)
          initializes the object with the given processing instructions and a "root" root node
Document(java.lang.String pi, Element root)
          initializes the object with the given processing instructions and root
 
Method Summary
 void clear()
          clears the document
 java.lang.Object clone()
          returns a copy of this object (warnings or errors are not cloned!)
 java.lang.String getDoctype()
          returns the DOCTYPE definition, unfortunately it is not set from a read file (must be set manually again before saving)
 java.util.Vector getErrors()
          returns errors, if any, from previous parse (of type SAXParseException)
 java.lang.String getPI()
          returns the processing instructions
 Element getRoot()
          returns the root node, the node that contains the PI, DOCTYPE (actual) root-node
 boolean getValidate()
          returns whether we validate the parsing or not
 java.util.Vector getWarnings()
          returns the warnings, if any, from previous parse (of type SAXParseException)
 boolean hasErrors()
          returns whether any errors happened during the last parse
 boolean hasWarnings()
          whether there were any warning during the previous parse
static void main(java.lang.String[] args)
          for testing only
 boolean read(java.io.Reader reader)
          reads the XML data from the given reader, returns TRUE if successful (if any error happened during parsing, FALSE is returned!)
 boolean read(java.lang.String filename)
          reads the given file, returns TRUE if successful
 void setDoctype(java.lang.String doctype)
          sets the DOCTYPE definition
 void setPI(java.lang.String pi)
          sets the processing instructions
 void setRoot(Element root)
          sets the root node
 void setValidate(boolean validate)
          sets whether we validate the parsing or not
 java.lang.String toString()
          returns the document in a string representation
 boolean write(java.lang.String filename)
          writes the document to the given file, returns TRUE if it succeeds
 boolean write(java.io.Writer writer)
          writes the document to the given Writer, returns TRUE if it succeeds
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Document

public Document()
initializes the document with empty processing instructions and a "root" root node


Document

public Document(java.lang.String pi)
initializes the object with the given processing instructions and a "root" root node


Document

public Document(java.lang.String pi,
                Element root)
initializes the object with the given processing instructions and root


Document

public Document(Document doc)
initializes the object with the given Document

Method Detail

clone

public java.lang.Object clone()
returns a copy of this object (warnings or errors are not cloned!)

Overrides:
clone in class java.lang.Object

clear

public void clear()
clears the document


setPI

public void setPI(java.lang.String pi)
sets the processing instructions


getPI

public java.lang.String getPI()
returns the processing instructions


setDoctype

public void setDoctype(java.lang.String doctype)
sets the DOCTYPE definition


getDoctype

public java.lang.String getDoctype()
returns the DOCTYPE definition, unfortunately it is not set from a read file (must be set manually again before saving)


setValidate

public void setValidate(boolean validate)
sets whether we validate the parsing or not


getValidate

public boolean getValidate()
returns whether we validate the parsing or not


setRoot

public void setRoot(Element root)
sets the root node


getRoot

public Element getRoot()
returns the root node, the node that contains the PI, DOCTYPE (actual) root-node


getErrors

public java.util.Vector getErrors()
returns errors, if any, from previous parse (of type SAXParseException)


hasErrors

public boolean hasErrors()
returns whether any errors happened during the last parse


getWarnings

public java.util.Vector getWarnings()
returns the warnings, if any, from previous parse (of type SAXParseException)


hasWarnings

public boolean hasWarnings()
whether there were any warning during the previous parse


write

public boolean write(java.lang.String filename)
writes the document to the given file, returns TRUE if it succeeds


write

public boolean write(java.io.Writer writer)
writes the document to the given Writer, returns TRUE if it succeeds


read

public boolean read(java.lang.String filename)
reads the given file, returns TRUE if successful


read

public boolean read(java.io.Reader reader)
reads the XML data from the given reader, returns TRUE if successful (if any error happened during parsing, FALSE is returned!)


toString

public java.lang.String toString()
returns the document in a string representation

Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
for testing only