View Javadoc

1   // UnmodifiableIterator.java, created Tue Jun 15 22:00:21 1999 by cananian
2   // Copyright (C) 1999 C. Scott Ananian <cananian@alumni.princeton.edu>
3   // Licensed under the terms of the GNU GPL; see COPYING for details.
4   package jwutil.collections;
5   
6   import java.util.Iterator;
7   /***
8    * <code>UnmodifiableIterator</code> is an abstract superclass to save
9    * you the trouble of implementing the <code>remove()</code> method
10   * over and over again for those iterators which don't implement it.
11   * The name's a bit clunky, but fits with the JDK naming in
12   * <code>java.util.Collections</code> and etc.
13   * 
14   * @author  C. Scott Ananian <cananian@alumni.princeton.edu>
15   * @version $Id: UnmodifiableIterator.java 1934 2004-09-27 22:42:35Z joewhaley $
16   */
17  public abstract class UnmodifiableIterator implements Iterator {
18      /*** Returns <code>true</code> if the iteration has more elements.
19       * @return <code>true</code> if the iterator has more elements.
20       */
21      public abstract boolean hasNext();
22      /*** Returns the next element in the iteration.
23       * @exception java.util.NoSuchElementException iteration has no more elements.
24       */
25      public abstract Object next();
26      /*** Always throws an <code>UnsupportedOperationException</code>.
27       * @exception UnsupportedOperationException always.
28       */
29      public final void remove() {
30          throw new UnsupportedOperationException("Unmodifiable Iterator");
31      }
32  }