Class SequentialListSegment<E>
- All Implemented Interfaces:
CharSequence, Comparable<Segment>, Iterable<E>, Collection<E>, List<E>, SequencedCollection<E>
- Direct Known Subclasses:
Attributes
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.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThis list is unmodifiable, so this method always throws anUnsupportedOperationException.booleanThis list is unmodifiable, so this method always throws anUnsupportedOperationException.booleanaddAll(int index, Collection<? extends E> collection) This list is unmodifiable, so this method always throws anUnsupportedOperationException.booleanaddAll(Collection<? extends E> collection) This list is unmodifiable, so this method always throws anUnsupportedOperationException.voidclear()This list is unmodifiable, so this method always throws anUnsupportedOperationException.booleanIndicates whether this list contains the specified object.booleancontainsAll(Collection<?> collection) Indicates whether this list contains all of the items in the specified collection.get(int index) Returns the item at the specified position in this list.abstract intgetCount()Returns the number of items in the list.intReturns the index in this list of the first occurence of the specified object, or -1 if the list does not contain this object.booleanisEmpty()Indicates whether this list is empty.iterator()Returns an iterator over the items in the list in proper sequence.intReturns the index in this list of the last occurence of the specified object, or -1 if the list does not contain this object.Returns a list iterator of the items in this list (in proper sequence), starting with the first item in the list.abstract 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.remove(int index) This list is unmodifiable, so this method always throws anUnsupportedOperationException.booleanThis list is unmodifiable, so this method always throws anUnsupportedOperationException.booleanremoveAll(Collection<?> collection) This list is unmodifiable, so this method always throws anUnsupportedOperationException.booleanretainAll(Collection<?> collection) This list is unmodifiable, so this method always throws anUnsupportedOperationException.This list is unmodifiable, so this method always throws anUnsupportedOperationException.intsize()Returns the number of items in the list.subList(int fromIndex, int toIndex) Returns a view of the portion of this list betweenfromIndex, inclusive, andtoIndex, exclusive.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.Methods inherited from class Segment
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, toStringMethods inherited from interface CharSequence
chars, codePoints, getCharsMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
-
Constructor Details
-
SequentialListSegment
-
-
Method Details
-
getCount
public abstract int getCount()Returns the number of items in the list.- Returns:
- the number of items in the list.
-
listIterator
Returns a list iterator of the items in this list (in proper sequence), starting at the specified position in the list.The specified index indicates the first item that would be returned by an initial call to the
next()method. An initial call to theprevious()method would return the item with the specified index minus one.- Specified by:
listIteratorin interfaceList<E>- Parameters:
index- index of the first item to be returned from the list iterator (by a call to thenext()method).- Returns:
- a list iterator of the items in this list (in proper sequence), starting at the specified position in the list.
- Throws:
IndexOutOfBoundsException- if the specified index is out of range (index < 0 || index > size()).
-
get
Returns the item at the specified position in this list.This implementation first gets a list iterator pointing to the indexed item (with
listIterator(index)). Then, it gets the element usingListIterator.nextand returns it.- Specified by:
getin interfaceList<E>- Parameters:
index- the index of the item to return.- Returns:
- the item at the specified position in this list.
- Throws:
IndexOutOfBoundsException- if the specified index is out of range (index < 0 || index >= size()).
-
size
public int size()Returns the number of items in the list.This is equivalent to
getCount(), and is necessary to for the implementation of thejava.util.Collectioninterface. -
isEmpty
public boolean isEmpty()Indicates whether this list is empty.- Specified by:
isEmptyin interfaceCharSequence- Specified by:
isEmptyin interfaceCollection<E>- Specified by:
isEmptyin interfaceList<E>- Returns:
trueif there are no items in the list, otherwisefalse.
-
contains
Indicates whether this list contains the specified object. -
toArray
-
toArray
public <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. If the list fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this list.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 anynullitems.- Specified by:
toArrayin interfaceCollection<E>- Specified by:
toArrayin interfaceList<E>- Parameters:
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.- Returns:
- an array containing the items of the list.
- Throws:
NullPointerException- if the specified array isnull.ArrayStoreException- if the runtime type of the specified array is not a supertype of the runtime type of every item in this list.
-
remove
This list is unmodifiable, so this method always throws anUnsupportedOperationException.- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceList<E>- Throws:
UnsupportedOperationException
-
containsAll
Indicates whether this list contains all of the items in the specified collection.- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>- Parameters:
collection- the collection to be checked for containment in this list.- Returns:
trueif this list contains all of the items in the specified collection, otherwisefalse.- Throws:
NullPointerException- if the specified collection is null.- See Also:
-
addAll
This list is unmodifiable, so this method always throws anUnsupportedOperationException.- Specified by:
addAllin interfaceCollection<E>- Specified by:
addAllin interfaceList<E>- Throws:
UnsupportedOperationException
-
removeAll
This list is unmodifiable, so this method always throws anUnsupportedOperationException.- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceList<E>- Throws:
UnsupportedOperationException
-
retainAll
This list is unmodifiable, so this method always throws anUnsupportedOperationException.- Specified by:
retainAllin interfaceCollection<E>- Specified by:
retainAllin interfaceList<E>- Throws:
UnsupportedOperationException
-
add
This list is unmodifiable, so this method always throws anUnsupportedOperationException.- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceList<E>- Throws:
UnsupportedOperationException
-
set
-
add
This list is unmodifiable, so this method always throws anUnsupportedOperationException.- Specified by:
addin interfaceList<E>- Throws:
UnsupportedOperationException
-
remove
This list is unmodifiable, so this method always throws anUnsupportedOperationException.- Specified by:
removein interfaceList<E>- Throws:
UnsupportedOperationException
-
indexOf
Returns the index in this list of the first occurence of the specified object, or -1 if the list does not contain this object. -
lastIndexOf
Returns the index in this list of the last occurence of the specified object, or -1 if the list does not contain this object.- Specified by:
lastIndexOfin interfaceList<E>- Parameters:
o- object to search for.- Returns:
- the index in this list of the last occurence of the specified object, or -1 if the list does not contain this object.
-
clear
public void clear()This list is unmodifiable, so this method always throws anUnsupportedOperationException.- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceList<E>- Throws:
UnsupportedOperationException
-
addAll
This list is unmodifiable, so this method always throws anUnsupportedOperationException.- Specified by:
addAllin interfaceList<E>- Throws:
UnsupportedOperationException
-
iterator
Returns an iterator over the items in the list in proper sequence. -
listIterator
Returns a list iterator of the items in this list (in proper sequence), starting with the first item in the list.- Specified by:
listIteratorin interfaceList<E>- Returns:
- a list iterator of the items in this list (in proper sequence), starting with the first item in the list.
- See Also:
-
subList
Returns a view of the portion of this list betweenfromIndex, inclusive, andtoIndex, exclusive. (IffromIndexandtoIndexare 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.- Specified by:
subListin interfaceList<E>- Parameters:
fromIndex- low endpoint (inclusive) of the subList.toIndex- high endpoint (exclusive) of the subList.- Returns:
- a view of the specified range within this list.
- Throws:
IndexOutOfBoundsException- endpoint index value out of range(fromIndex < 0 || toIndex > size)IllegalArgumentException- endpoint indices out of order(fromIndex > toIndex)- See Also:
-