Top Description Inners Fields Constructors Methods
org.jdom

pack-priv final Class ContentList

extends AbstractList
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.util.*, org.jdom.filter.*

A non-public list implementation holding only legal JDOM content, including content for Document or Element nodes. Users see this class as a simple List implementation.
Authors
Alex Rosen, Philippe Riand, Bradley S. Huffman
Version
$Revision: 1.42 $, $Date: 2007/11/10 05:28:58 $
See Also
CDATA, Comment, Element, EntityRef, ProcessingInstruction, Text

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
ContentList.FilterList

FilterList represents legal JDOM content, including content for Documents or Elements.

pack-priv class

Field Summary

Modifier and TypeField and Description
private static final String
private Content[]
elementData

Our backing list

private static final int
private Parent
parent

Document or Element this list belongs to

private static final long
private int
Inherited from java.util.AbstractList:
modCount

Constructor Summary

AccessConstructor and Description
pack-priv
ContentList(Parent parent)

Force either a Document or Element parent

Method Summary

Modifier and TypeMethod and Description
public void
add(int
The location to set the value to.
index
,
Object
The object to insert into the list. throws IndexOutOfBoundsException if index < 0 || index > size()
obj
)

Overrides java.util.AbstractList.add.

Implements java.util.List.add.

Inserts the specified object at the specified position in this list.
pack-priv void
add(int
index where to add Element
index
,
Content
Element to add
child
)

Overrides java.util.AbstractList.add.

Implements java.util.List.add.

Check and add the Element to this list at the given index.
public boolean

Returns:

true if the list was modified as a result of the add.
addAll
(Collection<E>
The collection to add to the list.
collection
)

Overrides java.util.AbstractCollection.addAll.

Implements java.util.List.addAll, java.util.Collection.addAll.

Add the specified collecton to the end of this list.
public boolean

Returns:

true if the list was modified as a result of the add. throws IndexOutOfBoundsException if index < 0 || index > size()
addAll
(int
The offset to start adding the data in the collection
index
,
Collection<E>
The collection to insert into the list.
collection
)

Overrides java.util.AbstractList.addAll.

Implements java.util.List.addAll.

Inserts the specified collecton at the specified position in this list.
public void
clear()

Overrides java.util.AbstractList.clear.

Implements java.util.List.clear, java.util.Collection.clear.

Clear the current list.
pack-priv void
clearAndSet(Collection<E>
The collection to use.
collection
)

Clear the current list and set it to the contents of the Collection.

private void
documentCanContain(int index, Content child)

private static void
elementCanContain(int index, Content child)

pack-priv void
ensureCapacity(int
the desired minimum capacity.
minCapacity
)

Increases the capacity of this ContentList instance, if necessary, to ensure that it can hold at least the number of items specified by the minimum capacity argument.

public Object

Returns:

The Object which was returned.
get
(int
The offset of the object.
index
)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Return the object at the specified offset.
private int
getModCount()

Give access of ContentList.modCount to FilterList

pack-priv List<E>

Returns:

a list representing the rules of the Filter.
getView
(Filter
Filter for this view.
filter
)

Return a view of this list based on the given filter.

pack-priv int

Returns:

index of the DocType, or -1 if it doesn't exist
indexOfDocType
()

Return the index of the DocType element in the list.

pack-priv int

Returns:

index of first element, or -1 if one doesn't exist
indexOfFirstElement
()

Return the index of the first Element in the list.

public Object

Returns:

The Object which was removed.
remove
(int
The offset of the object.
index
)

Overrides java.util.AbstractList.remove.

Implements java.util.List.remove.

Remove the object at the specified offset.
private static void
removeParent(Content c)

Remove the parent of a Object

public Object

Returns:

The object which was replaced. throws IndexOutOfBoundsException if index < 0 || index >= size()
set
(int
The location to set the value to.
index
,
Object
The location to set the value to.
obj
)

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Set the object at the specified location to the supplied object.
public int

Returns:

The number of items in this list.
size
()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Return the number of items in this list
public String

Returns:

The number of items in this list.
toString
()

Overrides java.util.AbstractCollection.toString.

Return this list as a String
pack-priv final void
uncheckedAddContent(Content
content to add without any checks
c
)

Package internal method to support building from sources that are 100% trusted.

Inherited from java.util.AbstractList:
addequalshashCodeindexOfiteratorlastIndexOflistIteratorlistIteratorremoveRangesubList

Field Detail

CVS_IDback to summary
private static final String CVS_ID
elementDataback to summary
private Content[] elementData

Our backing list

INITIAL_ARRAY_SIZEback to summary
private static final int INITIAL_ARRAY_SIZE
parentback to summary
private Parent parent

Document or Element this list belongs to

serialVersionUIDback to summary
private static final long serialVersionUID
sizeback to summary
private int size

Constructor Detail

ContentListback to summary
pack-priv ContentList(Parent parent)

Force either a Document or Element parent

Method Detail

addback to summary
public void add(int index, Object obj)

Overrides java.util.AbstractList.add.

Implements java.util.List.add.

Inserts the specified object at the specified position in this list. Shifts the object currently at that position (if any) and any subsequent objects to the right (adds one to their indices).

Parameters
index:int

The location to set the value to.

obj:Object

The object to insert into the list. throws IndexOutOfBoundsException if index < 0 || index > size()

addback to summary
pack-priv void add(int index, Content child)

Overrides java.util.AbstractList.add.

Implements java.util.List.add.

Check and add the Element to this list at the given index.

Parameters
index:int

index where to add Element

child:Content

Element to add

addAllback to summary
public boolean addAll(Collection<E> collection)

Overrides java.util.AbstractCollection.addAll.

Implements java.util.List.addAll, java.util.Collection.addAll.

Add the specified collecton to the end of this list.

Parameters
collection:Collection<E>

The collection to add to the list.

Returns:boolean

true if the list was modified as a result of the add.

addAllback to summary
public boolean addAll(int index, Collection<E> collection)

Overrides java.util.AbstractList.addAll.

Implements java.util.List.addAll.

Inserts the specified collecton at the specified position in this list. Shifts the object currently at that position (if any) and any subsequent objects to the right (adds one to their indices).

Parameters
index:int

The offset to start adding the data in the collection

collection:Collection<E>

The collection to insert into the list.

Returns:boolean

true if the list was modified as a result of the add. throws IndexOutOfBoundsException if index < 0 || index > size()

clearback to summary
public void clear()

Overrides java.util.AbstractList.clear.

Implements java.util.List.clear, java.util.Collection.clear.

Clear the current list.

clearAndSetback to summary
pack-priv void clearAndSet(Collection<E> collection)

Clear the current list and set it to the contents of the Collection. object.

Parameters
collection:Collection<E>

The collection to use.

documentCanContainback to summary
private void documentCanContain(int index, Content child) throws IllegalAddException
See Also
org.jdom.ContentList#add(int, org.jdom.Content)
elementCanContainback to summary
private static void elementCanContain(int index, Content child) throws IllegalAddException
ensureCapacityback to summary
pack-priv void ensureCapacity(int minCapacity)

Increases the capacity of this ContentList instance, if necessary, to ensure that it can hold at least the number of items specified by the minimum capacity argument.

Parameters
minCapacity:int

the desired minimum capacity.

getback to summary
public Object get(int index)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Return the object at the specified offset.

Parameters
index:int

The offset of the object.

Returns:Object

The Object which was returned.

getModCountback to summary
private int getModCount()

Give access of ContentList.modCount to FilterList

getViewback to summary
pack-priv List<E> getView(Filter filter)

Return a view of this list based on the given filter.

Parameters
filter:Filter

Filter for this view.

Returns:List<E>

a list representing the rules of the Filter.

indexOfDocTypeback to summary
pack-priv int indexOfDocType()

Return the index of the DocType element in the list. If the list contains no DocType, it returns -1.

Returns:int

index of the DocType, or -1 if it doesn't exist

indexOfFirstElementback to summary
pack-priv int indexOfFirstElement()

Return the index of the first Element in the list. If the parent is a Document then the element is the root element. If the list contains no Elements, it returns -1.

Returns:int

index of first element, or -1 if one doesn't exist

removeback to summary
public Object remove(int index)

Overrides java.util.AbstractList.remove.

Implements java.util.List.remove.

Remove the object at the specified offset.

Parameters
index:int

The offset of the object.

Returns:Object

The Object which was removed.

removeParentback to summary
private static void removeParent(Content c)

Remove the parent of a Object

setback to summary
public Object set(int index, Object obj)

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Set the object at the specified location to the supplied object.

Parameters
index:int

The location to set the value to.

obj:Object

The location to set the value to.

Returns:Object

The object which was replaced. throws IndexOutOfBoundsException if index < 0 || index >= size()

sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Return the number of items in this list

Returns:int

The number of items in this list.

toStringback to summary
public String toString()

Overrides java.util.AbstractCollection.toString.

Return this list as a String

Returns:String

The number of items in this list.

uncheckedAddContentback to summary
pack-priv final void uncheckedAddContent(Content c)

Package internal method to support building from sources that are 100% trusted.

Parameters
c:Content

content to add without any checks

org.jdom back to summary

pack-priv Class ContentList.FilterList

extends AbstractList
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

FilterList represents legal JDOM content, including content for Documents or Elements.

Field Summary

Modifier and TypeField and Description
pack-priv int
count

Current number of items in this view

pack-priv int
expected

Expected modCount in our backing list

pack-priv Filter
filter

The Filter

Inherited from java.util.AbstractList:
modCount

Constructor Summary

AccessConstructor and Description
pack-priv
FilterList(Filter filter)

Create a new instance of the FilterList with the specified Filter.

Method Summary

Modifier and TypeMethod and Description
public void
add(int
The location to set the value to.
index
,
Object
The object to insert into the list. throws IndexOutOfBoundsException if index < 0 || index > size()
obj
)

Overrides java.util.AbstractList.add.

Implements java.util.List.add.

Inserts the specified object at the specified position in this list.
public Object

Returns:

The Object which was returned.
get
(int
The offset of the object.
index
)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Return the object at the specified offset.
private final int

Returns:

True index in backing list
getAdjustedIndex
(int
Index of in this view.
index
)

Return the adjusted index

public Iterator<E>
iterator()

Overrides java.util.AbstractList.iterator.

Implements java.util.List.iterator, java.util.Collection.iterator.

Returns an iterator over the elements in this list in proper sequence.
public ListIterator<E>
listIterator()

Overrides java.util.AbstractList.listIterator.

Implements java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence).
public ListIterator<E>
listIterator(int
index of the first element to be returned from the list iterator (by a call to next)
index
)

Overrides java.util.AbstractList.listIterator.

Implements java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list.
public Object

Returns:

The Object which was removed.
remove
(int
The offset of the object.
index
)

Overrides java.util.AbstractList.remove.

Implements java.util.List.remove.

Remove the object at the specified offset.
public Object

Returns:

The object which was replaced. throws IndexOutOfBoundsException if index < 0 || index >= size()
set
(int
The location to set the value to.
index
,
Object
The location to set the value to.
obj
)

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Set the object at the specified location to the supplied object.
public int

Returns:

The number of items in this list.
size
()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Return the number of items in this list
Inherited from java.util.AbstractList:
addaddAllclearequalshashCodeindexOflastIndexOfremoveRangesubList

Field Detail

countback to summary
pack-priv int count

Current number of items in this view

expectedback to summary
pack-priv int expected

Expected modCount in our backing list

filterback to summary
pack-priv Filter filter

The Filter

Constructor Detail

FilterListback to summary
pack-priv FilterList(Filter filter)

Create a new instance of the FilterList with the specified Filter.

Method Detail

addback to summary
public void add(int index, Object obj)

Overrides java.util.AbstractList.add.

Implements java.util.List.add.

Inserts the specified object at the specified position in this list. Shifts the object currently at that position (if any) and any subsequent objects to the right (adds one to their indices).

Parameters
index:int

The location to set the value to.

obj:Object

The object to insert into the list. throws IndexOutOfBoundsException if index < 0 || index > size()

getback to summary
public Object get(int index)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Return the object at the specified offset.

Parameters
index:int

The offset of the object.

Returns:Object

The Object which was returned.

getAdjustedIndexback to summary
private final int getAdjustedIndex(int index)

Return the adjusted index

Parameters
index:int

Index of in this view.

Returns:int

True index in backing list

iteratorback to summary
public Iterator<E> iterator()

Overrides java.util.AbstractList.iterator.

Implements java.util.List.iterator, java.util.Collection.iterator.

Doc from java.util.AbstractList.iterator.

Returns an iterator over the elements in this list in proper sequence.

Returns:Iterator<E>

an iterator over the elements in this list in proper sequence

listIteratorback to summary
public ListIterator<E> listIterator()

Overrides java.util.AbstractList.listIterator.

Implements java.util.List.listIterator.

Doc from java.util.AbstractList.listIterator.

Returns a list iterator over the elements in this list (in proper sequence).

Returns:ListIterator<E>

Doc from java.util.List.listIterator.

a list iterator over the elements in this list (in proper sequence)

listIteratorback to summary
public ListIterator<E> listIterator(int index)

Overrides java.util.AbstractList.listIterator.

Implements java.util.List.listIterator.

Doc from java.util.AbstractList.listIterator.

Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list. The specified index indicates the first element that would be returned by an initial call to next. An initial call to previous would return the element with the specified index minus one.

Parameters
index:int

Doc from java.util.List.listIterator.

index of the first element to be returned from the list iterator (by a call to next)

Returns:ListIterator<E>

Doc from java.util.List.listIterator.

a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list

removeback to summary
public Object remove(int index)

Overrides java.util.AbstractList.remove.

Implements java.util.List.remove.

Remove the object at the specified offset.

Parameters
index:int

The offset of the object.

Returns:Object

The Object which was removed.

setback to summary
public Object set(int index, Object obj)

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Set the object at the specified location to the supplied object.

Parameters
index:int

The location to set the value to.

obj:Object

The location to set the value to.

Returns:Object

The object which was replaced. throws IndexOutOfBoundsException if index < 0 || index >= size()

sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Return the number of items in this list

Returns:int

The number of items in this list.

org.jdom back to summary

pack-priv Class ContentList.FilterListIterator

extends Object
implements ListIterator
Class Inheritance
All Implemented Interfaces
java.util.ListIterator, java.util.Iterator

Field Summary

Modifier and TypeField and Description
private boolean
canremove

Whether a call to remove() is valid

private boolean
canset

Whether a call to set() is valid

private int
cursor

Index in backing list of next object

private int
expected

Expected modCount in our backing list

pack-priv Filter
filter

The Filter that applies

private boolean
forward

Whether this iterator is in forward or reverse.

private int
fsize

Number of elements matching the filter.

private int
index

Index in ListIterator

private int
tmpcursor

the backing index to use if we actually DO move

Constructor Summary

AccessConstructor and Description
pack-priv
FilterListIterator(Filter filter, int start)

Default constructor

Method Summary

Modifier and TypeMethod and Description
public void
add(Object
the element to insert
obj
)

Implements java.util.ListIterator.add.

Inserts the specified element into the list.
private void
checkConcurrentModification()

Check if are backing list is being modified by someone else.

public boolean
hasNext()

Implements java.util.ListIterator.hasNext.

Returns true if this list iterator has a next element.
public boolean
hasPrevious()

Implements java.util.ListIterator.hasPrevious.

Returns true if this list iterator has more elements when traversing the list in the reverse direction.
public Object
next()

Implements java.util.ListIterator.next.

Returns the next element in the list.
public int
nextIndex()

Implements java.util.ListIterator.nextIndex.

Returns the index of the element that would be returned by a subsequent call to next.
public Object
previous()

Implements java.util.ListIterator.previous.

Returns the previous element in the list.
public int
previousIndex()

Implements java.util.ListIterator.previousIndex.

Returns the index of the element that would be returned by a subsequent call to previous.
public void
remove()

Implements java.util.ListIterator.remove.

Removes from the list the last element that was returned by the last call to next or previous.
public void
set(Object
the element with which to replace the last element returned by next or previous
obj
)

Implements java.util.ListIterator.set.

Replaces the last element returned by next or previous with the specified element.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

canremoveback to summary
private boolean canremove

Whether a call to remove() is valid

cansetback to summary
private boolean canset

Whether a call to set() is valid

cursorback to summary
private int cursor

Index in backing list of next object

expectedback to summary
private int expected

Expected modCount in our backing list

filterback to summary
pack-priv Filter filter

The Filter that applies

forwardback to summary
private boolean forward

Whether this iterator is in forward or reverse.

fsizeback to summary
private int fsize

Number of elements matching the filter.

indexback to summary
private int index

Index in ListIterator

tmpcursorback to summary
private int tmpcursor

the backing index to use if we actually DO move

Constructor Detail

FilterListIteratorback to summary
pack-priv FilterListIterator(Filter filter, int start)

Default constructor

Method Detail

addback to summary
public void add(Object obj)

Implements java.util.ListIterator.add.

Inserts the specified element into the list.

Parameters
obj:Object

Doc from java.util.ListIterator.add.

the element to insert

checkConcurrentModificationback to summary
private void checkConcurrentModification()

Check if are backing list is being modified by someone else.

hasNextback to summary
public boolean hasNext()

Implements java.util.ListIterator.hasNext.

Returns true if this list iterator has a next element.

Returns:boolean

Doc from java.util.ListIterator.hasNext.

true if the list iterator has more elements when traversing the list in the forward direction

hasPreviousback to summary
public boolean hasPrevious()

Implements java.util.ListIterator.hasPrevious.

Returns true if this list iterator has more elements when traversing the list in the reverse direction.

Returns:boolean

Doc from java.util.ListIterator.hasPrevious.

true if the list iterator has more elements when traversing the list in the reverse direction

nextback to summary
public Object next()

Implements java.util.ListIterator.next.

Returns the next element in the list.

Returns:Object

Doc from java.util.ListIterator.next.

the next element in the list

nextIndexback to summary
public int nextIndex()

Implements java.util.ListIterator.nextIndex.

Returns the index of the element that would be returned by a subsequent call to next.

Returns:int

Doc from java.util.ListIterator.nextIndex.

the index of the element that would be returned by a subsequent call to next, or list size if the list iterator is at the end of the list

previousback to summary
public Object previous()

Implements java.util.ListIterator.previous.

Returns the previous element in the list.

Returns:Object

Doc from java.util.ListIterator.previous.

the previous element in the list

previousIndexback to summary
public int previousIndex()

Implements java.util.ListIterator.previousIndex.

Returns the index of the element that would be returned by a subsequent call to previous. (Returns -1 if the list iterator is at the beginning of the list.)

Returns:int

Doc from java.util.ListIterator.previousIndex.

the index of the element that would be returned by a subsequent call to previous, or -1 if the list iterator is at the beginning of the list

removeback to summary
public void remove()

Implements java.util.ListIterator.remove.

Removes from the list the last element that was returned by the last call to next or previous.

setback to summary
public void set(Object obj)

Implements java.util.ListIterator.set.

Replaces the last element returned by next or previous with the specified element.

Parameters
obj:Object

Doc from java.util.ListIterator.set.

the element with which to replace the last element returned by next or previous