Class ListIteratorWrapper

  • All Implemented Interfaces:
    java.util.Iterator, java.util.ListIterator, ResettableIterator, ResettableListIterator

    @Deprecated(since="2021-04-30")
    public class ListIteratorWrapper
    extends java.lang.Object
    implements ResettableListIterator
    Deprecated.
    Commons Collections 3 is in maintenance mode. Commons Collections 4 should be used instead.
    Converts an iterator into a list iterator by caching the returned entries.

    The ListIterator interface has additional useful methods for navigation - previous() and the index methods. This class allows a regular Iterator to behave as a ListIterator. It achieves this by building a list internally of as the underlying iterator is traversed.

    The optional operations of ListIterator are not supported.

    This class implements ResettableListIterator from Commons Collections 3.2.

    Since:
    Commons Collections 2.1
    • Constructor Summary

      Constructors 
      Constructor Description
      ListIteratorWrapper​(java.util.Iterator iterator)
      Deprecated.
      Constructs a new ListIteratorWrapper that will wrap the given iterator.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void add​(java.lang.Object obj)
      Deprecated.
      Throws UnsupportedOperationException.
      boolean hasNext()
      Deprecated.
      Returns true if there are more elements in the iterator.
      boolean hasPrevious()
      Deprecated.
      Returns true if there are previous elements in the iterator.
      java.lang.Object next()
      Deprecated.
      Returns the next element from the iterator.
      int nextIndex()
      Deprecated.
      Returns in the index of the next element.
      java.lang.Object previous()
      Deprecated.
      Returns the the previous element.
      int previousIndex()
      Deprecated.
      Returns the index of the previous element.
      void remove()
      Deprecated.
      Throws UnsupportedOperationException.
      void reset()
      Deprecated.
      Resets this iterator back to the position at which the iterator was created.
      void set​(java.lang.Object obj)
      Deprecated.
      Throws UnsupportedOperationException.
      • Methods inherited from class java.lang.Object

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

        forEachRemaining
    • Constructor Detail

      • ListIteratorWrapper

        public ListIteratorWrapper​(java.util.Iterator iterator)
        Deprecated.
        Constructs a new ListIteratorWrapper that will wrap the given iterator.
        Parameters:
        iterator - the iterator to wrap
        Throws:
        java.lang.NullPointerException - if the iterator is null
    • Method Detail

      • add

        public void add​(java.lang.Object obj)
                 throws java.lang.UnsupportedOperationException
        Deprecated.
        Throws UnsupportedOperationException.
        Specified by:
        add in interface java.util.ListIterator
        Parameters:
        obj - the object to add, ignored
        Throws:
        java.lang.UnsupportedOperationException - always
      • hasNext

        public boolean hasNext()
        Deprecated.
        Returns true if there are more elements in the iterator.
        Specified by:
        hasNext in interface java.util.Iterator
        Specified by:
        hasNext in interface java.util.ListIterator
        Returns:
        true if there are more elements
      • hasPrevious

        public boolean hasPrevious()
        Deprecated.
        Returns true if there are previous elements in the iterator.
        Specified by:
        hasPrevious in interface java.util.ListIterator
        Returns:
        true if there are previous elements
      • next

        public java.lang.Object next()
                              throws java.util.NoSuchElementException
        Deprecated.
        Returns the next element from the iterator.
        Specified by:
        next in interface java.util.Iterator
        Specified by:
        next in interface java.util.ListIterator
        Returns:
        the next element from the iterator
        Throws:
        java.util.NoSuchElementException - if there are no more elements
      • nextIndex

        public int nextIndex()
        Deprecated.
        Returns in the index of the next element.
        Specified by:
        nextIndex in interface java.util.ListIterator
        Returns:
        the index of the next element
      • previous

        public java.lang.Object previous()
                                  throws java.util.NoSuchElementException
        Deprecated.
        Returns the the previous element.
        Specified by:
        previous in interface java.util.ListIterator
        Returns:
        the previous element
        Throws:
        java.util.NoSuchElementException - if there are no previous elements
      • previousIndex

        public int previousIndex()
        Deprecated.
        Returns the index of the previous element.
        Specified by:
        previousIndex in interface java.util.ListIterator
        Returns:
        the index of the previous element
      • remove

        public void remove()
                    throws java.lang.UnsupportedOperationException
        Deprecated.
        Throws UnsupportedOperationException.
        Specified by:
        remove in interface java.util.Iterator
        Specified by:
        remove in interface java.util.ListIterator
        Throws:
        java.lang.UnsupportedOperationException - always
      • set

        public void set​(java.lang.Object obj)
                 throws java.lang.UnsupportedOperationException
        Deprecated.
        Throws UnsupportedOperationException.
        Specified by:
        set in interface java.util.ListIterator
        Parameters:
        obj - the object to set, ignored
        Throws:
        java.lang.UnsupportedOperationException - always
      • reset

        public void reset()
        Deprecated.
        Resets this iterator back to the position at which the iterator was created.
        Specified by:
        reset in interface ResettableIterator
        Specified by:
        reset in interface ResettableListIterator
        Since:
        Commons Collections 3.2