Documentation of 'org.clapper.util.misc.EnumerationIterator' Java class
EnumerationIterator
org.clapper.util.misc

Class EnumerationIterator<T>

  • All Implemented Interfaces:
    java.lang.Iterable<T>, java.util.Iterator<T>


    public class EnumerationIterator<T>
    extends java.lang.Object
    implements java.util.Iterator<T>, java.lang.Iterable<T>

    The EnumerationIterator class is an adapter that makes a java.util.Enumeration object look and behave like a java.util.Iterator objects. The EnumerationIterator class implements the Iterator interface and wraps an existing Enumeration object. This class is the conceptual opposite of the Collections.enumeration() method in the java.util package.

    You can also use an instance of this class to wrap an Enumeration for use in a JDK 1.5-style for each loop. For instance:

     Vector v = ...
     for (String s : new EnumerationIterator (v.elements()))
         ...
     
    See Also:
    Iterator, Enumeration
    • Constructor Summary

      Constructors 
      Constructor and Description
      EnumerationIterator(java.util.Enumeration<T> enumeration)
      Allocate a new EnumerationIterator object that will forward its calls to the specified Enumeration.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean hasNext()
      Determine whether the underlying Enumeration has more elements.
      java.util.Iterator<T> iterator()
      Returns this iterator.
      T next()
      Get the next element from the underlying Enumeration.
      void remove()
      Removes from the underlying collection the last element returned by the iterator.
      • Methods inherited from class java.lang.Object

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

        forEachRemaining
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • EnumerationIterator

        public EnumerationIterator(java.util.Enumeration<T> enumeration)
        Allocate a new EnumerationIterator object that will forward its calls to the specified Enumeration.
        Parameters:
        enumeration - The Enumeration to which to forward calls
    • Method Detail

      • hasNext

        public boolean hasNext()
        Determine whether the underlying Enumeration has more elements.
        Specified by:
        hasNext in interface java.util.Iterator<T>
        Returns:
        true if and only if a call to next() will return an element, false otherwise.
        See Also:
        next(), Enumeration.hasMoreElements()
      • iterator

        public java.util.Iterator<T> iterator()
        Returns this iterator. Necessary for the Iterable interface.
        Specified by:
        iterator in interface java.lang.Iterable<T>
        Returns:
        this object
      • next

        public T next()
               throws java.util.NoSuchElementException
        Get the next element from the underlying Enumeration.
        Specified by:
        next in interface java.util.Iterator<T>
        Returns:
        the next element from the underlying Enumeration
        Throws:
        java.util.NoSuchElementException - No more elements exist
        See Also:
        Iterator.next()
      • remove

        public void remove()
                    throws java.lang.IllegalStateException,
                           java.lang.UnsupportedOperationException
        Removes from the underlying collection the last element returned by the iterator. Not supported by this class.
        Specified by:
        remove in interface java.util.Iterator<T>
        Throws:
        java.lang.IllegalStateException - doesn't
        java.lang.UnsupportedOperationException - unconditionally

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.