java.lang.Object | +--org.apache.commons.collections.iterators.ObjectArrayIterator | +--org.apache.commons.collections.iterators.ObjectArrayListIteratorAll Implemented Interfaces:
org.apache.commons.collections.iterators.ObjectArrayIterator
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. |
ObjectArrayListIterator(Object[] array) Constructs an ObjectArrayListIterator that will iterate over the values in the specified array. |
ObjectArrayListIterator(Object[] array, int start) Constructs an ObjectArrayListIterator that will iterate over the values in the specified array from a specific start index. |
ObjectArrayListIterator(Object[] array, int start, int end) Construct an ObjectArrayListIterator that will iterate over a range of values in the specified array. |
void | add(Object obj) This iterator does not support modification of its backing array's size, 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 obj) 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 ObjectArrayListIterator()
setArray
.
Using this constructor, the iterator is equivalent to an empty iterator
until setArray is called to establish the array to iterate over.
public ObjectArrayListIterator(Object[] array, int start, int end)
- if the start or end index is out of bounds
- if end index is before the start
- if array is nullpublic ObjectArrayListIterator(Object[] array, int start)
- if array is null
- if the start index is out of boundspublic ObjectArrayListIterator(Object[] array)
- if array is nullpublic void add(Object obj)
- always thrown.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 obj)
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.
- if next() has not yet been called.
- if the object type is unsuitable for the array