Top Description Fields Constructors Methods
org.jdom2

public Class Document

extends CloneBase
implements Parent
Class Inheritance
All Implemented Interfaces
org.jdom2.Parent, java.io.Serializable, org.jdom2.NamespaceAware, java.lang.Cloneable
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, java.util.*, org.jdom2.filter.*, org.jdom2.util.IteratorIterable

An XML document. Methods allow access to the root element as well as the DocType and other document-level information.
Authors
Brett McLaughlin, Jason Hunter, Jools Enticknap, Bradley S. Huffman, Rolf Lear

Field Summary

Modifier and TypeField and Description
protected String
baseURI

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

pack-priv transient ContentList
content

This document's content including comments, PIs, a possible DocType, and a root element.

private transient HashMap<String, Object>
private static final long
serialVersionUID

JDOM2 Serialization.

Constructor Summary

AccessConstructor and Description
public
Document()

Creates a new empty document.

public
Document(Element
Element for document root.
rootElement
,
DocType
DocType declaration.
docType
,
String
the URI from which this document was loaded.
baseURI
)

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

public
Document(Element
Element for document root.
rootElement
,
DocType
DocType declaration.
docType
)

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

public
Document(Element
Element for document root
rootElement
)

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

public
Document(List<? extends Content>
List of starter content
content
)

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

Method Summary

Modifier and TypeMethod and Description
public Document

Returns:

the document on which the method was called
addContent
(Content
child to append to end of content list
child
)

Implements org.jdom2.Parent.addContent.

Appends the child to the end of the content list.
public Document

Returns:

the document on which the method was called
addContent
(Collection<? extends Content>
collection to append
c
)

Implements org.jdom2.Parent.addContent.

Appends all children in the given collection to the end of the content list.
public Document

Returns:

the parent on which the method was called
addContent
(int
location for adding the collection
index
,
Content
child to insert
child
)

Implements org.jdom2.Parent.addContent.

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

Returns:

the parent on which the method was called
addContent
(int
location for adding the collection
index
,
Collection<? extends Content>
collection to insert
c
)

Implements org.jdom2.Parent.addContent.

Inserts the content in a collection into the content list at the given index.
public void
canContainContent(Content
The content to be checked
child
,
int
The location where the content would be put.
index
,
boolean
true if the intention is to replace the content already at the index.
replace
)

Implements org.jdom2.Parent.canContainContent.

Test whether this Parent instance can contain the specified content at the specified position.
public Document

Returns:

Object clone of this Document
clone
()

Overrides org.jdom2.CloneBase.clone.

Implements org.jdom2.Parent.clone.

This will return a deep clone of this Document.
public List<Content>
cloneContent()

Implements org.jdom2.Parent.cloneContent.

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

Returns:

removed root Element
detachRootElement
()

Detach the root Element from this document.

public final boolean

Returns:

boolean whether the Document is equal to the supplied Object
equals
(Object
Object to compare to
ob
)

Overrides java.lang.Object.equals.

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

Returns:

the base URI of this document
getBaseURI
()

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

public Content
getContent(int
location of desired child
index
)

Implements org.jdom2.Parent.getContent.

Returns the child at the given index.
public List<Content>

Returns:

List - all Document content
getContent
()

Implements org.jdom2.Parent.getContent.

This will return all content for the Document.
public <F extends Content> List<F>

Returns:

List - filtered Document content
getContent
(Filter<F>
Filter to apply Note that the Filters class has a number of predefined, useful filters.
filter
)

Implements org.jdom2.Parent.getContent.

Return a filtered view of this Document's content.
public int
getContentSize()

Implements org.jdom2.Parent.getContentSize.

Returns the number of children in this parent's content list.
public IteratorIterable<Content>

Returns:

an iterator to walk descendants
getDescendants
()

Implements org.jdom2.Parent.getDescendants.

Returns an iterator that walks over all descendants in document order.
public <F extends Content> IteratorIterable<F>

Returns:

an iterator to walk descendants within a filter
getDescendants
(final Filter<F>
filter to select which descendants to see Note that the Filters class has a number of predefined, useful filters.
filter
)

Implements org.jdom2.Parent.getDescendants.

Returns an iterator that walks over all descendants in document order applying the Filter to return only elements that match the filter rule.
public DocType

Returns:

DocType - the DOCTYPE declaration.
getDocType
()

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

public Document

Returns:

'this' because this Document is its own Document
getDocument
()

Implements org.jdom2.Parent.getDocument.

Always returns this Document Instance
public List<Namespace>
getNamespacesInherited()

Implements org.jdom2.NamespaceAware.getNamespacesInherited.

Obtain a list of all namespaces that are in scope for this content, but were not introduced by this content.
public List<Namespace>
getNamespacesInScope()

Implements org.jdom2.NamespaceAware.getNamespacesInScope.

Get the Namespaces that are in-scope on this Document.
public List<Namespace>
getNamespacesIntroduced()

Implements org.jdom2.NamespaceAware.getNamespacesIntroduced.

Obtain a list of all namespaces that are introduced to the XML tree by this node.
public Parent

Returns:

null
getParent
()

Implements org.jdom2.Parent.getParent.

Always returns null, Document cannot have a parent.
public Object

Returns:

the Object associated with the given id
getProperty
(String
the id of the stored Object to return
id
)

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.

public Element

Returns:

Element - the document's root element
getRootElement
()

This will return the root Element for this Document

public final int

Returns:

int hash code
hashCode
()

Overrides java.lang.Object.hashCode.

This returns the hash code for this Document.
public boolean

Returns:

true if this document has a root element, false otherwise.
hasRootElement
()

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

public int
indexOf(Content
child to search for
child
)

Implements org.jdom2.Parent.indexOf.

Returns the index of the supplied child in the content list, or -1 if not a child of this parent.
private void
readObject(final ObjectInputStream
where to read the Element from.
in
)

Read an Element off the ObjectInputStream.

public List<Content>

Returns:

list of the old children detached from this parent
removeContent
()

Implements org.jdom2.Parent.removeContent.

Removes all child content from this parent.
public <F extends Content> List<F>

Returns:

list of the old children detached from this parent
removeContent
(Filter<F>
filter to select which content to remove Note that the Filters class has a number of predefined, useful filters.
filter
)

Implements org.jdom2.Parent.removeContent.

Remove all child content from this parent matching the supplied filter.
public boolean
removeContent(Content
child to remove
child
)

Implements org.jdom2.Parent.removeContent.

Removes a single child node from the content list.
public Content
removeContent(int
index of child to remove
index
)

Implements org.jdom2.Parent.removeContent.

Removes and returns the child at the given index, or returns null if there's no such child.
public final void
setBaseURI(String
the base URI of this document
uri
)

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

public Document

Returns:

this document modified
setContent
(Collection<? extends Content>
List of content to set
newContent
)

This sets the content of the Document.

public Document

Returns:

this document instance
setContent
(int
- index of child to replace.
index
,
Content
- child to add.
child
)

Replace the current child the given index with the supplied child.

public Document

Returns:

object on which the method was invoked
setContent
(int
- index of child to replace.
index
,
Collection<? extends Content>
- collection of content to add.
collection
)

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

public Document

Returns:

the parent on which the method was called
setContent
(Content
new content to replace existing content
child
)

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

public Document

Returns:

object on which the method was invoked
setDocType
(DocType
DocType declaration.
docType
)

This will set the DocType declaration for this Document.

public void
setProperty(String
the id of the stored Object
id
,
Object
the Object to store
value
)

Assigns an arbitrary object to be associated with this document under the given "id" string.

public Document

Returns:

Document - modified Document.
setRootElement
(Element
Element to be new root.
rootElement
)

This sets the root Element for the Document.

public String

Returns:

String - information about the Document
toString
()

Overrides java.lang.Object.toString.

This returns a String representation of the Document, suitable for debugging.
private void
writeObject(final ObjectOutputStream
where to write the Element to.
out
)

Serialize out the Element.

Field Detail

baseURIback to summary
protected String baseURI

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

contentback to summary
pack-priv transient ContentList content

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

propertyMapback to summary
private transient HashMap<String, Object> propertyMap
serialVersionUIDback to summary
private static final long serialVersionUID

JDOM2 Serialization. In this case, DocType is simple.

Constructor Detail

Documentback to summary
public Document()

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.

Documentback to summary
public Document(Element rootElement, DocType docType, String baseURI)

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

Element for document root.

docType:DocType

DocType declaration.

baseURI:String

the URI from which this document was loaded.

Exceptions
IllegalAddException:
if the given docType object is already attached to a document or the given rootElement already has a parent
Documentback to summary
public Document(Element rootElement, DocType docType)

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

Parameters
rootElement:Element

Element for document root.

docType:DocType

DocType declaration.

Exceptions
IllegalAddException:
if the given DocType object is already attached to a document or the given rootElement already has a parent
Documentback to summary
public Document(Element rootElement)

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

Parameters
rootElement:Element

Element for document root

Exceptions
IllegalAddException:
if the given rootElement already has a parent.
Documentback to summary
public Document(List<? extends Content> content)

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<? extends Content>

List of starter content

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

Method Detail

addContentback to summary
public Document addContent(Content child)

Implements org.jdom2.Parent.addContent.

Appends the child to the end of the content list.

Parameters
child:Content

child to append to end of content list

Returns:Document

the document on which the method was called

Annotations
@Override
Exceptions
IllegalAddException:
if the given child already has a parent.
addContentback to summary
public Document addContent(Collection<? extends Content> c)

Implements org.jdom2.Parent.addContent.

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<? extends Content>

collection to append

Returns:Document

the document on which the method was called

Annotations
@Override
Exceptions
IllegalAddException:
if any item in the collection already has a parent or is of an illegal type.
addContentback to summary
public Document addContent(int index, Content child)

Implements org.jdom2.Parent.addContent.

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

Parameters
index:int

location for adding the collection

child:Content

child to insert

Returns:Document

the parent on which the method was called

Annotations
@Override
Exceptions
IndexOutOfBoundsException:
if index is negative or beyond the current number of children
IllegalAddException:
if the given child already has a parent.
addContentback to summary
public Document addContent(int index, Collection<? extends Content> c)

Implements org.jdom2.Parent.addContent.

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:int

location for adding the collection

c:Collection<? extends Content>

collection to insert

Returns:Document

the parent on which the method was called

Annotations
@Override
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.
canContainContentback to summary
public void canContainContent(Content child, int index, boolean replace)

Implements org.jdom2.Parent.canContainContent.

Doc from org.jdom2.Parent.canContainContent.

Test whether this Parent instance can contain the specified content at the specified position.

Parameters
child:Content

The content to be checked

index:int

The location where the content would be put.

replace:boolean

true if the intention is to replace the content already at the index.

Annotations
@Override
cloneback to summary
public Document clone()

Overrides org.jdom2.CloneBase.clone.

Implements org.jdom2.Parent.clone.

This will return a deep clone of this Document.

Returns:Document

Object clone of this Document

Annotations
@Override
cloneContentback to summary
public List<Content> cloneContent()

Implements org.jdom2.Parent.cloneContent.

Doc from org.jdom2.Parent.cloneContent.

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

Returns:List<Content>

list of cloned child content

Annotations
@Override
detachRootElementback to summary
public Element detachRootElement()

Detach the root Element from this document.

Returns:Element

removed root Element

equalsback to summary
public final boolean equals(Object ob)

Overrides java.lang.Object.equals.

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

Parameters
ob:Object

Object to compare to

Returns:boolean

boolean whether the Document is equal to the supplied Object

Annotations
@Override
getBaseURIback to summary
public final String getBaseURI()

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

Returns:String

the base URI of this document

getContentback to summary
public Content getContent(int index)

Implements org.jdom2.Parent.getContent.

Doc from org.jdom2.Parent.getContent.

Returns the child at the given index.

Parameters
index:int

location of desired child

Returns:Content

child at the given index

Annotations
@Override
getContentback to summary
public List<Content> getContent()

Implements org.jdom2.Parent.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.

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<Content>

List - all Document content

Annotations
@Override
Exceptions
IllegalStateException:
if the root element hasn't been set
getContentback to summary
public <F extends Content> List<F> getContent(Filter<F> filter)

Implements org.jdom2.Parent.getContent.

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
<F>

Doc from org.jdom2.Parent.getContent. The Generic type of the returned content (the Filter's type)

filter:Filter<F>

Filter to apply Note that the Filters class has a number of predefined, useful filters.

Returns:List<F>

List - filtered Document content

Annotations
@Override
Exceptions
IllegalStateException:
if the root element hasn't been set
getContentSizeback to summary
public int getContentSize()

Implements org.jdom2.Parent.getContentSize.

Doc from org.jdom2.Parent.getContentSize.

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

Returns:int

number of children

Annotations
@Override
getDescendantsback to summary
public IteratorIterable<Content> getDescendants()

Implements org.jdom2.Parent.getDescendants.

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

Returns:IteratorIterable<Content>

an iterator to walk descendants

Annotations
@Override
getDescendantsback to summary
public <F extends Content> IteratorIterable<F> getDescendants(final Filter<F> filter)

Implements org.jdom2.Parent.getDescendants.

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
<F>

Doc from org.jdom2.Parent.getDescendants. The generic type of the returned descendant data

filter:Filter<F>

filter to select which descendants to see Note that the Filters class has a number of predefined, useful filters.

Returns:IteratorIterable<F>

an iterator to walk descendants within a filter

Annotations
@Override
getDocTypeback to summary
public DocType getDocType()

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

Returns:DocType

DocType - the DOCTYPE declaration.

getDocumentback to summary
public Document getDocument()

Implements org.jdom2.Parent.getDocument.

Always returns this Document Instance

Returns:Document

'this' because this Document is its own Document

Annotations
@Override
getNamespacesInheritedback to summary
public List<Namespace> getNamespacesInherited()

Implements org.jdom2.NamespaceAware.getNamespacesInherited.

Doc from org.jdom2.NamespaceAware.getNamespacesInherited.

Obtain a list of all namespaces that are in scope for this content, but were not introduced by this content.

The contents of this list will always be a subset (but in the same order) of getNamespacesInScope(), and will never intersect getNamspacesIntroduced()

Returns:List<Namespace>

a read-only list of Namespaces.

Annotations
@Override
getNamespacesInScopeback to summary
public List<Namespace> getNamespacesInScope()

Implements org.jdom2.NamespaceAware.getNamespacesInScope.

Doc from org.jdom2.NamespaceAware.getNamespacesInScope.

Get the Namespaces that are in-scope on this Document.

Document always has exactly two Namespaces in-scope: Namespace#NO_NAMESPACE and Namespace#XML_NAMESPACE.

These namespaces are always introduced by the Document, and thus they are both returned by getNamespacesIntroduced(), and additionally getNamespacesInherited() will always be empty.

Description copied from NamespaceAware#getNamespacesInScope():

Obtain a list of all namespaces that are in scope for the current content.

The contents of this list will always be the combination of getNamespacesIntroduced() and getNamespacesInherited().

See NamespaceAware documentation for details on what the order of the Namespaces will be in the returned list.

Returns:List<Namespace>

a read-only list of Namespaces.

Annotations
@Override
getNamespacesIntroducedback to summary
public List<Namespace> getNamespacesIntroduced()

Implements org.jdom2.NamespaceAware.getNamespacesIntroduced.

Doc from org.jdom2.NamespaceAware.getNamespacesIntroduced.

Obtain a list of all namespaces that are introduced to the XML tree by this node. Only Elements and Attributes can introduce namespaces, so all other Content types will return an empty list.

The contents of this list will always be a subset (but in the same order) of getNamespacesInScope(), and will never intersect getNamspacesInherited()

Returns:List<Namespace>

a read-only list of Namespaces.

Annotations
@Override
getParentback to summary
public Parent getParent()

Implements org.jdom2.Parent.getParent.

Always returns null, Document cannot have a parent.

Returns:Parent

null

Annotations
@Override
getPropertyback to summary
public Object getProperty(String id)

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:String

the id of the stored Object to return

Returns:Object

the Object associated with the given id

getRootElementback to summary
public Element getRootElement()

This will return the root Element for this Document

Returns:Element

Element - the document's root element

Exceptions
IllegalStateException:
if the root element hasn't been set
hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

This returns the hash code for this Document.

Returns:int

int hash code

Annotations
@Override
hasRootElementback to summary
public boolean hasRootElement()

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

Returns:boolean

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

indexOfback to summary
public int indexOf(Content child)

Implements org.jdom2.Parent.indexOf.

Doc from org.jdom2.Parent.indexOf.

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

Parameters
child:Content

child to search for

Returns:int

index of child, or -1 if not found

Annotations
@Override
readObjectback to summary
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException

Read an Element off the ObjectInputStream.

Parameters
in:ObjectInputStream

where to read the Element from.

Exceptions
IOException:
if there is a reading problem.
ClassNotFoundException:
when a class cannot be found
See Also
writeObject(ObjectOutputStream)
removeContentback to summary
public List<Content> removeContent()

Implements org.jdom2.Parent.removeContent.

Removes all child content from this parent.

Returns:List<Content>

list of the old children detached from this parent

Annotations
@Override
removeContentback to summary
public <F extends Content> List<F> removeContent(Filter<F> filter)

Implements org.jdom2.Parent.removeContent.

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

Parameters
<F>

Doc from org.jdom2.Parent.removeContent. The Generic type of the content to remove.

filter:Filter<F>

filter to select which content to remove Note that the Filters class has a number of predefined, useful filters.

Returns:List<F>

list of the old children detached from this parent

Annotations
@Override
removeContentback to summary
public boolean removeContent(Content child)

Implements org.jdom2.Parent.removeContent.

Doc from org.jdom2.Parent.removeContent.

Removes a single child node from the content list.

Parameters
child:Content

child to remove

Returns:boolean

whether the removal occurred

Annotations
@Override
removeContentback to summary
public Content removeContent(int index)

Implements org.jdom2.Parent.removeContent.

Doc from org.jdom2.Parent.removeContent.

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

Parameters
index:int

index of child to remove

Returns:Content

detached child at given index or null if no

Annotations
@Override
setBaseURIback to summary
public final void setBaseURI(String uri)

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

Parameters
uri:String

the base URI of this document

setContentback to summary
public Document setContent(Collection<? extends Content> newContent)

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:Collection<? extends Content>

List of content to set

Returns:Document

this document modified

Exceptions
IllegalAddException:
if the List contains objects of illegal types or with existing parentage.
setContentback to summary
public Document setContent(int index, Content child)

Replace the current child the given index with the supplied child.

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

Parameters
index:int

- index of child to replace.

child:Content

- child to add.

Returns:Document

this document instance

Exceptions
IllegalAddException:
if the supplied child is already attached or not legal content for this parent.
IndexOutOfBoundsException:
if index is negative or greater than the current number of children.
setContentback to summary
public Document setContent(int index, Collection<? extends Content> collection)

Replace the child at the given index with 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:int

- index of child to replace.

collection:Collection<? extends Content>

- collection of content to add.

Returns:Document

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.
setContentback to summary
public Document setContent(Content child)

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:Content

new content to replace existing content

Returns:Document

the parent on which the method was called

Exceptions
IllegalAddException:
if the supplied child is already attached or not legal content for this parent
setDocTypeback to summary
public Document setDocType(DocType docType)

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

DocType declaration.

Returns:Document

object on which the method was invoked

Exceptions
IllegalAddException:
if the given docType is already attached to a Document.
setPropertyback to summary
public void setProperty(String id, Object value)

Assigns an arbitrary object to be associated with this document under the given "id" string. Null values are permitted. 'id' Strings beginning with "http://www.jdom.org/ are reserved for JDOM use. Properties set with this method will not be serialized with the rest of this Document, should serialization need to be done.

Parameters
id:String

the id of the stored Object

value:Object

the Object to store

setRootElementback to summary
public Document setRootElement(Element rootElement)

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

Parameters
rootElement:Element

Element to be new root.

Returns:Document

Document - modified Document.

Exceptions
IllegalAddException:
if the given rootElement already has a parent.
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

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

Returns:String

String - information about the Document

Annotations
@Override
writeObjectback to summary
private void writeObject(final ObjectOutputStream out) throws IOException

Serialize out the Element.

Parameters
out:ObjectOutputStream

where to write the Element to.

Exceptions
IOException:
if there is a writing problem.
Serial data
Document Properties are not serialized!

The Stream protocol is:

  1. The BaseURI using default Serialization.
  2. The count of child Content
  3. The actual Child Content.