pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.util
Class IteratorEnumerationBridge<E>

java.lang.Object
  extended by org.torweg.pulse.util.IteratorEnumerationBridge<E>
Type Parameters:
E - the type of the bridged Enumeration/Iterator
All Implemented Interfaces:
java.lang.Iterable<E>, java.util.Enumeration<E>, java.util.Iterator<E>

public final class IteratorEnumerationBridge<E>
extends java.lang.Object
implements java.util.Iterator<E>, java.util.Enumeration<E>, java.lang.Iterable<E>

a bridge between Iterator and Enumeration.

This class allows you to treat an Enumeration as an Iterator and vice versa. Moreover it can be directly used in for-each loops (enhanced for loops).

Version:
$Revision$
Author:
Thomas Weber

Constructor Summary
IteratorEnumerationBridge(java.util.Enumeration<E> e)
          creates a new IteratorEnumerationBridge operating on the given Enumeration.
IteratorEnumerationBridge(java.util.Iterator<E> i)
          creates a new IteratorEnumerationBridge operating on the given Iterator.
 
Method Summary
 boolean hasMoreElements()
          
 boolean hasNext()
          
 java.util.Iterator<E> iterator()
          
 E next()
          
 E nextElement()
          
 void remove()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IteratorEnumerationBridge

public IteratorEnumerationBridge(java.util.Enumeration<E> e)
creates a new IteratorEnumerationBridge operating on the given Enumeration.

Parameters:
e - the enumeration to be bridged

IteratorEnumerationBridge

public IteratorEnumerationBridge(java.util.Iterator<E> i)
creates a new IteratorEnumerationBridge operating on the given Iterator.

Parameters:
i - the iterator to be bridged
Method Detail

hasMoreElements

public boolean hasMoreElements()

Specified by:
hasMoreElements in interface java.util.Enumeration<E>

nextElement

public E nextElement()

Specified by:
nextElement in interface java.util.Enumeration<E>

hasNext

public boolean hasNext()

Specified by:
hasNext in interface java.util.Iterator<E>

next

public E next()

Specified by:
next in interface java.util.Iterator<E>

remove

public void remove()

Specified by:
remove in interface java.util.Iterator<E>
Throws:
java.lang.UnsupportedOperationException - if the underlying type is a Enumeration or the underlying Iterator does not support the remove operation
java.lang.IllegalStateException - if the remove operation is performed at an illegal state of the underlying Iterator

iterator

public java.util.Iterator<E> iterator()

Specified by:
iterator in interface java.lang.Iterable<E>