EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

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

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

public class CloneIterator<E>
extends java.lang.Object
implements IterableIterator<E>

A CloneIterator iterates over a copy of a collection, allowing for concurrent access to the original collection.

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

By default, a CloneIterator does not support the remove() operation; this is because it does not have access to the original collection. But if the CloneIterator is supplied with an Mutator it will delegate the remove() operation to the Mutator. Alternatively, a subclass can override the remove(Object) method.

Version:
2.4
Since:
2.4

Constructor Summary
CloneIterator(java.util.Collection<? extends E> collection)
          Creates a new CloneIterator using a copy of the specified collection.
CloneIterator(java.util.Collection<? extends E> collection, Mutator<? extends E> mutator)
          Creates a new CloneIterator using a copy of the specified collection.
 
Method Summary
 boolean hasNext()
          
 java.util.Iterator<E> iterator()
          
 E next()
          
 void remove()
          
protected  void remove(E item)
          Removes the specified element from the original collection.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CloneIterator

public CloneIterator(java.util.Collection<? extends E> collection)
Creates a new CloneIterator using a copy of the specified collection. The remove() method will not be supported, unless a subclass overrides remove(Object).

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

CloneIterator

public CloneIterator(java.util.Collection<? extends E> collection,
                     Mutator<? extends E> mutator)
Creates a new CloneIterator using a copy of the specified collection. Use the specified mutator to remove objects from the original collection.

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

hasNext

public boolean hasNext()

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

iterator

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

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

next

public E next()

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

remove

public void remove()

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

remove

protected void remove(E item)
Removes the specified element from the original collection.

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

Parameters:
item - The element to remove from the original collection

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

EclipseLink 2.4.2, build 'v20130514-5956486' API Reference