|
EclipseLink 2.5.0, build 'v20130507-3faac2b' API Reference | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.persistence.jpa.jpql.tools.utility.iterator.CloneIterator<E>
E
- the type of elements returned by the iteratorpublic class CloneIterator<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 (e.g. Vector
);
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 CloneIterator.Remover
it will delegate the
remove()
operation to the CloneIterator.Remover
.
Alternatively, a subclass can override the remove(Object)
method.
org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable
,
org.eclipse.jpt.common.utility.internal.iterables.SnapshotCloneIterable
Nested Class Summary | |
---|---|
static interface |
CloneIterator.Remover<T>
Used by CloneIterator to remove
elements from the original collection; since the iterator
does not have direct access to the original collection. |
Constructor Summary | |
---|---|
protected |
CloneIterator(CloneIterator.Remover<E> remover,
java.lang.Object... array)
Internal constructor used by subclasses. |
|
CloneIterator(java.util.Collection<? extends E> collection)
Construct an iterator on a copy of the specified collection. |
|
CloneIterator(java.util.Collection<? extends E> collection,
CloneIterator.Remover<E> remover)
Construct an iterator on a copy of the specified collection. |
|
CloneIterator(E[] array)
Construct an iterator on a copy of the specified array. |
|
CloneIterator(E[] array,
CloneIterator.Remover<E> remover)
Construct an iterator on a copy of the specified array. |
Method Summary | |
---|---|
boolean |
hasNext()
|
protected E |
nestedNext()
The collection passed in during construction held elements of type E ,
so this cast is not a problem. |
E |
next()
|
void |
remove()
|
protected void |
remove(E e)
Remove the specified element from the original collection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CloneIterator(java.util.Collection<? extends E> collection)
remove()
method will not be supported,
unless a subclass overrides the remove(Object)
.
public CloneIterator(E[] array)
remove()
method will not be supported,
unless a subclass overrides the remove(Object)
.
public CloneIterator(java.util.Collection<? extends E> collection, CloneIterator.Remover<E> remover)
public CloneIterator(E[] array, CloneIterator.Remover<E> remover)
protected CloneIterator(CloneIterator.Remover<E> remover, java.lang.Object... array)
Method Detail |
---|
public boolean hasNext()
hasNext
in interface java.util.Iterator<E>
public E next()
next
in interface java.util.Iterator<E>
public void remove()
remove
in interface java.util.Iterator<E>
protected E nestedNext()
E
,
so this cast is not a problem. We need this cast because
all the elements of the original collection were copied into
an object array (Object[]
).
protected void remove(E e)
This method can be overridden by a subclass as an
alternative to building a CloneIterator.Remover
.
|
EclipseLink 2.5.0, build 'v20130507-3faac2b' API Reference | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |