org.elkoserver.util
Class EmptyIterator<V>

java.lang.Object
  extended by org.elkoserver.util.EmptyIterator<V>
All Implemented Interfaces:
Iterator<V>

public class EmptyIterator<V>
extends Object
implements Iterator<V>

Iterator for a collection of no elements. This is sort of the Iterator equivalent of a null pointer.


Constructor Summary
EmptyIterator()
          Constructor.
 
Method Summary
 boolean hasNext()
          Returns true if the iteration has more elements.
 V next()
          Returns the next element in the iteration.
 void remove()
          Removes from the underlying collection the last element returned by the iterator; will always throw an exception since there never was such an element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmptyIterator

public EmptyIterator()
Constructor.

Method Detail

hasNext

public boolean hasNext()
Returns true if the iteration has more elements.

Specified by:
hasNext in interface Iterator<V>
Returns:
false (since, by definition, there are no elements).

next

public V next()
Returns the next element in the iteration.

Specified by:
next in interface Iterator<V>
Returns:
the next element in the iteration (actually, this will never happen; it will always throw).
Throws:
NoSuchElementException - iteration has no more elements (always).

remove

public void remove()
Removes from the underlying collection the last element returned by the iterator; will always throw an exception since there never was such an element.

Specified by:
remove in interface Iterator<V>
Throws:
IllegalStateException - since there are no elements in this collection.