Class SequentialListSegment<E>
- All Implemented Interfaces:
CharSequence
,Comparable<Segment>
,Iterable<E>
,Collection<E>
,List<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 TypeMethodDescriptionvoid
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.boolean
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.boolean
addAll
(int index, Collection<? extends E> collection) This list is unmodifiable, so this method always throws anUnsupportedOperationException
.boolean
addAll
(Collection<? extends E> collection) This list is unmodifiable, so this method always throws anUnsupportedOperationException
.void
clear()
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.boolean
Indicates whether this list contains the specified object.boolean
containsAll
(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 int
getCount()
Returns the number of items in the list.int
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.iterator()
Returns an iterator over the items in the list in proper sequence.int
Returns 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
.boolean
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.boolean
removeAll
(Collection<?> collection) This list is unmodifiable, so this method always throws anUnsupportedOperationException
.boolean
retainAll
(Collection<?> collection) This list is unmodifiable, so this method always throws anUnsupportedOperationException
.This list is unmodifiable, so this method always throws anUnsupportedOperationException
.int
size()
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 net.htmlparser.jericho.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, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
equals, hashCode, replaceAll, 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:
listIterator
in 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.next
and returns it.- Specified by:
get
in 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.Collection
interface. -
isEmpty
public boolean isEmpty()Indicates whether this list is empty.- Specified by:
isEmpty
in interfaceCharSequence
- Specified by:
isEmpty
in interfaceCollection<E>
- Specified by:
isEmpty
in interfaceList<E>
- Returns:
true
if there are no items in the list, otherwisefalse
.
-
contains
Indicates whether this list contains the specified object. -
toArray
Returns an array containing all of the items in this list. -
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 anynull
items.- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in 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:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceList<E>
- Throws:
UnsupportedOperationException
-
containsAll
Indicates whether this list contains all of the items in the specified collection.- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceList<E>
- Parameters:
collection
- the collection to be checked for containment in this list.- Returns:
true
if 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:
addAll
in interfaceCollection<E>
- Specified by:
addAll
in interfaceList<E>
- Throws:
UnsupportedOperationException
-
removeAll
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.- Specified by:
removeAll
in interfaceCollection<E>
- Specified by:
removeAll
in interfaceList<E>
- Throws:
UnsupportedOperationException
-
retainAll
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.- Specified by:
retainAll
in interfaceCollection<E>
- Specified by:
retainAll
in interfaceList<E>
- Throws:
UnsupportedOperationException
-
add
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceList<E>
- Throws:
UnsupportedOperationException
-
set
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.- Specified by:
set
in interfaceList<E>
- Throws:
UnsupportedOperationException
-
add
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.- Specified by:
add
in interfaceList<E>
- Throws:
UnsupportedOperationException
-
remove
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.- Specified by:
remove
in 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:
lastIndexOf
in 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:
clear
in interfaceCollection<E>
- Specified by:
clear
in interfaceList<E>
- Throws:
UnsupportedOperationException
-
addAll
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.- Specified by:
addAll
in 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:
listIterator
in 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. (IffromIndex
andtoIndex
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.- Specified by:
subList
in 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:
-