public abstract class SequentialListSegment<E> extends Segment implements java.util.List<E>
Segment
and java.util.AbstractSequentialList
.
It allows a Segment
based class to implement java.util.List
without having to implement
all of the List
methods explicitly, which would clutter the API documentation with mostly irrelevant methods.
By extending this class, most of the list implementation methods are simply listed in the inherited methods list.
The list is assumed to be immutable.
Attributes
Constructor and Description |
---|
SequentialListSegment(Source source,
int begin,
int end) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E e)
This list is unmodifiable, so this method always throws an
UnsupportedOperationException . |
void |
add(int index,
E element)
This list is unmodifiable, so this method always throws an
UnsupportedOperationException . |
boolean |
addAll(java.util.Collection<? extends E> collection)
This list is unmodifiable, so this method always throws an
UnsupportedOperationException . |
boolean |
addAll(int index,
java.util.Collection<? extends E> collection)
This list is unmodifiable, so this method always throws an
UnsupportedOperationException . |
void |
clear()
This list is unmodifiable, so this method always throws an
UnsupportedOperationException . |
boolean |
contains(java.lang.Object o)
Indicates whether this list contains the specified object.
|
boolean |
containsAll(java.util.Collection<?> collection)
Indicates whether this list contains all of the items in the specified collection.
|
E |
get(int index)
Returns the item at the specified position in this list.
|
abstract int |
getCount()
Returns the number of items in the list.
|
int |
indexOf(java.lang.Object o)
Returns the index in this list of the first occurence of the specified object, or -1 if the list does not contain this object.
|
boolean |
isEmpty()
Indicates whether this list is empty.
|
java.util.Iterator<E> |
iterator()
Returns an iterator over the items in the list in proper sequence.
|
int |
lastIndexOf(java.lang.Object o)
Returns the index in this list of the last occurence of the specified object, or -1 if the list does not contain this object.
|
java.util.ListIterator<E> |
listIterator()
Returns a list iterator of the items in this list (in proper sequence), starting with the first item in the list.
|
abstract java.util.ListIterator<E> |
listIterator(int index)
Returns a list iterator of the items in this list (in proper sequence), starting at the specified position in the list.
|
E |
remove(int index)
This list is unmodifiable, so this method always throws an
UnsupportedOperationException . |
boolean |
remove(java.lang.Object o)
This list is unmodifiable, so this method always throws an
UnsupportedOperationException . |
boolean |
removeAll(java.util.Collection<?> collection)
This list is unmodifiable, so this method always throws an
UnsupportedOperationException . |
boolean |
retainAll(java.util.Collection<?> collection)
This list is unmodifiable, so this method always throws an
UnsupportedOperationException . |
E |
set(int index,
E element)
This list is unmodifiable, so this method always throws an
UnsupportedOperationException . |
int |
size()
Returns the number of items in the list.
|
java.util.List<E> |
subList(int fromIndex,
int toIndex)
Returns a view of the portion of this list between
fromIndex , inclusive, and toIndex , exclusive. |
java.lang.Object[] |
toArray()
Returns an array containing all of the items in this list.
|
<T> T[] |
toArray(T[] a)
Returns an array containing all of the items in this list in the correct order;
the runtime type of the returned array is that of the specified array.
|
charAt, compareTo, encloses, encloses, equals, getAllCharacterReferences, getAllElements, getAllElements, getAllElements, getAllElements, getAllElements, getAllElementsByClass, getAllStartTags, getAllStartTags, getAllStartTags, getAllStartTags, getAllStartTags, getAllStartTagsByClass, getAllTags, getAllTags, getBegin, getChildElements, getDebugInfo, getEnd, getFirstElement, getFirstElement, getFirstElement, getFirstElement, getFirstElementByClass, getFirstStartTag, getFirstStartTag, getFirstStartTag, getFirstStartTag, getFirstStartTag, getFirstStartTagByClass, getFormControls, getFormFields, getMaxDepthIndicator, getNodeIterator, getRenderer, getRowColumnVector, getSource, getStyleURISegments, getTextExtractor, getURIAttributes, hashCode, ignoreWhenParsing, isWhiteSpace, isWhiteSpace, length, parseAttributes, subSequence, toString
public SequentialListSegment(Source source, int begin, int end)
public abstract int getCount()
public abstract java.util.ListIterator<E> listIterator(int index)
The specified index indicates the first item that would be returned by an initial call to the next()
method.
An initial call to the previous()
method would return the item with the specified index minus one.
listIterator
in interface java.util.List<E>
index
- index of the first item to be returned from the list iterator (by a call to the next()
method).java.lang.IndexOutOfBoundsException
- if the specified index is out of range (index < 0 || index > size()
).public E get(int index)
This implementation first gets a list iterator pointing to the indexed item (with listIterator(index)
).
Then, it gets the element using ListIterator.next
and returns it.
get
in interface java.util.List<E>
index
- the index of the item to return.java.lang.IndexOutOfBoundsException
- if the specified index is out of range (index < 0 || index >= size()
).public int size()
This is equivalent to getCount()
,
and is necessary to for the implementation of the java.util.Collection
interface.
public boolean isEmpty()
public boolean contains(java.lang.Object o)
public java.lang.Object[] toArray()
public <T> T[] toArray(T[] a)
If the list fits in the specified array with room to spare (i.e., the array has more elements than the list),
the item in the array immediately following the end of the collection is set to null
.
This is useful in determining the length of the list only
if the caller knows that the list does not contain any null
items.
toArray
in interface java.util.Collection<E>
toArray
in interface java.util.List<E>
a
- the array into which the items of the list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.java.lang.NullPointerException
- if the specified array is null
.java.lang.ArrayStoreException
- if the runtime type of the specified array is not a supertype of the runtime type of every item in this list.public boolean remove(java.lang.Object o)
UnsupportedOperationException
.public boolean containsAll(java.util.Collection<?> collection)
containsAll
in interface java.util.Collection<E>
containsAll
in interface java.util.List<E>
collection
- the collection to be checked for containment in this list.true
if this list contains all of the items in the specified collection, otherwise false
.java.lang.NullPointerException
- if the specified collection is null.contains(Object)
public boolean addAll(java.util.Collection<? extends E> collection)
UnsupportedOperationException
.public boolean removeAll(java.util.Collection<?> collection)
UnsupportedOperationException
.public boolean retainAll(java.util.Collection<?> collection)
UnsupportedOperationException
.public boolean add(E e)
UnsupportedOperationException
.public E set(int index, E element)
UnsupportedOperationException
.set
in interface java.util.List<E>
java.lang.UnsupportedOperationException
public void add(int index, E element)
UnsupportedOperationException
.add
in interface java.util.List<E>
java.lang.UnsupportedOperationException
public E remove(int index)
UnsupportedOperationException
.remove
in interface java.util.List<E>
java.lang.UnsupportedOperationException
public int indexOf(java.lang.Object o)
indexOf
in interface java.util.List<E>
o
- object to search for.public int lastIndexOf(java.lang.Object o)
lastIndexOf
in interface java.util.List<E>
o
- object to search for.public void clear()
UnsupportedOperationException
.public boolean addAll(int index, java.util.Collection<? extends E> collection)
UnsupportedOperationException
.addAll
in interface java.util.List<E>
java.lang.UnsupportedOperationException
public java.util.Iterator<E> iterator()
public java.util.ListIterator<E> listIterator()
listIterator
in interface java.util.List<E>
listIterator(int)
public java.util.List<E> subList(int fromIndex, int toIndex)
fromIndex
, inclusive, and toIndex
, exclusive.
(If fromIndex
and toIndex
are equal, the returned list is empty.)
The returned list is backed by this list, so changes in the returned list are reflected in this list, and vice-versa.
The returned list supports all of the optional list operations supported by this list.subList
in interface java.util.List<E>
fromIndex
- low endpoint (inclusive) of the subList.toIndex
- high endpoint (exclusive) of the subList.java.lang.IndexOutOfBoundsException
- endpoint index value out of range (fromIndex < 0 || toIndex > size)
java.lang.IllegalArgumentException
- endpoint indices out of order (fromIndex > toIndex)
List.subList(int fromIndex, int toIndex)