EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

org.eclipse.persistence.jpa.jpql.util.iterator
Class CloneListIterator<E>

java.lang.Object
  extended by org.eclipse.persistence.jpa.jpql.util.iterator.CloneListIterator<E>
All Implemented Interfaces:
java.lang.Iterable<E>, java.util.Iterator<E>, java.util.ListIterator<E>, IterableIterator<E>, IterableListIterator<E>

public class CloneListIterator<E>
extends java.lang.Object
implements IterableListIterator<E>

A CloneListIterator iterates over a copy of a list, allowing for concurrent access to the original list.

The original list passed to the CloneListIterator's constructor should be synchronized; otherwise you run the risk of a corrupted list.

By default, a CloneListIterator does not support the modification operations; this is because it does not have access to the original list. But if the CloneListIterator is supplied with a Mutator it will delegate the modification operations to the Mutator. Alternatively, a subclass can override the modification methods.

Version:
2.4
Since:
2.4

Constructor Summary
CloneListIterator(java.util.List<? extends E> list)
          Creates a new CloneListIterator using a copy of the specified list.
CloneListIterator(java.util.List<? extends E> list, ListMutator<E> mutator)
          Construct a list iterator on a copy of the specified list.
 
Method Summary
 void add(E item)
          
protected  void add(int index, E item)
          Adds the specified element to the original list.
 boolean hasNext()
          
 boolean hasPrevious()
          
 java.util.ListIterator<E> iterator()
          
 E next()
          
 int nextIndex()
          
 E previous()
          
 int previousIndex()
          
 void remove()
          
protected  void remove(int index)
          Removes the specified element from the original list.
 void set(E item)
          
protected  void set(int index, E item)
          Sets the specified element in the original list.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CloneListIterator

public CloneListIterator(java.util.List<? extends E> list)
Creates a new CloneListIterator using a copy of the specified list. The modification methods will not be supported, unless a subclass overrides them.

Parameters:
list - The list that is copied in order to iterate over its items without being changed concurrently

CloneListIterator

public CloneListIterator(java.util.List<? extends E> list,
                         ListMutator<E> mutator)
Construct a list iterator on a copy of the specified list. Use the specified ListMutator to modify the original list.

Parameters:
list - The list that is copied in order to iterate over its items without being changed concurrently
mutator - This ListMutator is used to remove the item from the original list
Method Detail

add

public void add(E item)

Specified by:
add in interface java.util.ListIterator<E>

add

protected void add(int index,
                   E item)
Adds the specified element to the original list.

This method can be overridden by a subclass as an alternative to building a Mutator.

Parameters:
index - The index of insertion
item - The element to insert into the list

hasNext

public boolean hasNext()

Specified by:
hasNext in interface java.util.Iterator<E>
Specified by:
hasNext in interface java.util.ListIterator<E>

hasPrevious

public boolean hasPrevious()

Specified by:
hasPrevious in interface java.util.ListIterator<E>

iterator

public java.util.ListIterator<E> iterator()

Specified by:
iterator in interface java.lang.Iterable<E>
Specified by:
iterator in interface IterableListIterator<E>

next

public E next()

Specified by:
next in interface java.util.Iterator<E>
Specified by:
next in interface java.util.ListIterator<E>

nextIndex

public int nextIndex()

Specified by:
nextIndex in interface java.util.ListIterator<E>

previous

public E previous()

Specified by:
previous in interface java.util.ListIterator<E>

previousIndex

public int previousIndex()

Specified by:
previousIndex in interface java.util.ListIterator<E>

remove

public void remove()

Specified by:
remove in interface java.util.Iterator<E>
Specified by:
remove in interface java.util.ListIterator<E>

remove

protected void remove(int index)
Removes the specified element from the original list.

This method can be overridden by a subclass as an alternative to building a ListMutator.

Parameters:
index - The position of the item to remove from the original list

set

public void set(E item)

Specified by:
set in interface java.util.ListIterator<E>

set

protected void set(int index,
                   E item)
Sets the specified element in the original list.

This method can be overridden by a subclass as an alternative to building a ListMutator.

Parameters:
index - The index of replacement
item - The element to replace the existing one

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

EclipseLink 2.4.2, build 'v20130514-5956486' API Reference