Top Description Methods
org.jdom

public Interface Parent

extends Cloneable, Serializable
Known Direct Implementers
org.jdom.Document, org.jdom.Element
Imports
java.io.Serializable, java.util.*, org.jdom.filter.Filter

Superclass for JDOM objects which are allowed to contain Content content.
Authors
Bradley S. Huffman, Jason Hunter
Version
$Revision: 1.13 $, $Date: 2007/11/10 05:28:59 $
See Also
org.jdom.Content, org.jdom.Document, org.jdom.Element

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

a deep copy of this parent and it's children.
clone
()

Obtain a deep, unattached copy of this parent and it's children.

public List<E>

Returns:

list of cloned child content
cloneContent
()

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

public Content

Returns:

child at the given index
getContent
(int
location of desired child
index
)

Returns the child at the given index.

public List<E>

Returns:

a list of the content of the parent
getContent
()

Returns the full content of this parent as a java.util.List which contains objects of type Content.

public List<E>

Returns:

a list of the content of the parent matching the filter
getContent
(Filter
filter to apply
filter
)

Returns as a java.util.List the content of this parent that matches the supplied filter.

public int

Returns:

number of children
getContentSize
()

Returns the number of children in this parent's content list.

public Iterator<E>

Returns:

an iterator to walk descendants
getDescendants
()

Returns an java.util.Iterator that walks over all descendants in document order.

public Iterator<E>

Returns:

an iterator to walk descendants that match a filter
getDescendants
(Filter
filter to select which descendants to see
filter
)

Returns an java.util.Iterator that walks over all descendants in document order applying the Filter to return only elements that match the filter rule.

public Document

Returns:

this child's owning document or null if none
getDocument
()

Return this parent's owning document or null if the branch containing this parent is currently not attached to a document.

public Parent

Returns:

this parent's parent or null if none
getParent
()

Return this parent's parent, or null if this parent is currently not attached to another parent.

public int

Returns:

index of child, or -1 if not found
indexOf
(Content
child to search for
child
)

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

public List<E>

Returns:

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

Removes all content from this parent and returns the detached children.

public List<E>

Returns:

list of the detached children matching the filter
removeContent
(Filter
filter to apply
filter
)

Removes from this parent all child content matching the given filter and returns a list of the detached children.

public boolean

Returns:

whether the removal occurred
removeContent
(Content
child to remove
child
)

Removes a single child node from the content list.

public Content

Returns:

detached child at given index or null if no
removeContent
(int
index of child to remove
index
)

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

Method Detail

cloneback to summary
public Object clone()

Obtain a deep, unattached copy of this parent and it's children.

Returns:Object

a deep copy of this parent and it's children.

cloneContentback to summary
public List<E> cloneContent()

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

Returns:List<E>

list of cloned child content

getContentback to summary
public Content getContent(int index)

Returns the child at the given index.

Parameters
index:int

location of desired child

Returns:Content

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
getContentback to summary
public List<E> getContent()

Returns the full content of this parent as a java.util.List which contains objects of type Content. The returned list is "live" and in document order. Any modifications to it affect the element's actual contents. Modifications are checked for conformance to XML 1.0 rules.

Sequential traversal through the List is best done with an Iterator since the underlying implement of java.util.List#size may require walking the entire list and indexed lookups may require starting at the beginning each time.

Returns:List<E>

a list of the content of the parent

Exceptions
IllegalStateException:
if parent is a Document and the root element is not set
getContentback to summary
public List<E> getContent(Filter filter)

Returns as a java.util.List the content of this parent that matches the supplied filter. The returned list is "live" and in document order. Any modifications to it affect the element's actual contents. Modifications are checked for conformance to XML 1.0 rules.

Sequential traversal through the List is best done with an Iterator since the underlying implement of java.util.List#size may require walking the entire list and indexed lookups may require starting at the beginning each time.

Parameters
filter:Filter

filter to apply

Returns:List<E>

a list of the content of the parent matching the filter

Exceptions
IllegalStateException:
if parent is a Document and the root element is not set
getContentSizeback to summary
public int getContentSize()

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

Returns:int

number of children

getDescendantsback to summary
public Iterator<E> getDescendants()

Returns an java.util.Iterator that walks over all descendants in document order.

Returns:Iterator<E>

an iterator to walk descendants

getDescendantsback to summary
public Iterator<E> getDescendants(Filter filter)

Returns an java.util.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

filter to select which descendants to see

Returns:Iterator<E>

an iterator to walk descendants that match a filter

getDocumentback to summary
public Document getDocument()

Return this parent's owning document or null if the branch containing this parent is currently not attached to a document.

Returns:Document

this child's owning document or null if none

getParentback to summary
public Parent getParent()

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

this parent's parent or null if none

indexOfback to summary
public int indexOf(Content child)

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

removeContentback to summary
public List<E> removeContent()

Removes all content from this parent and returns the detached children.

Returns:List<E>

list of the old content detached from this parent

removeContentback to summary
public List<E> removeContent(Filter filter)

Removes from this parent all child content matching the given filter and returns a list of the detached children.

Parameters
filter:Filter

filter to apply

Returns:List<E>

list of the detached children matching the filter

removeContentback to summary
public boolean removeContent(Content child)

Removes a single child node from the content list.

Parameters
child:Content

child to remove

Returns:boolean

whether the removal occurred

removeContentback to summary
public Content removeContent(int index)

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

Exceptions
IndexOutOfBoundsException:
if index is negative or beyond the current number of children