Top Description Inners Fields Constructors Methods
org.jdom2

pack-priv final Class ContentList

extends AbstractList<Content>
implements RandomAccess
Class Inheritance
All Implemented Interfaces
java.util.RandomAccess
Imports
java.util.*, org.jdom2.filter.*, org.jdom2.internal.ArrayCopy

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, Rolf Lear
See Also
DocType, CDATA, Comment, Element, EntityRef, ProcessingInstruction, Text

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
ContentList.CLIterator

A fast implementation of Iterator.

private class
ContentList.CLListIterator

A fast implementation of Iterator.

pack-priv class
ContentList.FilterList<
The Generic type of content accepted by the underlying Filter.
F extends Content
>

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

pack-priv class

Field Summary

Modifier and TypeField and Description
private transient int
dataModiCount

modCount is used for concurrent modification, but dataModCount is used for refreshing filters.

private Content[]
elementData

Our backing list

private static final int
private final Parent
parent

Document or Element this list belongs to

private int
size

The amount of valid content in elementData

private transient int
sizeModCount

Completely remove references to AbstractList.modCount because in ContentList it is confusing.

Inherited from java.util.AbstractList:
modCount

Constructor Summary

AccessConstructor and Description
pack-priv
ContentList(final Parent
the Element this ContentList belongs to.
parent
)

Force either a Document or Element parent

Method Summary

Modifier and TypeMethod and Description
public void
add(final int
index where to add Element
index
,
final Content
Content to add
child
)

Overrides java.util.AbstractList.add.

Implements java.util.List.add.

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

Returns:

true if the list was modified as a result of the add.
addAll
(final Collection<? extends Content>
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 collection 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
(final int
The offset to start adding the data in the collection
index
,
final Collection<? extends Content>
The collection to insert into the list.
collection
)

Overrides java.util.AbstractList.addAll.

Implements java.util.List.addAll.

Inserts the specified collection at the specified position in this list.
private final int

Returns:

the insertion point.
binarySearch
(final int[]
THe pointers to search within
indexes
,
final int
The number of pointers to search within
len
,
final int
The pointer we are checking for.
val
,
final Comparator<? super Content>
The Comparator to compare with
comp
)

Unlike the Arrays.binarySearch, this method never expects an "already exists" condition, we only ever add, thus there will never be a negative insertion-point.

private final void
checkIndex(final int index, final boolean excludes)

private final void
checkPreConditions(final Content child, final int index, final boolean replace)

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(final Collection<? extends Content>
The collection to use.
collection
)

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

pack-priv void
ensureCapacity(final 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 Content

Returns:

The Object which was returned.
get
(final 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:

the current data mode count.
getDataModCount
()

Get the modcount of data changes.

private final int

Returns:

mod the value.
getModCount
()

In the FilterList and FilterList iterators it becomes confusing as to which modCount is being used.

pack-priv <
The Generic type of the content as set by the Filter.
E extends Content
>
List<E>

Returns:

a list representing the rules of the Filter.
getView
(final Filter<E>
Filter for this view.
filter
)

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

private final void
private final void
incModCount()

In the FilterList and FilterList iterators it becomes confusing as to which modCount is being used.

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 Iterator<Content>
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<Content>
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<Content>
listIterator(final int
index of the first element to be returned from the list iterator (by a call to next)
start
)

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 Content

Returns:

The Object which was removed.
remove
(final 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(final Content c)

Remove the parent of a Object

public Content

Returns:

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

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Set the object at the specified location to the supplied object.
private final void
setModCount(final int
the value to set for the size-mod count.
sizemod
,
final int
the value to set for the data-mod count.
datamod
)

In the FilterList and FilterList iterators it becomes confusing as to which modCount is being used.

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 final void
sort(final Comparator<? super Content>
- the Comparator used to compare list elements. A null value indicates that the elements' natural ordering should be used
comp
)

Overrides default java.util.List.sort.

Sorts this list using the supplied Comparator to compare elements.
private void
sortInPlace(final int[] indexes)

public String

Returns:

The String representation of this list.
toString
()

Overrides java.util.AbstractCollection.toString.

Return this list as a String
pack-priv final void
uncheckedAddContent(final 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:
addequalshashCodeindexOflastIndexOfremoveRangesubList