Main Page | Class Hierarchy | Class List | Class Members

org::jdom::Document Class Reference

Inheritance diagram for org::jdom::Document:

org::jdom::Parent List of all members.

Public Member Functions

 Document ()
 Document (Element rootElement, DocType docType, String baseURI)
 Document (Element rootElement, DocType docType)
 Document (Element rootElement)
 Document (List content)
int getContentSize ()
int indexOf (Content child)
boolean hasRootElement ()
Element getRootElement ()
Document setRootElement (Element rootElement)
Element detachRootElement ()
DocType getDocType ()
Document setDocType (DocType docType)
Document addContent (Content child)
Document addContent (Collection c)
Document addContent (int index, Content child)
Document addContent (int index, Collection c)
List cloneContent ()
Content getContent (int index)
List getContent ()
List getContent (Filter filter)
List removeContent ()
List removeContent (Filter filter)
Document setContent (Collection newContent)
final void setBaseURI (String uri)
final String getBaseURI ()
Document setContent (int index, Content child)
Document setContent (int index, Collection collection)
boolean removeContent (Content child)
Content removeContent (int index)
Document setContent (Content child)
String toString ()
final boolean equals (Object ob)
final int hashCode ()
Object clone ()
Iterator getDescendants ()
Iterator getDescendants (Filter filter)
Parent getParent ()
Document getDocument ()
void setProperty (String id, Object value)
Object getProperty (String id)

Protected Attributes

String baseURI = null

Package Attributes

ContentList content = new ContentList(this)

Detailed Description

An XML document. Methods allow access to the root element as well as the DocType and other document-level information.

Version:
Revision
1.84
,
Date
2004/08/31 21:47:51
Author:
Brett McLaughlin

Jason Hunter

Jools Enticknap

Bradley S. Huffman


Constructor & Destructor Documentation

org::jdom::Document::Document  )  [inline]
 

Creates a new empty document. A document must have a root element, so this document will not be well-formed and accessor methods will throw an IllegalStateException if this document is accessed before a root element is added. This method is most useful for build tools.

org::jdom::Document::Document Element  rootElement,
DocType  docType,
String  baseURI
[inline]
 

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

Parameters:
rootElement Element for document root.
docType DocType declaration.
baseURI the URI from which this doucment was loaded.
Exceptions:
IllegalAddException if the given docType object is already attached to a document or the given rootElement already has a parent

org::jdom::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.
Exceptions:
IllegalAddException if the given DocType object is already attached to a document or the given rootElement already has a parent

org::jdom::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
Exceptions:
IllegalAddException if the given rootElement already has a parent.

org::jdom::Document::Document List  content  )  [inline]
 

This will create a new Document, with the supplied list of content, and a DocType declaration only if the content contains a DocType instance. A null list is treated the same as the no-arg constructor.

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 org::jdom::Document::addContent int  index,
Collection  c
[inline]
 

Inserts the content in a collection into the content list at the given index. In event of an exception the original content will be unchanged and the objects in the supplied collection will be unaltered.

Parameters:
index location for adding the collection
c collection to insert
Returns:
the parent on which the method was called
Exceptions:
IndexOutOfBoundsException if index is negative or beyond the current number of children
IllegalAddException if any item in the collection already has a parent or is of an illegal type.

Document org::jdom::Document::addContent int  index,
Content  child
[inline]
 

Inserts the child into the content list at the given index.

Parameters:
index location for adding the collection
child child to insert
Returns:
the parent on which the method was called
Exceptions:
IndexOutOfBoundsException if index is negative or beyond the current number of children
IllegalAddException if the given child already has a parent.

Document org::jdom::Document::addContent Collection  c  )  [inline]
 

Appends all children in the given collection to the end of the content list. In event of an exception during add the original content will be unchanged and the objects in the supplied collection will be unaltered.

Parameters:
c collection to append
Returns:
the document on which the method was called
Exceptions:
IllegalAddException if any item in the collection already has a parent or is of an illegal type.

Document org::jdom::Document::addContent Content  child  )  [inline]
 

Appends the child to the end of the content list.

Parameters:
child child to append to end of content list
Returns:
the document on which the method was called
Exceptions:
IllegalAddException if the given child already has a parent.

Object org::jdom::Document::clone  )  [inline]
 

This will return a deep clone of this Document.

Returns:
Object clone of this Document

Implements org::jdom::Parent.

List org::jdom::Document::cloneContent  )  [inline]
 

Returns a list containing detached clones of this parent's content list.

Returns:
list of cloned child content

Implements org::jdom::Parent.

Element org::jdom::Document::detachRootElement  )  [inline]
 

Detach the root Element from this document.

Returns:
removed root Element

final boolean org::jdom::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

final String org::jdom::Document::getBaseURI  )  [inline]
 

Returns the URI from which this document was loaded, or null if this is not known.

Returns:
the base URI of this document

List org::jdom::Document::getContent Filter  filter  )  [inline]
 

Return a filtered view of this Document's content.

Sequential traversal through the List is best done with a Iterator since the underlying implement of List.size() may require walking the entire list.

Parameters:
filter Filter to apply
Returns:
List - filtered Document content
Exceptions:
IllegalStateException if the root element hasn't been set

Implements org::jdom::Parent.

List org::jdom::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.

Sequential traversal through the List is best done with a Iterator since the underlying implement of List.size() may require walking the entire list.

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

Implements org::jdom::Parent.

Content org::jdom::Document::getContent int  index  )  [inline]
 

Returns the child at the given index.

Parameters:
index location of desired child
Returns:
child at the given index
Exceptions:
IndexOutOfBoundsException if index is negative or beyond the current number of children
IllegalStateException if parent is a Document and the root element is not set

Implements org::jdom::Parent.

int org::jdom::Document::getContentSize  )  [inline]
 

Returns the number of children in this parent's content list. Children may be any Content type.

Returns:
number of children

Implements org::jdom::Parent.

Iterator org::jdom::Document::getDescendants Filter  filter  )  [inline]
 

Returns an iterator that walks over all descendants in document order applying the Filter to return only elements that match the filter rule. With filters you can match only Elements, only Comments, Elements or Comments, only Elements with a given name and/or prefix, and so on.

Parameters:
filter filter to select which descendants to see
Returns:
an iterator to walk descendants within a filter

Implements org::jdom::Parent.

Iterator org::jdom::Document::getDescendants  )  [inline]
 

Returns an iterator that walks over all descendants in document order.

Returns:
an iterator to walk descendants

Implements org::jdom::Parent.

DocType org::jdom::Document::getDocType  )  [inline]
 

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

Returns:
DocType - the DOCTYPE declaration.

Document org::jdom::Document::getDocument  )  [inline]
 

See also:
org.jdom.Parent::getDocument()

Implements org::jdom::Parent.

Parent org::jdom::Document::getParent  )  [inline]
 

Return this parent's parent, or null if this parent is currently not attached to another parent. This is the same method as in Content but also added to Parent to allow more easy up-the-tree walking.

Returns:
this parent's parent or null if none

Implements org::jdom::Parent.

Object org::jdom::Document::getProperty String  id  )  [inline]
 

Returns the object associated with this document under the given "id" string, or null if there is no binding or if the binding explicitly stored a null value.

Parameters:
id the id of the stored object to return
Returns:
the object associated with the given id

Element org::jdom::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 org::jdom::Document::hashCode  )  [inline]
 

This returns the hash code for this Document.

Returns:
int hash code

boolean org::jdom::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.

int org::jdom::Document::indexOf Content  child  )  [inline]
 

Returns the index of the supplied child in the content list, or -1 if not a child of this parent.

Parameters:
child child to search for
Returns:
index of child, or -1 if not found

Implements org::jdom::Parent.

Content org::jdom::Document::removeContent int  index  )  [inline]
 

Removes and returns the child at the given index, or returns null if there's no such child.

Parameters:
index index of child to remove
Returns:
detached child at given index or null if no
Exceptions:
IndexOutOfBoundsException if index is negative or beyond the current number of children

Implements org::jdom::Parent.

boolean org::jdom::Document::removeContent Content  child  )  [inline]
 

Removes a single child node from the content list.

Parameters:
child child to remove
Returns:
whether the removal occurred

Implements org::jdom::Parent.

List org::jdom::Document::removeContent Filter  filter  )  [inline]
 

Remove all child content from this parent matching the supplied filter.

Parameters:
filter filter to select which content to remove
Returns:
list of the old children detached from this parent

Implements org::jdom::Parent.

List org::jdom::Document::removeContent  )  [inline]
 

Removes all child content from this parent.

Returns:
list of the old children detached from this parent

Implements org::jdom::Parent.

final void org::jdom::Document::setBaseURI String  uri  )  [inline]
 

Sets the effective URI from which this document was loaded, and against which relative URLs in this document will be resolved.

Parameters:
uri the base URI of this document

Document org::jdom::Document::setContent Content  child  )  [inline]
 

Set this document's content to be the supplied child.

If the supplied child is legal content for a Document and before it is added, all content in the current content list will be cleared and all current children will have their parentage set to null.

This has the effect that any active list (previously obtained with a call to one of the getContent methods will also change to reflect the new content. In addition, all content in the supplied collection will have their parentage set to this Document. If the user wants to continue working with a "live" list of this Document's child, then a call to setContent should be followed by a call to one of the getContent methods to obtain a "live" version of the children.

Passing a null child clears the existing content.

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

Parameters:
child new content to replace existing content
Returns:
the parent on which the method was called
Exceptions:
IllegalAddException if the supplied child is already attached or not legal content for this parent

Document org::jdom::Document::setContent int  index,
Collection  collection
[inline]
 

Replace the child at the given index whith the supplied collection.

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

Parameters:
index - index of child to replace.
collection - collection of content to add.
Returns:
object on which the method was invoked
Exceptions:
IllegalAddException if the collection contains objects of illegal types.
IndexOutOfBoundsException if index is negative or greater than the current number of children.

Document org::jdom::Document::setContent Collection  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 legal 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.

Parameters:
newContent List of content to set
Returns:
this document modified
Exceptions:
IllegalAddException if the List contains objects of illegal types or with existing parentage.

Document org::jdom::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.
Returns:
object on which the method was invoked
Exceptions:
IllegalAddException if the given docType is already attached to a Document.

void org::jdom::Document::setProperty String  id,
Object  value
[inline]
 

Assigns an arbitrary object to be associated with this document under the given "id" string. Null values are permitted. Strings beginning with "http://www.jdom.org/ are reserved for JDOM use.

Parameters:
id the id of the stored object
value the object to store

Document org::jdom::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 org::jdom::Document::toString  )  [inline]
 

This returns a String representation of the Document, suitable for debugging. If the XML representation of the Document is desired, org.jdom.output.XMLOutputter#outputString(Document) should be used.

Returns:
String - information about the Document


Member Data Documentation

String org::jdom::Document::baseURI = null [protected]
 

See http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/core.html#baseURIs-Considerations

ContentList org::jdom::Document::content = new ContentList(this) [package]
 

This document's content including comments, PIs, a possible DocType, and a root element. Subclassers have to track content using their own mechanism.


The documentation for this class was generated from the following file:
Generated on Thu Dec 9 10:42:04 2004 for JDOM by  doxygen 1.3.9.1