|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--net.sf.molae.pipe.basic.AbstractListIterator
This class provides a skeletal implementation of the
ListIterator interface,
to minimize the effort required to implement this interface.
It provides an int property that stores the index of the actual
cursor position.
For immutable lists only hasNext() and get() have to be
implemented.
Instead of get(),
next() and previous() can be implemented directly.
For mutable lists use ListBasedListIterator.
| Constructor Summary | |
AbstractListIterator()
|
|
| Method Summary | |
void |
add(Object o)
This implementation always throws an UnsupportedOperationException. |
protected void |
forwardTo(int index)
Calls next() until cursor equals specified index. |
protected Object |
get()
This method can be used as a common body for next() and previous(). |
abstract boolean |
hasNext()
|
boolean |
hasPrevious()
Tests if the value of the cursor is zero. |
Object |
next()
This implementation calls get() and increments the cursor. |
int |
nextIndex()
This implementation returns the value of the cursor. |
Object |
previous()
This implementation decrements the cursor and calls get(). |
int |
previousIndex()
This implementation returns the value of the cursor-1. |
void |
remove()
This implementation always throws an UnsupportedOperationException. |
void |
set(Object o)
This implementation always throws an UnsupportedOperationException. |
protected void |
setCursor(int newCursor)
Replaces the value of the cursor with the specified value. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public AbstractListIterator()
| Method Detail |
protected final void setCursor(int newCursor)
forwardTo(int).newCursor - new value of the underlying cursorprotected void forwardTo(int index)
next() until cursor equals specified index.
Used for starting at a specific position.index - index of first element to be returned from the list
iterator (by a call to the next method).IndexOutOfBoundsException - if
index < 0 || index > size().public abstract boolean hasNext()
hasNext in interface ListIteratorprotected Object get()
next() and previous().
Return the object at current cursor position.public Object next()
get() and increments the cursor.next in interface ListIteratorNoSuchElementException - if the iteration has no next element.public boolean hasPrevious()
cursor is zero.hasPrevious in interface ListIteratortrue if the cursor is zero.public Object previous()
get().previous in interface ListIteratorNoSuchElementException - if the iteration has no previous
element.public int nextIndex()
cursor.nextIndex in interface ListIteratorpublic int previousIndex()
cursor-1.previousIndex in interface ListIteratorpublic void remove()
UnsupportedOperationException.remove in interface ListIteratorpublic void set(Object o)
UnsupportedOperationException.set in interface ListIteratorpublic void add(Object o)
UnsupportedOperationException.add in interface ListIterator
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||