|
JDOM 1.0beta10 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Superclass for JDOM objects which are allowed to contain
Content
content.
Content
,
Document
,
Element
Method Summary | |
Parent |
addContent(java.util.Collection collection)
Appends all children in the given collection to the end of the content list. |
Parent |
addContent(Content child)
Appends the child to the end of the content list. |
Parent |
addContent(int index,
java.util.Collection collection)
Inserts the content in a collection into the content list at the given index. |
Parent |
addContent(int index,
Content child)
Inserts the child into the content list at the given index. |
void |
canContain(Content child,
int index)
Checks if this parent can contain the given child at the specified position, throwing a descriptive IllegalAddException if not and simply returning if it's allowed. |
java.lang.Object |
clone()
Obtain a deep, unattached copy of this parent and it's children. |
java.util.List |
cloneContent()
Returns a list containing detached clones of this parent's content list. |
java.util.List |
getContent()
Returns the full content of this parent as a List
which contains objects of type Content . |
java.util.List |
getContent(Filter filter)
Returns as a List the content of
this parent that matches the supplied filter. |
Content |
getContent(int index)
Returns the child at the given index. |
int |
getContentSize()
Returns the number of children in this parent's content list. |
java.util.Iterator |
getDescendants()
Returns an Iterator that walks over all descendants
in document order. |
java.util.Iterator |
getDescendants(Filter filter)
Returns an Iterator that walks over all descendants
in document order applying the Filter to return only elements that
match the filter rule. |
Document |
getDocument()
Return this parent's owning document or null if the branch containing this parent is currently not attached to a document. |
Parent |
getParent()
Return this parent's parent, or null if this parent is currently not attached to another parent. |
int |
indexOf(Content child)
Returns the index of the supplied child in the content list, or -1 if not a child of this parent. |
java.util.List |
removeContent()
Removes all content from this parent and returns the detached children. |
boolean |
removeContent(Content child)
Removes a single child node from the content list. |
java.util.List |
removeContent(Filter filter)
Removes from this parent all child content matching the given filter and returns a list of the detached children. |
Content |
removeContent(int index)
Removes and returns the child at the given index, or returns null if there's no such child. |
Parent |
setContent(java.util.Collection collection)
Sets this parent's content to the supplied content list. |
Parent |
setContent(Content child)
Set this parent's content to the supplied child. |
Parent |
setContent(int index,
java.util.Collection collection)
Replaces the child at the given index whith the supplied collection. |
Parent |
setContent(int index,
Content child)
Replaces the current child the given index with the supplied child. |
Method Detail |
public int getContentSize()
Content
type.
public int indexOf(Content child)
child
- child to search for
public Parent addContent(Content child)
child
- child to append to end of content list
public Parent addContent(java.util.Collection collection)
collection
- collection to append
public Parent addContent(int index, Content child)
child
- child to insert
java.lang.IndexOutOfBoundsException
- if index is negative or beyond
the current number of childrenpublic Parent addContent(int index, java.util.Collection collection)
collection
- collection to insert
java.lang.IndexOutOfBoundsException
- if index is negative or beyond
the current number of childrenpublic java.util.List cloneContent()
public Content getContent(int index)
index
- location of desired child
java.lang.IndexOutOfBoundsException
- if index is negative or beyond
the current number of children
java.lang.IllegalStateException
- if parent is a Document
and the root element is not setpublic java.util.List getContent()
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 List.size()
may
require walking the entire list and indexed lookups may require
starting at the beginning each time.
java.lang.IllegalStateException
- if parent is a Document
and the root element is not setpublic java.util.List getContent(Filter filter)
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 List.size()
may
require walking the entire list and indexed lookups may require
starting at the beginning each time.
filter
- filter to apply
java.lang.IllegalStateException
- if parent is a Document
and the root element is not setpublic java.util.List removeContent()
public java.util.List removeContent(Filter filter)
filter
- filter to apply
public boolean removeContent(Content child)
child
- child to remove
public Content removeContent(int index)
index
- index of child to remove
java.lang.IndexOutOfBoundsException
- if index is negative or beyond
the current number of childrenpublic Parent setContent(Content child)
If the supplied child is legal content for this parent 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(int)
methods will also change
to reflect the new content. In addition, all content in the supplied
collection will have their parentage set to this parent. If the user
wants to continue working with a "live" list of this parent's
child, then a call to setContent should be followed by a call to one
of the getContent(int)
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.
child
- new content to replace existing content
IllegalAddException
- if the supplied child is already attached
or not legal content for this parentpublic Parent setContent(java.util.Collection collection)
Content
.
If the supplied content is legal content for this parent 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(int)
methods will also change
to reflect the new content. In addition, all content in the supplied
collection will have their parentage set to this parent. If the user
wants to continue working with a "live" list of this parent's
child, then a call to setContent should be followed by a call to one
of the getContent(int)
methods to obtain a "live"
version of the children.
Passing a null or empty Collection clears the existing content.
In event of an exception the original content will be unchanged and the content in the supplied collection will be unaltered.
collection
- new collection of content to replace existing content
IllegalAddException
- if any object in the supplied content is
already attached or not legal content for this parentpublic Parent setContent(int index, Content child)
In event of an exception the original content will be unchanged and the supplied child will be unaltered.
index
- index of child to replacechild
- new content to replace the existing content
IllegalAddException
- if the supplied child is already attached
or not legal content for this parent
java.lang.IndexOutOfBoundsException
- if index is negative or beyond
the current number of childrenpublic Parent setContent(int index, java.util.Collection collection)
In event of an exception the original content will be unchanged and the content in the supplied collection will be unaltered.
index
- index of child to replacecollection
- collection of content to add
IllegalAddException
- if any object in the supplied content is
already attached or not legal content for this parent
java.lang.IndexOutOfBoundsException
- if index is negative or beyond
the current number of childrenpublic java.lang.Object clone()
public java.util.Iterator getDescendants()
Iterator
that walks over all descendants
in document order.
public java.util.Iterator getDescendants(Filter filter)
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.
public Parent getParent()
public Document getDocument()
public void canContain(Content child, int index) throws IllegalAddException
child
- the potential child to be added to this parentindex
- the location for the potential child
IllegalAddException
- if the child add isn't allowed
|
JDOM 1.0beta10 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |