harpoon.Util
Class UnmodifiableListIterator

java.lang.Object
  |
  +--harpoon.Util.UnmodifiableListIterator
All Implemented Interfaces:
Iterator, ListIterator

public abstract class UnmodifiableListIterator
extends Object
implements ListIterator

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.2 2002/02/25 21:08:56 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>

Constructor Summary
UnmodifiableListIterator()
           
 
Method Summary
 void add(Object o)
          Always throws an UnsupportedOperationException.
abstract  boolean hasNext()
          Returns true if the list iterator has more elements in the forward direction.
abstract  boolean hasPrevious()
          Returns true if the list iterator has more elements in the reverse direction.
abstract  Object next()
          Returns the next element in the list.
abstract  int nextIndex()
          Returns the index of the element that would be returned by a subsequent call to next().
abstract  Object previous()
          Returns the previous element in the list.
 int previousIndex()
          Returns the index of the element that would be returned by a subsequent call to previous().
 void remove()
          Always throws an UnsupportedOperationException.
 void set(Object o)
          Always throws an UnsupportedOperationException.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnmodifiableListIterator

public UnmodifiableListIterator()
Method Detail

hasNext

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

Specified by:
hasNext in interface ListIterator

next

public abstract Object 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.)

Specified by:
next in interface ListIterator
Throws:
NoSuchElementException - if the iteration has no next element.

hasPrevious

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

Specified by:
hasPrevious in interface ListIterator

previous

public abstract Object 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.)

Specified by:
previous in interface ListIterator
Throws:
NoSuchElementException - if the iteration has no previous 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.)

Specified by:
nextIndex in interface ListIterator

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.)

Specified by:
previousIndex in interface ListIterator

remove

public final void remove()
Always throws an UnsupportedOperationException.

Specified by:
remove in interface ListIterator
Throws:
UnsupportedOperationException - always.

set

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

Specified by:
set in interface ListIterator
Throws:
UnsupportedOperationException - always.

add

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

Specified by:
add in interface ListIterator
Throws:
UnsupportedOperationException - always.