com.darwinsys.util
Class EnumerationIterator<T>

java.lang.Object
  extended by com.darwinsys.util.EnumerationIterator<T>
All Implemented Interfaces:
java.util.Iterator

public class EnumerationIterator<T>
extends java.lang.Object
implements java.util.Iterator

A GOF Adapter to make instances of old Enumeration interface behave like new Iterator interface, so we only have to deal with one well-defined implementation of the Iterator pattern.


Constructor Summary
EnumerationIterator(java.util.Enumeration<T> old)
          Construct an EnumerationIterator from an old-style Enumeration.
 
Method Summary
 boolean hasNext()
          Fulfills the general contract of Iterator.hasNext(), that is, return true as long as there is at least one more item in the Iterator.
 T next()
          Fulfuls the general contract of Iterator.next(), that is, returns the next element in the Iterator.
 void remove()
          Remove is not implemented (optional method).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnumerationIterator

public EnumerationIterator(java.util.Enumeration<T> old)
Construct an EnumerationIterator from an old-style Enumeration.

Parameters:
old - The Enumeration to be adapted.
Method Detail

hasNext

public boolean hasNext()
Fulfills the general contract of Iterator.hasNext(), that is, return true as long as there is at least one more item in the Iterator.

Specified by:
hasNext in interface java.util.Iterator

next

public T next()
Fulfuls the general contract of Iterator.next(), that is, returns the next element in the Iterator.

Specified by:
next in interface java.util.Iterator

remove

public void remove()
Remove is not implemented (optional method).

Specified by:
remove in interface java.util.Iterator
Throws:
java.lang.UnsupportedOperationException - in all cases.


Copyright © 1996-2004 Ian F. Darwin. See license.html for usage license.