net.cscott.jutil

Class UnmodifiableListIterator<E>

public abstract class UnmodifiableListIterator<E> extends Object implements ListIterator<E>

UnmodifiableListIterator is an abstract superclass to save you the trouble of implementing the remove(), add() and set() methods over and over again for those list iterators which don't implement them. The name's a bit clunky, but fits with the JDK naming in java.util.Collections and such.

Version: $Id: UnmodifiableListIterator.java,v 1.1 2003/03/20 01:58:20 cananian Exp $

Author: C. Scott Ananian

Method Summary
voidadd(E o)
Always throws an UnsupportedOperationException.
abstract booleanhasNext()
Returns true if the list iterator has more elements in the forward direction.
abstract booleanhasPrevious()
Returns true if the list iterator has more elements in the reverse direction.
abstract Enext()
Returns the next element in the list.
abstract intnextIndex()
Returns the index of the element that would be returned by a subsequent call to next().
abstract Eprevious()
Returns the previous element in the list.
intpreviousIndex()
Returns the index of the element that would be returned by a subsequent call to previous().
voidremove()
Always throws an UnsupportedOperationException.
voidset(E o)
Always throws an UnsupportedOperationException.

Method Detail

add

public final void add(E o)
Always throws an UnsupportedOperationException.

Throws: UnsupportedOperationException always.

hasNext

public abstract boolean hasNext()
Returns true if the list iterator has more elements in the forward direction.

hasPrevious

public abstract boolean hasPrevious()
Returns true if the list iterator has more elements in the reverse direction.

next

public abstract E next()
Returns the next element in the list. This method may be called repeatedly to iterate through the list, or intermixed with calls to previous() to go back and forth. (Note that alternating calls to next() and previous() will return the same element repeatedly.)

Throws: java.util.NoSuchElementException if the iteration has no next element.

nextIndex

public abstract int nextIndex()
Returns the index of the element that would be returned by a subsequent call to next(). (Returns list size if the list iterator is at the end of the list.)

previous

public abstract E previous()
Returns the previous element in the list. This method may be called repeatedly to iterate through the list backwards, or intermixed with calls to next() to go back and forth. (Note that alternating calls to next() and previous() will return the same element repeatedly.)

Throws: java.util.NoSuchElementException if the iteration has no previous element.

previousIndex

public int previousIndex()
Returns the index of the element that would be returned by a subsequent call to previous(). (Returns -1 if the list iterator is at the beginning of the list.)

remove

public final void remove()
Always throws an UnsupportedOperationException.

Throws: UnsupportedOperationException always.

set

public final void set(E o)
Always throws an UnsupportedOperationException.

Throws: UnsupportedOperationException always.

Copyright © 2003 C. Scott Ananian