Class SequentialListSegment<E>
- java.lang.Object
-
- Segment
-
- net.htmlparser.jericho.nodoc.SequentialListSegment<E>
-
- All Implemented Interfaces:
java.lang.CharSequence
,java.lang.Comparable<Segment>
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.List<E>
- Direct Known Subclasses:
Attributes
public abstract class SequentialListSegment<E> extends Segment implements java.util.List<E>
A base class used internally to simulate multiple inheritance ofSegment
andjava.util.AbstractSequentialList
.It allows a
Segment
based class to implementjava.util.List
without having to implement all of theList
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:
Attributes
-
-
Constructor Summary
Constructors Constructor Description SequentialListSegment(Source source, int begin, int end)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
add(int index, E element)
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.boolean
add(E e)
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.boolean
addAll(int index, java.util.Collection<? extends E> collection)
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.boolean
addAll(java.util.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
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 anUnsupportedOperationException
.boolean
remove(java.lang.Object o)
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.boolean
removeAll(java.util.Collection<?> collection)
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.boolean
retainAll(java.util.Collection<?> collection)
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.E
set(int index, E element)
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.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 betweenfromIndex
, inclusive, andtoIndex
, 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.-
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
-
-
-
-
Constructor Detail
-
SequentialListSegment
public SequentialListSegment(Source source, int begin, int end)
-
-
Method Detail
-
getCount
public abstract int getCount()
Returns the number of items in the list.- Returns:
- the number of items in the list.
-
listIterator
public 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.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 interfacejava.util.List<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:
java.lang.IndexOutOfBoundsException
- if the specified index is out of range (index < 0 || index > size()
).
-
get
public E get(int index)
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 interfacejava.util.List<E>
- Parameters:
index
- the index of the item to return.- Returns:
- the item at the specified position in this list.
- Throws:
java.lang.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.
-
contains
public boolean contains(java.lang.Object o)
Indicates whether this list contains the specified object.
-
toArray
public java.lang.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 interfacejava.util.Collection<E>
- Specified by:
toArray
in interfacejava.util.List<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:
java.lang.NullPointerException
- if the specified array isnull
.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.
-
remove
public boolean remove(java.lang.Object o)
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.
-
containsAll
public boolean containsAll(java.util.Collection<?> collection)
Indicates whether this list contains all of the items in the specified collection.- Specified by:
containsAll
in interfacejava.util.Collection<E>
- Specified by:
containsAll
in interfacejava.util.List<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:
java.lang.NullPointerException
- if the specified collection is null.- See Also:
contains(Object)
-
addAll
public boolean addAll(java.util.Collection<? extends E> collection)
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.
-
removeAll
public boolean removeAll(java.util.Collection<?> collection)
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.
-
retainAll
public boolean retainAll(java.util.Collection<?> collection)
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.
-
add
public boolean add(E e)
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.
-
set
public E set(int index, E element)
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.- Specified by:
set
in interfacejava.util.List<E>
- Throws:
java.lang.UnsupportedOperationException
-
add
public void add(int index, E element)
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.- Specified by:
add
in interfacejava.util.List<E>
- Throws:
java.lang.UnsupportedOperationException
-
remove
public E remove(int index)
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.- Specified by:
remove
in interfacejava.util.List<E>
- Throws:
java.lang.UnsupportedOperationException
-
indexOf
public 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.- Specified by:
indexOf
in interfacejava.util.List<E>
- Parameters:
o
- object to search for.- 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
public 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.- Specified by:
lastIndexOf
in interfacejava.util.List<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
.
-
addAll
public boolean addAll(int index, java.util.Collection<? extends E> collection)
This list is unmodifiable, so this method always throws anUnsupportedOperationException
.- Specified by:
addAll
in interfacejava.util.List<E>
- Throws:
java.lang.UnsupportedOperationException
-
iterator
public java.util.Iterator<E> iterator()
Returns an iterator over the items in the list in proper sequence.
-
listIterator
public 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.- Specified by:
listIterator
in interfacejava.util.List<E>
- Returns:
- a list iterator of the items in this list (in proper sequence), starting with the first item in the list.
- See Also:
listIterator(int)
-
subList
public java.util.List<E> subList(int fromIndex, int toIndex)
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 interfacejava.util.List<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:
java.lang.IndexOutOfBoundsException
- endpoint index value out of range(fromIndex < 0 || toIndex > size)
java.lang.IllegalArgumentException
- endpoint indices out of order(fromIndex > toIndex)
- See Also:
List.subList(int fromIndex, int toIndex)
-
-