|
||||||||||
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 java.util.List |
content
This Document 's
s and
the root
|
protected DocType |
docType
The declaration |
protected java.util.Map |
namespaceMappings
The namespace prefix/URI mappings for this Document . |
protected java.util.List |
processingInstructions
s of
Document , with order preserved. |
protected Element |
rootElement
The root
of the Document . |
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. |
Method Summary | |
Document |
addComment(Comment comment)
This will add a comment to the Document . |
Document |
addNamespaceMapping(java.lang.String prefix,
java.lang.String mapping)
Adds a namespace prefix/URI mapping. |
Document |
addProcessingInstruction(ProcessingInstruction pi)
|
Document |
addProcessingInstruction(java.lang.String target,
java.util.Map data)
|
Document |
addProcessingInstruction(java.lang.String target,
java.lang.String data)
|
java.util.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. |
java.util.Map |
getNamespaceMappings()
This will return all namespace mappings. |
java.lang.String |
getNamespaceURI(java.lang.String prefix)
This will return the URI associated with the supplied prefix, or an empty String if no such
mapping exists. |
ProcessingInstruction |
getProcessingInstruction(java.lang.String target)
This returns the first processing instruction for this Document for the supplied target. |
java.util.List |
getProcessingInstructions()
This will return the list of s
for this Document . |
java.util.List |
getProcessingInstructions(java.lang.String target)
This returns the processing instructions for this Document which have the supplied target. |
Element |
getRootElement()
This will return the root Element
for this Document , or null if there is none. |
boolean |
removeNamespaceMapping(java.lang.String prefix)
This removes a namespace mapping for the supplied prefix. |
boolean |
removeProcessingInstruction(ProcessingInstruction processingInstruction)
This will remove the specified ProcessingInstruction . |
boolean |
removeProcessingInstruction(java.lang.String target)
This will remove the first PI with the specified target. |
boolean |
removeProcessingInstructions(java.lang.String target)
This will remove all PIs with the specified target. |
Document |
setDocType(DocType docType)
This will set the
declaration for this Document . |
Document |
setProcessingInstructions(java.util.List processingInstructions)
This sets the PIs for this Document to those in the
List
|
Document |
setRootElement(Element rootElement)
This sets the root for the
Document . |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected java.util.List processingInstructions
ProcessingInstruction
s of
Document
, with order preserved.
These are stored at the document level, so while
order is consistent, placement is not. In
other words the resulting Document
is
the same functionally as when created, but not
neccessarily lexically.protected java.util.List content
Document
's
Comment
s and
the root Element
protected java.util.Map namespaceMappings
Document
.protected Element rootElement
Element
of the Document
.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 rootMethod Detail |
public Element getRootElement() throws NoSuchElementException
This will return the root Element
for this Document
, or null if there is none.
Element
- the document's root elementNoSuchElementException
- - when no root
element exists.public 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
.
docType
- DocType
declaration.public java.util.List getProcessingInstructions()
This will return the list of
s
for this ProcessingInstruction
Document
.
List
- PIs for document.public java.util.List getProcessingInstructions(java.lang.String target)
This returns the processing instructions for this
Document
which have the supplied target.
target
- String
target of PI to return.List
- all PIs with the specified
target.public ProcessingInstruction getProcessingInstruction(java.lang.String target) throws NoSuchProcessingInstructionException
This returns the first processing instruction for this
Document
for the supplied target.
target
- String
target of PI to return.ProcessingInstruction
- the first PI
with the specified target.public Document addProcessingInstruction(ProcessingInstruction pi)
pi
- the PI to add.Document
this document modified.public Document addProcessingInstruction(java.lang.String target, java.lang.String data)
target
- target of PI to add.data
- raw data portion of PI to add.Document
this document modified.public Document addProcessingInstruction(java.lang.String target, java.util.Map data)
target
- target of PI to add.data
- map data portion of PI to add.Document
this document modified.public Document setProcessingInstructions(java.util.List processingInstructions)
This sets the PIs for this Document
to those in the
List
processingInstructions
- List
of PIs to use.Document
- this Document modified.public boolean removeProcessingInstruction(ProcessingInstruction processingInstruction)
This will remove the specified ProcessingInstruction
.
processingInstruction
- ProcessingInstruction
to remove.boolean
- whether the requested PI was removed.public boolean removeProcessingInstruction(java.lang.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(java.lang.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 addNamespaceMapping(java.lang.String prefix, java.lang.String mapping)
Adds a namespace prefix/URI mapping.
prefix
- String
prefix for mapping.uri
- String
URI being mapped toDocument
- this modifiedpublic java.lang.String getNamespaceURI(java.lang.String prefix)
This will return the URI associated with the supplied
prefix, or an empty String
if no such
mapping exists.
String
- prefix to locate mapping for.String
- URI for supplied prefix.public boolean removeNamespaceMapping(java.lang.String prefix)
This removes a namespace mapping for the supplied prefix.
String
- prefix to remove mapping for.boolean
- whether the mapping was deleted.public java.util.Map getNamespaceMappings()
This will return all namespace mappings.
Map
- namespace mappings.public Document addComment(Comment comment)
This will add a comment to the Document
.
comment
- Comment
to add.Document
- this object modified.public java.util.List getContent()
This will return all content for the Document
.
List
- all Document content
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |