Main Page   Packages   Namespace List   Class Hierarchy   Compound List   Compound Members  

Document Class Reference

List of all members.

Public Methods

 Document (Element rootElement, DocType docType)
 Document (Element rootElement)
 Document (List newContent, DocType docType)
 Document (List content)
boolean hasRootElement ()
Element getRootElement ()
Document setRootElement (Element rootElement)
Element detachRootElement ()
DocType getDocType ()
Document setDocType (DocType docType)
Document addContent (ProcessingInstruction pi)
Document addContent (Comment comment)
List getContent ()
Document setContent (List newContent)
boolean removeContent (ProcessingInstruction pi)
boolean removeContent (Comment comment)
String toString ()
final boolean equals (Object ob)
final int hashCode ()
Object clone ()

Protected Methods

 Document ()

Protected Attributes

ContentList content = new ContentList(this)
DocType docType

Detailed Description

Document defines behavior for an XML Document, modeled in Java. Methods allow access to the root element as well as processing instructions and other document-level information.

Author:
Brett McLaughlin , Jason Hunter , Jools Enticknap , Bradley S. Huffman
Version:
Revision:
1.51
,
Date:
2002/02/13 16:58:47


Constructor & Destructor Documentation

Document::Document   [inline, protected]
 

Default, no-args constructor for implementations to use if needed.

Document::Document Element    rootElement,
DocType    docType
[inline]
 

This will create a new Document, with the supplied Element as the root element and the supplied DocType declaration.

Parameters:
rootElement  Element for document root.
docType  DocType declaration.

Document::Document Element    rootElement [inline]
 

This will create a new Document, with the supplied Element as the root element, and no DocType declaration.

Parameters:
rootElement  Element for document root

Document::Document List    newContent,
DocType    docType
[inline]
 

This will create a new Document, with the supplied list of content, and the supplied DocType declaration.

Parameters:
content  List of starter content
docType  DocType declaration.
Exceptions:
IllegalAddException  if (1) the List contains more than one Element or objects of illegal types, or (2) if the given docType object is already attached to a document.

Document::Document List    content [inline]
 

This will create a new Document, with the supplied list of content, and no DocType declaration.

Parameters:
content  List of starter content
Exceptions:
IllegalAddException  if the List contains more than one Element or objects of illegal types.


Member Function Documentation

Document Document::addContent Comment    comment [inline]
 

This will add a comment to the Document.

Parameters:
comment  Comment to add.
Returns:
Document - this object modified.
Exceptions:
IllegalAddException  if the given comment already has a parent element.

Document Document::addContent ProcessingInstruction    pi [inline]
 

Adds the specified PI to the document.

Parameters:
pi  the ProcessingInstruction to add.
Returns:
Document this document modified.
Exceptions:
IllegalAddException  if the given processing instruction already has a parent element.

Object Document::clone   [inline]
 

This will return a deep clone of this Document.

Returns:
Object - clone of this Document.

Element Document::detachRootElement   [inline]
 

Detach the root Element from this document.

Returns:
removed root Element

final boolean Document::equals Object    ob [inline]
 

This tests for equality of this Document to the supplied Object.

Parameters:
ob  Object to compare to.
Returns:
boolean - whether the Document is equal to the supplied Object.

List Document::getContent   [inline]
 

This will return all content for the Document. The returned list is "live" in document order and changes to it affect the document's actual content.

Returns:
List - all Document content
Exceptions:
IllegalStateException  if the root element hasn't been set

DocType Document::getDocType   [inline]
 

This will return the DocType declaration for this Document, or null if none exists.

Returns:
DocType - the DOCTYPE declaration.

Element Document::getRootElement   [inline]
 

This will return the root Element for this Document

Returns:
Element - the document's root element
Exceptions:
IllegalStateException  if the root element hasn't been set

final int Document::hashCode   [inline]
 

This returns the hash code for this Document.

Returns:
int - hash code.

boolean Document::hasRootElement   [inline]
 

This will return true if this document has a root element, false otherwise.

Returns:
true if this document has a root element, false otherwise.

boolean Document::removeContent Comment    comment [inline]
 

This removes the specified Comment. If the specified Comment is not a child of this Document, this method does nothing.

Parameters:
comment  Comment to delete
Returns:
whether deletion occurred

boolean Document::removeContent ProcessingInstruction    pi [inline]
 

This removes the specified ProcessingInstruction. If the specified ProcessingInstruction is not a child of this Document, this method does nothing.

Parameters:
child  ProcessingInstruction to delete
Returns:
whether deletion occurred

Document Document::setContent List    newContent [inline]
 

This sets the content of the Document. The supplied List should contain only objects of type Element, Comment, and ProcessingInstruction.

When all objects in the supplied List are valid and before the new content is added, all objects in the old content will have their parentage set to null (no parent) and the old content list will be cleared. This has the effect that any active list (previously obtained with a call to getContent) will also change to reflect the new content. In addition, all objects in the supplied List will have their parentage set to this document, but the List itself will not be "live" and further removals and additions will have no effect on this document content. If the user wants to continue working with a "live" list, then a call to setContent should be followed by a call to getContent to obtain a "live" version of the content.

Passing a null or empty List clears the existing content.

In event of an exception the original content will be unchanged and the objects in the supplied content will be unaltered.

em newContent <code>List</code> of content to set
Returns:
this document modified
Exceptions:
IllegalAddException  if the List contains objects of illegal types.

Document Document::setDocType DocType    docType [inline]
 

This will set the DocType declaration for this Document. Note that a DocType can only be attached to one Document. Attempting to set the DocType to a DocType object that already belongs to a Document will result in an IllegalAddException being thrown.

Parameters:
docType  DocType declaration.
Exceptions:
IllegalAddException  if the given docType is already attached to a Document.

Document Document::setRootElement Element    rootElement [inline]
 

This sets the root Element for the Document. If the document already has a root element, it is replaced.

Parameters:
rootElement  Element to be new root.
Returns:
Document - modified Document.
Exceptions:
IllegalAddException  if the given rootElement already has a parent.

String Document::toString   [inline]
 

This returns a String representation of the Document, suitable for debugging. If the XML representation of the Document is desired, XMLOutputter::outputString should be used.

Returns:
String - information about the Document


Member Data Documentation

ContentList Document::content = new ContentList(this) [protected]
 

This Document's Comments, ProcessingInstructions and the root Element.

DocType Document::docType [protected]
 

The DocType declaration.


The documentation for this class was generated from the following file:
Generated on Sat Mar 30 18:53:03 2002 for JDOM by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001