org.elkoserver.util
Class SingleObjectIterator<V>

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

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

Iterator over a single object. This class is useful in the implementation of collection-like interfaces in cases where there is no actual underlying collection object.


Constructor Summary
SingleObjectIterator(V object)
          Constructor.
 
Method Summary
 boolean hasNext()
          Returns true if the iteration has more elements.
 V next()
          Returns the next element in the iteration.
 void remove()
          This operation is not supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingleObjectIterator

public SingleObjectIterator(V object)
Constructor.

Parameters:
object - The object to iterate over.
Method Detail

hasNext

public boolean hasNext()
Returns true if the iteration has more elements. (In other words, returns true if next() would return an element rather than throwing an exception.)

Specified by:
hasNext in interface Iterator<V>
Returns:
true if the iterator has more 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.
Throws:
NoSuchElementException - iteration has no more elements.

remove

public void remove()
This operation is not supported.

Specified by:
remove in interface Iterator<V>
Throws:
UnsupportedOperationException - always.