org.apache.commons.collections.iterators
Class ListIteratorWrapper<E>

java.lang.Object
  extended by org.apache.commons.collections.iterators.ListIteratorWrapper<E>
All Implemented Interfaces:
Iterator<E>, ListIterator<E>

public class ListIteratorWrapper<E>
extends Object
implements ListIterator<E>

As the wrapped Iterator is traversed, ListIteratorWrapper builds a LinkedList of its values, permitting all required operations of ListIterator.

Since:
Commons Collections 2.1
Version:
$Revision: 1.1.1.1 $ $Date: 2005/05/23 04:34:55 $
Author:
Morgan Delagrange, Matt Hall, John Watkinson, Stephen Colebourne

Constructor Summary
ListIteratorWrapper(Iterator<E> iterator)
          Constructs a new ListIteratorWrapper that will wrap the given iterator.
 
Method Summary
 void add(E o)
          Throws UnsupportedOperationException.
 boolean hasNext()
          Returns true if there are more elements in the iterator.
 boolean hasPrevious()
          Returns true if there are previous elements in the iterator.
 E next()
          Returns the next element from the iterator.
 int nextIndex()
          Returns in the index of the next element.
 E previous()
          Returns the the previous element.
 int previousIndex()
          Returns the index of the previous element.
 void remove()
          Throws UnsupportedOperationException.
 void set(E o)
          Throws UnsupportedOperationException.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListIteratorWrapper

public ListIteratorWrapper(Iterator<E> iterator)
Constructs a new ListIteratorWrapper that will wrap the given iterator.

Parameters:
iterator - the iterator to wrap
Throws:
NullPointerException - if the iterator is null
Method Detail

add

public void add(E o)
         throws UnsupportedOperationException
Throws UnsupportedOperationException.

Specified by:
add in interface ListIterator<E>
Parameters:
o - ignored
Throws:
UnsupportedOperationException - always

hasNext

public boolean hasNext()
Returns true if there are more elements in the iterator.

Specified by:
hasNext in interface Iterator<E>
Specified by:
hasNext in interface ListIterator<E>
Returns:
true if there are more elements

hasPrevious

public boolean hasPrevious()
Returns true if there are previous elements in the iterator.

Specified by:
hasPrevious in interface ListIterator<E>
Returns:
true if there are previous elements

next

public E next()
       throws NoSuchElementException
Returns the next element from the iterator.

Specified by:
next in interface Iterator<E>
Specified by:
next in interface ListIterator<E>
Returns:
the next element from the iterator
Throws:
NoSuchElementException - if there are no more elements

nextIndex

public int nextIndex()
Returns in the index of the next element.

Specified by:
nextIndex in interface ListIterator<E>
Returns:
the index of the next element

previous

public E previous()
           throws NoSuchElementException
Returns the the previous element.

Specified by:
previous in interface ListIterator<E>
Returns:
the previous element
Throws:
NoSuchElementException - if there are no previous elements

previousIndex

public int previousIndex()
Returns the index of the previous element.

Specified by:
previousIndex in interface ListIterator<E>
Returns:
the index of the previous element

remove

public void remove()
            throws UnsupportedOperationException
Throws UnsupportedOperationException.

Specified by:
remove in interface Iterator<E>
Specified by:
remove in interface ListIterator<E>
Throws:
UnsupportedOperationException - always

set

public void set(E o)
         throws UnsupportedOperationException
Throws UnsupportedOperationException.

Specified by:
set in interface ListIterator<E>
Parameters:
o - ignored
Throws:
UnsupportedOperationException - always


Copyright © 2005-2005 Apache Software Foundation, Matt Hall, John Watkinson. All Rights Reserved.