collectionframework
Class NullIterator<E>

java.lang.Object
  extended by collectionframework.NullIterator<E>
All Implemented Interfaces:
java.util.Enumeration<E>, java.util.Iterator<E>

public class NullIterator<E>
extends java.lang.Object
implements java.util.Enumeration<E>, java.util.Iterator<E>

An Iterator/Enumeration that contains one (or zero) elements

See Also:
"The Design and Implementation of Multimedia Software © 2011"

Constructor Summary
NullIterator()
          Default Constructor
NullIterator(E element)
          Explicit Value Constructor
 
Method Summary
 void clear()
          Clear this Iterator (so that it no longer has an element)
 boolean hasMoreElements()
          Returns true if this Enumeration has another element (required by Enumeration)
 boolean hasNext()
          Returns true if this Iterator has another element (required by Iterator)
 E next()
          Returns the next element in this Iterator (required by Iterator)
 E nextElement()
          Returns the next element in this Enumeration (required by Enumeration)
 void remove()
          Remove the last element from the underlying collection (required by Iterator) This method is not supported
 void reset()
          Reset this Iterator so that it (again) contains the single element
 void setElement(E element)
          Set the single element in this Iterator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NullIterator

public NullIterator()
Default Constructor


NullIterator

public NullIterator(E element)
Explicit Value Constructor

Parameters:
element - The element in the Iterator
Method Detail

clear

public void clear()
Clear this Iterator (so that it no longer has an element)


hasMoreElements

public boolean hasMoreElements()
Returns true if this Enumeration has another element (required by Enumeration)

Specified by:
hasMoreElements in interface java.util.Enumeration<E>
Returns:
true if this Enumeration has another element

hasNext

public boolean hasNext()
Returns true if this Iterator has another element (required by Iterator)

Specified by:
hasNext in interface java.util.Iterator<E>
Returns:
true if this Iterator has another element

nextElement

public E nextElement()
              throws java.util.NoSuchElementException
Returns the next element in this Enumeration (required by Enumeration)

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

next

public E next()
       throws java.util.NoSuchElementException
Returns the next element in this Iterator (required by Iterator)

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

remove

public void remove()
            throws java.lang.UnsupportedOperationException
Remove the last element from the underlying collection (required by Iterator) This method is not supported

Specified by:
remove in interface java.util.Iterator<E>
Throws:
java.lang.UnsupportedOperationException

reset

public void reset()
Reset this Iterator so that it (again) contains the single element


setElement

public void setElement(E element)
Set the single element in this Iterator

Parameters:
element - The element


Design and Implementation of Multimedia Software, Jones and Bartlett Publishers