Class Enumerator<T>

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

    public class Enumerator<T>
    extends java.lang.Object
    implements java.util.Enumeration<T>

    Adapter that wraps an Enumeration around a Java 2 collection Iterator.

    Constructors are provided to easily create such wrappers.

    This class is based on code in Apache Tomcat.

    • Constructor Summary

      Constructors 
      Constructor Description
      Enumerator​(java.util.Collection<T> collection)
      Return an Enumeration over the values of the specified Collection.
      Enumerator​(java.util.Collection<T> collection, boolean clone)
      Return an Enumeration over the values of the specified Collection.
      Enumerator​(java.util.Iterator<T> iterator)
      Return an Enumeration over the values returned by the specified Iterator.
      Enumerator​(java.util.Iterator<T> iterator, boolean clone)
      Return an Enumeration over the values returned by the specified Iterator.
      Enumerator​(java.util.Map<?,​T> map)
      Return an Enumeration over the values of the specified Map.
      Enumerator​(java.util.Map<?,​T> map, boolean clone)
      Return an Enumeration over the values of the specified Map.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasMoreElements()
      Tests if this enumeration contains more elements.
      T nextElement()
      Returns the next element of this enumeration if this enumeration has at least one more element to provide.
      • Methods inherited from class java.lang.Object

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

        asIterator
    • Constructor Detail

      • Enumerator

        public Enumerator​(java.util.Collection<T> collection)
        Return an Enumeration over the values of the specified Collection.
        Parameters:
        collection - Collection whose values should be enumerated
      • Enumerator

        public Enumerator​(java.util.Collection<T> collection,
                          boolean clone)
        Return an Enumeration over the values of the specified Collection.
        Parameters:
        collection - Collection whose values should be enumerated
        clone - true to clone iterator
      • Enumerator

        public Enumerator​(java.util.Iterator<T> iterator)
        Return an Enumeration over the values returned by the specified Iterator.
        Parameters:
        iterator - Iterator to be wrapped
      • Enumerator

        public Enumerator​(java.util.Iterator<T> iterator,
                          boolean clone)
        Return an Enumeration over the values returned by the specified Iterator.
        Parameters:
        iterator - Iterator to be wrapped
        clone - true to clone iterator
      • Enumerator

        public Enumerator​(java.util.Map<?,​T> map)
        Return an Enumeration over the values of the specified Map.
        Parameters:
        map - Map whose values should be enumerated
      • Enumerator

        public Enumerator​(java.util.Map<?,​T> map,
                          boolean clone)
        Return an Enumeration over the values of the specified Map.
        Parameters:
        map - Map whose values should be enumerated
        clone - true to clone iterator
    • Method Detail

      • hasMoreElements

        public boolean hasMoreElements()
        Tests if this enumeration contains more elements.
        Specified by:
        hasMoreElements in interface java.util.Enumeration<T>
        Returns:
        true if and only if this enumeration object contains at least one more element to provide, false otherwise
      • nextElement

        public T nextElement()
                      throws java.util.NoSuchElementException
        Returns the next element of this enumeration if this enumeration has at least one more element to provide.
        Specified by:
        nextElement in interface java.util.Enumeration<T>
        Returns:
        the next element of this enumeration
        Throws:
        java.util.NoSuchElementException - if no more elements exist