org.apache.ecs.xml
Class XMLDocument

java.lang.Object
  |
  +--org.apache.ecs.xml.XMLDocument
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
VXMLDocument

public class XMLDocument
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

XMLDocument This is the container for XML elements that can be used similar to org.apache.ecs.Document. However, it correctly handles XML elements and doesn't have any notion of a head, body, etc., that is associated with HTML documents.

Author:
Brett McLaughlin
See Also:
Serialized Form

Field Summary
private  java.lang.String codeset
           
private  XML content
          "Body" of document
private static float DEFAULT_XML_VERSION
          Default Version
private  java.util.Vector prolog
          Prolog
private  java.lang.String versionDecl
          Version Declaration - FIXME!!
 
Constructor Summary
XMLDocument()
          This sets the document up.
XMLDocument(double version)
          This sets the document up.
XMLDocument(double version, boolean standalone)
          This sets the document up.
XMLDocument(double version, boolean standalone, java.lang.String codeset)
          This sets the document up.
 
Method Summary
 XMLDocument addElement(XML element)
          This adds an element to the XML document.
 XMLDocument addStylesheet(java.lang.String href)
          This adds a stylesheet to the XML document, and assumes the default text/xsl type.
 XMLDocument addStylesheet(java.lang.String href, java.lang.String type)
          This adds a stylesheet to the XML document.
 XMLDocument addToProlog(ConcreteElement element)
          This adds the specified element to the prolog of the document
 java.lang.Object clone()
          Clone this document
 java.lang.String getCodeset()
          This gets the codeset for this document
 void output(java.io.OutputStream out)
          Write the document to the OutputStream
 void output(java.io.PrintWriter out)
          Write the document to the PrintWriter
 void setCodeset(java.lang.String codeset)
          This sets the codeset for this document
 java.lang.String toString()
          Override toString so it does something useful
 java.lang.String toString(java.lang.String codeset)
          Override toString so it prints something useful
 
Methods inherited from class java.lang.Object
, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

DEFAULT_XML_VERSION

private static final float DEFAULT_XML_VERSION
Default Version

versionDecl

private java.lang.String versionDecl
Version Declaration - FIXME!!

prolog

private java.util.Vector prolog
Prolog

content

private XML content
"Body" of document

codeset

private java.lang.String codeset
Constructor Detail

XMLDocument

public XMLDocument()
This sets the document up. Since an XML document can be pretty much anything you want, all it does is create an XML Instruction for the default version and sets the document to be standalone.

XMLDocument

public XMLDocument(double version)
This sets the document up. Since an XML document can be pretty much anything, all this does is create the XML Instruction for the version specified and set the document to be standalone.
Parameters:
version - - version of XML this document is

XMLDocument

public XMLDocument(double version,
                   boolean standalone)
This sets the document up. Since an XML document can be pretty much anything, all this does is create the XML Instruction with the version specified, and identifies the document as standalone if set
Parameters:
version - - version of XML document is
standalone - - boolean: true if standalone, else false

XMLDocument

public XMLDocument(double version,
                   boolean standalone,
                   java.lang.String codeset)
This sets the document up. Since an XML document can be pretty much anything, all this does is create the XML Instruction with the version specified, and identifies the document as standalone if set. This also allows the codeset to be set as well.
Parameters:
version - - version of XML document is
standalone - - boolean: truecodeset - - String codeset to use
Method Detail

setCodeset

public void setCodeset(java.lang.String codeset)
This sets the codeset for this document
Parameters:
codeset - - String representation of codeset for this document

getCodeset

public java.lang.String getCodeset()
This gets the codeset for this document
Returns:
String the codeset for this document

addStylesheet

public XMLDocument addStylesheet(java.lang.String href,
                                 java.lang.String type)
This adds a stylesheet to the XML document.
Parameters:
href - - String reference to stylesheet
type - - String type of stylesheet

addStylesheet

public XMLDocument addStylesheet(java.lang.String href)
This adds a stylesheet to the XML document, and assumes the default text/xsl type.
Parameters:
href - = String reference to stylesheet

addToProlog

public XMLDocument addToProlog(ConcreteElement element)
This adds the specified element to the prolog of the document
Parameters:
element - - Element to add

addElement

public XMLDocument addElement(XML element)
This adds an element to the XML document. If the document is empty, it sets the passed in element as the root element.
Parameters:
element - - XML Element to add
Returns:
XMLDocument - modified document

output

public void output(java.io.OutputStream out)
Write the document to the OutputStream
Parameters:
out - - OutputStream to write to

output

public void output(java.io.PrintWriter out)
Write the document to the PrintWriter
Parameters:
out - - PrintWriter to write to

toString

public final java.lang.String toString()
Override toString so it does something useful
Overrides:
toString in class java.lang.Object
Returns:
String - representation of the document

toString

public final java.lang.String toString(java.lang.String codeset)
Override toString so it prints something useful
Parameters:
codeset - - String codeset to use
Returns:
String - representation of the document

clone

public java.lang.Object clone()
Clone this document
Overrides:
clone in class java.lang.Object
Returns:
Object - cloned XMLDocument


Copyright © 1999-2003 Apache Software Foundation. All Rights Reserved.