Public Member Functions | |
Document () | |
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 () |
List | getContent (Filter filter) |
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 Attributes | |
ContentList | content = new ContentList(this) |
DocType | docType |
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.
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.
This will create a new Document
, with the supplied Element
as the root element and the supplied DocType
declaration.
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.
rootElement | Element for document root |
IllegalAddException | if the given rootElement already has a parent. |
org::jdom::Document::Document | ( | List | newContent, | |
DocType | docType | |||
) | [inline] |
This will create a new Document
, with the supplied list of content, and the supplied DocType
declaration.
newContent | List of starter content | |
docType | DocType declaration. |
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. |
org::jdom::Document::Document | ( | List | content | ) | [inline] |
This will create a new Document
, with the supplied list of content, and no DocType
declaration.
content | List of starter content |
IllegalAddException | if the List contains more than one Element or objects of illegal types. |
boolean org::jdom::Document::hasRootElement | ( | ) | [inline] |
This will return true
if this document has a root element, false
otherwise.
true
if this document has a root element, false
otherwise. Element org::jdom::Document::getRootElement | ( | ) | [inline] |
Element org::jdom::Document::detachRootElement | ( | ) | [inline] |
DocType org::jdom::Document::getDocType | ( | ) | [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.
docType | DocType declaration. |
IllegalAddException | if the given docType is already attached to a Document. |
Document org::jdom::Document::addContent | ( | ProcessingInstruction | pi | ) | [inline] |
Adds the specified PI to the document.
pi | the ProcessingInstruction to add. |
Document
this document modified. IllegalAddException | if the given processing instruction already has a parent element. |
This will add a comment to the Document
.
comment | Comment to add. |
Document
- this object modified. IllegalAddException | if the given comment already has a parent element. |
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.
List
- all Document content IllegalStateException | if the root element hasn't been set |
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.
filter | Filter to apply |
List
- filtered Document content IllegalStateException | if the root element hasn't been set |
Document org::jdom::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 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.
newContent | List of content to set |
IllegalAddException | if the List contains objects of illegal types. |
boolean org::jdom::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.
pi | ProcessingInstruction to delete |
boolean org::jdom::Document::removeContent | ( | Comment | comment | ) | [inline] |
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.
String
- information about the Document
final boolean org::jdom::Document::equals | ( | Object | ob | ) | [inline] |
final int org::jdom::Document::hashCode | ( | ) | [inline] |
Object org::jdom::Document::clone | ( | ) | [inline] |
ContentList org::jdom::Document::content = new ContentList(this) [protected] |
This Document
's Comment
s, ProcessingInstruction
s and the root Element
.
DocType org::jdom::Document::docType [protected] |
The DocType
declaration.