|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jdom.Document
Document
defines behavior for an XML Document, modeled
in Java. Methods allow the user to the root element as well
as processing instructions and other document-level information.
Field Summary | |
protected List |
content
This Document 's
s,
s and
the root
|
protected DocType |
docType
The declaration |
Constructor Summary | |
protected |
Document()
Default, no-args constructor for implementations to use if needed. |
|
Document(Element rootElement)
This will create a new Document ,
with the supplied
as the root element, and no
declaration. |
|
Document(Element rootElement,
DocType docType)
This will create a new Document ,
with the supplied
as the root element and the supplied
declaration. |
|
Document(List content)
This will create a new Document ,
with the supplied list of content, and no
declaration. |
|
Document(List content,
DocType docType)
This will create a new Document ,
with the supplied list of content, and the supplied
declaration. |
Method Summary | |
Document |
addContent(Comment comment)
This will add a comment to the Document . |
Document |
addContent(ProcessingInstruction pi)
Adds the specified PI to the document. |
Object |
clone()
This will return a deep clone of this Document . |
boolean |
equals(Object ob)
This tests for equality of this Document to the supplied
Object . |
List |
getContent()
This will return all content for the Document . |
DocType |
getDocType()
This will return the
declaration for this Document , or
null if none exists. |
List |
getMixedContent()
Deprecated. Deprecated in beta7, use getContent() instead |
ProcessingInstruction |
getProcessingInstruction(String target)
Deprecated. Deprecated in beta7, use getContent() and examine for PIs manually |
List |
getProcessingInstructions()
Deprecated. Deprecated in beta7, use getContent() and examine for PIs manually |
List |
getProcessingInstructions(String target)
Deprecated. Deprecated in beta7, use getContent() and examine for PIs manually |
Element |
getRootElement()
This will return the root Element
for this Document
|
String |
getSerializedForm()
Deprecated. Deprecated in beta7, use XMLOutputter.outputString(Document) instead |
int |
hashCode()
This returns the hash code for this Document . |
boolean |
removeContent(Comment comment)
This removes the specified Comment . |
boolean |
removeContent(ProcessingInstruction pi)
This removes the specified ProcessingInstruction . |
boolean |
removeProcessingInstruction(String target)
Deprecated. Deprecated in beta7, use getContent() and remove PIs manually |
boolean |
removeProcessingInstructions(String target)
Deprecated. Deprecated in beta7, use getContent() and remove PIs manually |
Document |
setContent(List newContent)
This will set all content for the Document . |
Document |
setDocType(DocType docType)
This will set the
declaration for this Document . |
Document |
setMixedContent(List mixedContent)
Deprecated. Deprecated in beta7, use setContent(List) instead |
Document |
setProcessingInstructions(List pis)
Deprecated. Deprecated in beta7, use getContent() and add PIs manually |
Document |
setRootElement(Element rootElement)
This sets the root for the
Document . |
String |
toString()
This returns a String representation of the
Document , suitable for debugging. |
Methods inherited from class java.lang.Object |
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
protected List content
Document
's
Comment
s,
ProcessingInstruction
s and
the root Element
protected DocType docType
DocType
declarationConstructor Detail |
protected Document()
Default, no-args constructor for implementations to use if needed.
public Document(Element rootElement, DocType docType)
This will create a new Document
,
with the supplied
as the root element and the supplied
Element
declaration.
DocType
rootElement
- Element
for document root.docType
- DocType
declaration.public Document(Element rootElement)
This will create a new Document
,
with the supplied
as the root element, and no Element
declaration.
DocType
rootElement
- Element
for document rootpublic Document(List content, DocType docType)
This will create a new Document
,
with the supplied list of content, and the supplied
declaration.
DocType
content
- List
of starter contentdocType
- DocType
declaration.public Document(List content)
This will create a new Document
,
with the supplied list of content, and no
declaration.
DocType
content
- List
of starter contentMethod Detail |
public Element getRootElement()
This will return the root Element
for this Document
Element
- the document's root elementpublic Document setRootElement(Element rootElement)
This sets the root
for the
Element
Document
.
rootElement
- Element
to be new root.Document
- modified Document.public DocType getDocType()
This will return the
declaration for this DocType
Document
, or
null
if none exists.
DocType
- the DOCTYPE declaration.public Document setDocType(DocType docType)
This will set the
declaration for this DocType
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.public Document addContent(ProcessingInstruction pi)
Adds the specified PI to the document.
pi
- the PI to add.Document
this document modified.public Document addContent(Comment comment)
This will add a comment to the Document
.
comment
- Comment
to add.Document
- this object modified.public List getContent()
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.
List
- all Document contentpublic Document setContent(List newContent)
This will set all content for the Document
.
The List may contain only objects of type Element, Comment, and
ProcessingInstruction; and only one Element that becomes the root.
In event of an exception the original content will be unchanged
and the items in the added content will be unaltered.
content
- the new contentpublic String toString()
This returns a String
representation of the
Document
, suitable for debugging. If the XML
representation of the Document
is desired,
XMLOutputter.outputString(Document)
should be used.
String
- information about the
Document
public final boolean equals(Object ob)
This tests for equality of this Document
to the supplied
Object
.
ob
- Object
to compare to.boolean
- whether the Document
is
equal to the supplied Object
.public final int hashCode()
This returns the hash code for this Document
.
int
- hash code.public Object clone()
This will return a deep clone of this Document
.
Object
- clone of this Document
.public boolean removeContent(ProcessingInstruction pi)
This removes the specified ProcessingInstruction
.
If the specified ProcessingInstruction
is not a child of
this Document
, this method does nothing.
child
- ProcessingInstruction
to deletepublic boolean removeContent(Comment comment)
This removes the specified Comment
.
If the specified Comment
is not a child of
this Document
, this method does nothing.
comment
- Comment
to deletepublic final String getSerializedForm()
This will return the Document
in XML format,
usable in an XML document.
String
- the serialized form of the
Document
.public List getProcessingInstructions()
This will return the list of
s
for this ProcessingInstruction
Document
located at the document level
(outside the root element).
The returned list is "live" in document order and changes to it
affect the document's actual content.
List
- PIs for document.public List getProcessingInstructions(String target)
This returns the processing instructions for this
Document
located at the document level
(outside the root element) which have the supplied target.
The returned list is "live" in document order and changes to it
affect the document's actual content.
target
- String
target of PI to return.List
- all PIs with the specified
target.public ProcessingInstruction getProcessingInstruction(String target)
This returns the first processing instruction for this
Document
located at the document level
(outside the root element) for the supplied target, or null if
no such processing instruction exists.
target
- String
target of PI to return.ProcessingInstruction
- the first PI
with the specified target, or null if no such PI exists.public boolean removeProcessingInstruction(String target)
This will remove the first PI with the specified target.
target
- String
target of PI to remove.boolean
- whether the requested PI was removed.public boolean removeProcessingInstructions(String target)
This will remove all PIs with the specified target.
target
- String
target of PI to remove.boolean
- whether the requested PIs were removed.public Document setProcessingInstructions(List pis)
This sets the PIs for this Document
to those in the
List
pis
- List
of PIs to use.Document
- this Document modified.public List getMixedContent()
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.
List
- all Document contentpublic Document setMixedContent(List mixedContent)
This will set all content for the Document
.
The List may contain only objects of type Element, Comment, and
ProcessingInstruction; and only one Element that becomes the root.
In event of an exception the original content will be unchanged
and the items in the added content will be unaltered.
content
- the new mixed content
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |