argutia.tools
Class UnmodifiableListIterator<E>

java.lang.Object
  extended by argutia.tools.UnmodifiableIterator<E>
      extended by argutia.tools.UnmodifiableListIterator<E>
Type Parameters:
E - the object type being iterated over.
All Implemented Interfaces:
Iterator<E>, ListIterator<E>
public class UnmodifiableListIterator<E>
extends UnmodifiableIterator<E>
implements ListIterator<E>

Decorates a list iterator such that iterator cannot be modified.

Author:
Geoffroy AUBRY
Field Summary
 
Fields inherited from class argutia.tools.UnmodifiableIterator
iterator
 
Constructor Summary
UnmodifiableListIterator(ListIterator<E> iterator)
          Decorates the specified list iterator such that iterator cannot be modified.
 
Method Summary
 void add(E element)
          Unsupported operation.
 boolean hasPrevious()
          Returns true if this list iterator has more elements when traversing the list in the reverse direction.
 int nextIndex()
          Returns the index of the element that would be returned by a subsequent call to UnmodifiableIterator.next().
 E previous()
          Returns the previous element in the list.
 int previousIndex()
          Returns the index of the element that would be returned by a subsequent call to previous().
 void set(E element)
          Unsupported operation.
 
Methods inherited from class argutia.tools.UnmodifiableIterator
hasNext, next, remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.ListIterator
hasNext, next, remove
 
Constructor Detail

UnmodifiableListIterator

public UnmodifiableListIterator(ListIterator<E> iterator)
Decorates the specified list iterator such that iterator cannot be modified.

Parameters:
iterator - list iterator being wrapped.
Method Detail

add

public void add(E element)
         throws UnsupportedOperationException
Unsupported operation. Always throws an UnsupportedOperationException.

Specified by:
add in interface ListIterator<E>
Parameters:
element - the element to insert.
Throws:
UnsupportedOperationException - always.

hasPrevious

public boolean hasPrevious()
Returns true if this list iterator has more elements when traversing the list in the reverse direction. In other words, returns true if previous() would return an element rather than throwing an exception.

Specified by:
hasPrevious in interface ListIterator<E>
Returns:
true if the list iterator has more elements when traversing the list in the reverse direction.

nextIndex

public int nextIndex()
Returns the index of the element that would be returned by a subsequent call to UnmodifiableIterator.next(). Returns list size if the list iterator is at the end of the list.

Specified by:
nextIndex in interface ListIterator<E>
Returns:
the index of the element that would be returned by a subsequent call to UnmodifiableIterator.next(), or list size if list iterator is at end of list.

previous

public E previous()
           throws NoSuchElementException
Returns the previous element in the list. This method may be called repeatedly to iterate through the list backwards, or intermixed with calls to UnmodifiableIterator.next() to go back and forth. Note that alternating calls to UnmodifiableIterator.next() and previous() will return the same element repeatedly.

Specified by:
previous in interface ListIterator<E>
Returns:
the previous element in the list.
Throws:
NoSuchElementException - if the iteration has no previous element.

previousIndex

public int previousIndex()
Returns the index of the element that would be returned by a subsequent call to previous(). Returns -1 if the list iterator is at the beginning of the list.

Specified by:
previousIndex in interface ListIterator<E>
Returns:
the index of the element that would be returned by a subsequent call to previous(), or -1 if list iterator is at beginning of list.

set

public void set(E element)
         throws UnsupportedOperationException
Unsupported operation. Always throws an UnsupportedOperationException.

Specified by:
set in interface ListIterator<E>
Parameters:
element - the element with which to replace the last element returned by UnmodifiableIterator.next() or previous().
Throws:
UnsupportedOperationException - always.
Argutia JavaDoc
23 décembre 2007