E
- the type of elements over which this instance iteratespublic class ListIteratorDecorator<E> extends java.lang.Object implements java.util.ListIterator<E>
ListIterator
can be inherited from this class.
In addition to the delegation of all methods to the underlying iterator this class provides the empty methods
afterAdd(int, Object)
, afterReplace(int, Object, Object)
and afterRemove(int, Object)
that can be overwritten by inherited classes to react to modifications of the associated list made by this iterator.
They are called from the according methods that make such modifications.
Constructor and Description |
---|
ListIteratorDecorator(java.util.ListIterator<E> underlyingIterator)
Creates a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
void |
add(E e) |
protected void |
afterAdd(int index,
E element)
This method is called at the end of
add(Object) to indicate that an element has been
inserted. |
protected void |
afterRemove(int index,
E element)
This method is called at the end of
remove() to indicate that an element has been removed from
the associated list. |
protected void |
afterReplace(int index,
E previousElement,
E currentElement)
This method is called at the end of
set(Object) to indicate that an element has been
replaced. |
protected void |
beforeAdd(int index,
E element)
This method is called at the beginning of
add(Object) to indicate that an element will be
inserted. |
protected void |
beforeRemove(int index,
java.lang.Object element)
This method is called at the beginning of
remove() to indicate that an element will be removed from
the associated list. |
protected void |
beforeReplace(int index,
E currentElement,
E newElement)
This method is called at the beginning of
set(Object) to indicate that an element will be
replaced. |
protected java.util.ListIterator<E> |
getUnderlyingIterator()
Returns the list iterator that has been decorated by this instance.
|
boolean |
hasNext() |
boolean |
hasPrevious() |
E |
next() |
int |
nextIndex() |
E |
previous() |
int |
previousIndex() |
void |
remove() |
void |
set(E e) |
public ListIteratorDecorator(java.util.ListIterator<E> underlyingIterator)
underlyingIterator
- the list iterator to be decorated by this instanceprotected java.util.ListIterator<E> getUnderlyingIterator()
protected void beforeAdd(int index, E element)
add(Object)
to indicate that an element will be
inserted. This default implementation is empty and can be overwritten by inherited classes which want
to track modifications made by this iterator.index
- the index where the first new element will be insertedelement
- the new element that will be insertedprotected void afterAdd(int index, E element)
add(Object)
to indicate that an element has been
inserted. This default implementation is empty and can be overwritten by inherited classes which want
to track modifications made by this iterator.index
- the index where the first new element has been insertedelement
- the new element that has been insertedprotected void beforeReplace(int index, E currentElement, E newElement)
set(Object)
to indicate that an element will be
replaced. This default implementation is empty and can be overwritten by inherited classes which want
to track modifications made by this iterator.index
- the index where the element will be replacedcurrentElement
- the element that will be replacednewElement
- the new element that will replace the current elementprotected void afterReplace(int index, E previousElement, E currentElement)
set(Object)
to indicate that an element has been
replaced. This default implementation is empty and can be overwritten by inherited classes which want
to track modifications made by this iterator.index
- the index where the element has been replacedpreviousElement
- the element that has been replacedcurrentElement
- the new element that is now contained in the listprotected void beforeRemove(int index, java.lang.Object element)
remove()
to indicate that an element will be removed from
the associated list. This default implementation is empty and can be overwritten by inherited classes which
want to track modifications made by this iterator.index
- the index of the element to be removedelement
- the element that will be removedprotected void afterRemove(int index, E element)
remove()
to indicate that an element has been removed from
the associated list. This default implementation is empty and can be overwritten by inherited classes which
want to track modifications made by this iterator.index
- the index of the element that has been removedelement
- the element that has been removedpublic boolean hasNext()
public boolean hasPrevious()
hasPrevious
in interface java.util.ListIterator<E>
public int previousIndex()
previousIndex
in interface java.util.ListIterator<E>
public void remove()