de.rwth.utils
Class SingletonIterator

java.lang.Object
  |
  +--de.rwth.utils.SingletonIterator
All Implemented Interfaces:
java.util.Iterator

public class SingletonIterator
extends java.lang.Object
implements java.util.Iterator

Implements an Iterator with a single, non-null entry.

Version:
$Id: SingletonIterator.java,v 1.2 2002/09/17 06:53:53 mohnen Exp $
Author:
Markus Mohnen
See Also:
Iterator

Field Summary
protected  java.lang.Object o
          Contains the entry, or null if this element has already been retrieved.
 
Constructor Summary
SingletonIterator(java.lang.Object o)
          Creates a new SingletonIterator instance.
 
Method Summary
 boolean hasNext()
          Implements the hasNext method from the Iterator interface.
 java.lang.Object next()
          Implements the next method from the Iterator interface.
 void remove()
          Implements the next method from the Iterator interface by always throwing an UnsupportedOperationException.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

o

protected java.lang.Object o
Contains the entry, or null if this element has already been retrieved.
Constructor Detail

SingletonIterator

public SingletonIterator(java.lang.Object o)
Creates a new SingletonIterator instance.
Parameters:
o - an Object value. If this is null, then the Iterator is empty.
Method Detail

hasNext

public boolean hasNext()
Implements the hasNext method from the Iterator interface.
Specified by:
hasNext in interface java.util.Iterator
Returns:
a boolean value

next

public java.lang.Object next()
Implements the next method from the Iterator interface.
Specified by:
next in interface java.util.Iterator
Returns:
an Object value

remove

public void remove()
Implements the next method from the Iterator interface by always throwing an UnsupportedOperationException.
Specified by:
remove in interface java.util.Iterator