Class IteratorEnumeration<E>

  • All Implemented Interfaces:
    java.util.Enumeration<E>

    public class IteratorEnumeration<E>
    extends java.lang.Object
    implements java.util.Enumeration<E>
    Adapter to make an Iterator instance appear to be an Enumeration instance.
    Since:
    1.0
    • Constructor Summary

      Constructors 
      Constructor Description
      IteratorEnumeration()
      Constructs a new IteratorEnumeration that will not function until setIterator is invoked.
      IteratorEnumeration​(java.util.Iterator<? extends E> iterator)
      Constructs a new IteratorEnumeration that will use the given iterator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Iterator<? extends E> getIterator()
      Returns the underlying iterator.
      boolean hasMoreElements()
      Returns true if the underlying iterator has more elements.
      E nextElement()
      Returns the next element from the underlying iterator.
      void setIterator​(java.util.Iterator<? extends E> iterator)
      Sets the underlying iterator.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Enumeration

        asIterator
    • Constructor Detail

      • IteratorEnumeration

        public IteratorEnumeration()
        Constructs a new IteratorEnumeration that will not function until setIterator is invoked.
      • IteratorEnumeration

        public IteratorEnumeration​(java.util.Iterator<? extends E> iterator)
        Constructs a new IteratorEnumeration that will use the given iterator.
        Parameters:
        iterator - the iterator to use
    • Method Detail

      • hasMoreElements

        public boolean hasMoreElements()
        Returns true if the underlying iterator has more elements.
        Specified by:
        hasMoreElements in interface java.util.Enumeration<E>
        Returns:
        true if the underlying iterator has more elements
      • nextElement

        public E nextElement()
        Returns the next element from the underlying iterator.
        Specified by:
        nextElement in interface java.util.Enumeration<E>
        Returns:
        the next element from the underlying iterator.
        Throws:
        java.util.NoSuchElementException - if the underlying iterator has no more elements
      • getIterator

        public java.util.Iterator<? extends E> getIterator()
        Returns the underlying iterator.
        Returns:
        the underlying iterator
      • setIterator

        public void setIterator​(java.util.Iterator<? extends E> iterator)
        Sets the underlying iterator.
        Parameters:
        iterator - the new underlying iterator