net.sf.molae.pipe.basic
Class ListBasedListIterator<E>

java.lang.Object
  extended by net.sf.molae.pipe.basic.AbstractListIterator<E>
      extended by net.sf.molae.pipe.basic.ListBasedListIterator<E>
All Implemented Interfaces:
Iterator<E>, ListIterator<E>

public class ListBasedListIterator<E>
extends AbstractListIterator<E>

Provides an implementation of the ListIterator interface that passes all calls to the underlying list. Parts are copied from AbstractList. Note that this implementation will throw an UnsupportedOperationException in response to its remove(), set(Object) and add(Object) methods unless the list's remove(int), set(int, Object), and add(int, Object) methods are implemented. This implementation can be made to throw runtime exceptions in the face of concurrent modification by providing a ModificationMark.


Constructor Summary
ListBasedListIterator(List<E> base)
          Constructs a ListBasedListIterator object.
ListBasedListIterator(List<E> base, int index)
          Constructs a ListBasedListIterator object.
ListBasedListIterator(List<E> base, int index, ModificationMark mark)
          Constructs a ListBasedListIterator object.
ListBasedListIterator(List<E> base, ModificationMark mark)
          Constructs a ListBasedListIterator object.
 
Method Summary
 void add(E o)
          This implementation calls the corresponding method of the base list.
protected  E get()
          This implementation calls the corresponding method of the base list.
 boolean hasNext()
          This implementation compares the cursor with the size of the base list.
 void remove()
          This implementation calls the corresponding method of the base list.
 void set(E o)
          This implementation calls the corresponding method of the base list.
 
Methods inherited from class net.sf.molae.pipe.basic.AbstractListIterator
forwardTo, hasPrevious, next, nextIndex, previous, previousIndex, setCursor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListBasedListIterator

public ListBasedListIterator(List<E> base,
                             ModificationMark mark)
Constructs a ListBasedListIterator object.

Parameters:
base - the base list
mark - Modification mark of the base object
Throws:
NullPointerException - if the specified list or mark are null.

ListBasedListIterator

public ListBasedListIterator(List<E> base)
Constructs a ListBasedListIterator object.

Parameters:
base - the base list

ListBasedListIterator

public ListBasedListIterator(List<E> base,
                             int index,
                             ModificationMark mark)
Constructs a ListBasedListIterator object.

Parameters:
base - the base list
index - start position of the created ListIterator.
mark - Modification mark of the base object

ListBasedListIterator

public ListBasedListIterator(List<E> base,
                             int index)
Constructs a ListBasedListIterator object.

Parameters:
base - the base list
index - start position of the created ListIterator.
Method Detail

hasNext

public boolean hasNext()
This implementation compares the cursor with the size of the base list.

Specified by:
hasNext in interface Iterator<E>
Specified by:
hasNext in interface ListIterator<E>
Specified by:
hasNext in class AbstractListIterator<E>

get

protected E get()
This implementation calls the corresponding method of the base list.

Overrides:
get in class AbstractListIterator<E>
Returns:
object of base list at current cursor position.
Throws:
ConcurrentModificationException - if modification marks are not equal

remove

public void remove()
This implementation calls the corresponding method of the base list.

Specified by:
remove in interface Iterator<E>
Specified by:
remove in interface ListIterator<E>
Overrides:
remove in class AbstractListIterator<E>
Throws:
IllegalStateException - depending on the base list

set

public void set(E o)
This implementation calls the corresponding method of the base list.

Specified by:
set in interface ListIterator<E>
Overrides:
set in class AbstractListIterator<E>
Throws:
ClassCastException - depending on the base list
IllegalArgumentException - depending on the base list
IllegalStateException - depending on the base list

add

public void add(E o)
This implementation calls the corresponding method of the base list.

Specified by:
add in interface ListIterator<E>
Overrides:
add in class AbstractListIterator<E>
Throws:
ClassCastException - depending on the base list
IllegalArgumentException - depending on the base list