java.lang.Object | +--org.apache.commons.collections.iterators.ArrayIterator | +--org.apache.commons.collections.iterators.ArrayListIteratorAll Implemented Interfaces:
org.apache.commons.collections.iterators.ArrayIterator
java.util.Iterator
java.util.ListIterator
int | Holds the index of the last item returned by a call to next() or previous(). |
Constructor for use with setArray. |
ArrayListIterator(Object array) Constructs an ArrayListIterator that will iterate over the values in the specified array. |
ArrayListIterator(Object array, int startIndex) Constructs an ArrayListIterator that will iterate over the values in the specified array from a specific start index. |
ArrayListIterator(Object array, int startIndex, int endIndex) Construct an ArrayListIterator that will iterate over a range of values in the specified array. |
void | add(Object o) This iterator does not support modification of its backing collection, and so will always throw an UnsupportedOperationException when this method is invoked. |
boolean | Returns true if there are previous elements to return from the array. |
Object | next() Gets the next element from the array. |
int | Gets the next index to be retrieved. |
Object | previous() Gets the previous element from the array. |
int | Gets the index of the item to be retrieved if #previous() is called. |
void | reset() Resets the iterator back to the start index. |
void | set(Object o) Sets the element under the cursor. |
protected int lastItemIndex
next()
or previous()
. This is set to -1
if neither method
has yet been invoked. lastItemIndex
is used to to implement
the set method.
public ArrayListIterator()
setArray
.
Using this constructor, the iterator is equivalent to an empty iterator
until setArray(Object) is called to establish the array to iterate over.
public ArrayListIterator(Object array, int startIndex, int endIndex)
- if array is not an array.
- if the start or end index is out of bounds
- if end index is before the start
- if array is nullpublic ArrayListIterator(Object array, int startIndex)
- if array is not an array.
- if array is null
- if the start index is out of boundspublic ArrayListIterator(Object array)
- if array is not an array.
- if array is nullpublic void add(Object o)
- always thrown.java.util.ListIterator.set
public boolean hasPrevious()
public Object next()
- if there is no next elementpublic int nextIndex()
public Object previous()
- if there is no previous elementpublic int previousIndex()
public void reset()
public void set(Object o)
add()
and remove()
only allow set()
to be called
once per call to next()
or previous
(see the ListIterator
javadoc for more details). Since this implementation does
not support add()
or remove()
, set()
may be
called as often as desired.
java.util.ListIterator.set