Top Description Inners Fields Constructors Methods
org.eclipse.persistence.jpa.jpql.utility.iterator

public Class CloneListIterator<E>

extends Object
implements ListIterator<E>
Class Inheritance
All Implemented Interfaces
java.util.ListIterator, java.util.Iterator
Known Direct Subclasses
org.eclipse.persistence.jpa.jpql.utility.iterable.SnapshotCloneListIterable.LocalCloneListIterator
Type Parameters
<E>
the type of elements returned by the iterator
Imports
java.io.Serializable, java.util.List, .ListIterator, org.eclipse.persistence.jpa.jpql.utility.CollectionTools

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 (e.g. java.util.Vector.

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.

See Also
LiveCloneListIterable, SnapshotCloneListIterable

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
CloneListIterator.Mutator<T>

Used by CloneListIterator to remove elements from the original list; since the list iterator does not have direct access to the original list.

private static enum

Field Summary

Modifier and TypeField and Description
private int
private final ListIterator<Object>
private final CloneListIterator.Mutator<E>
private CloneListIterator.State

Constructor Summary

AccessConstructor and Description
public
CloneListIterator(E[] array)

Construct a list iterator on a copy of the specified array.

public
CloneListIterator(E[] array, CloneListIterator.Mutator<E> mutator)

Construct a list iterator on a copy of the specified array.

public
CloneListIterator(List<? extends E> list)

Construct a list iterator on a copy of the specified list.

public
CloneListIterator(List<? extends E> list, CloneListIterator.Mutator<E> mutator)

Construct a list iterator on a copy of the specified list.

protected
CloneListIterator(CloneListIterator.Mutator<E> mutator, Object... array)

Internal constructor used by subclasses.

Method Summary

Modifier and TypeMethod and Description
public void
add(E
the element to insert
o
)

Implements java.util.ListIterator.add.

Inserts the specified element into the list (optional operation).
protected void
add(int index, E o)

Add the specified element to the original list.

public boolean
hasNext()

Implements java.util.ListIterator.hasNext.

Returns true if this list iterator has more elements when traversing the list in the forward direction.
public boolean
hasPrevious()

Implements java.util.ListIterator.hasPrevious.

Returns true if this list iterator has more elements when traversing the list in the reverse direction.
protected E
nestedNext()

The list passed in during construction held elements of type E, so this cast is not a problem.

protected E
nestedPrevious()

The list passed in during construction held elements of type E, so this cast is not a problem.

public E
next()

Implements java.util.ListIterator.next.

Returns the next element in the list and advances the cursor position.
public int
nextIndex()

Implements java.util.ListIterator.nextIndex.

Returns the index of the element that would be returned by a subsequent call to next.
public E
previous()

Implements java.util.ListIterator.previous.

Returns the previous element in the list and moves the cursor position backwards.
public int
previousIndex()

Implements java.util.ListIterator.previousIndex.

Returns the index of the element that would be returned by a subsequent call to previous.
public void
remove()

Implements java.util.ListIterator.remove.

Removes from the list the last element that was returned by next or previous (optional operation).
protected void
remove(int index)

Remove the specified element from the original list.

public void
set(E
the element with which to replace the last element returned by next or previous
o
)

Implements java.util.ListIterator.set.

Replaces the last element returned by next or previous with the specified element (optional operation).
protected void
set(int index, E o)

Set the specified element in the original list.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cursorback to summary
private int cursor
listIteratorback to summary
private final ListIterator<Object> listIterator
mutatorback to summary
private final CloneListIterator.Mutator<E> mutator
stateback to summary
private CloneListIterator.State state

Constructor Detail

CloneListIteratorback to summary
public CloneListIterator(E[] array)

Construct a list iterator on a copy of the specified array. The modification methods will not be supported, unless a subclass overrides them.

CloneListIteratorback to summary
public CloneListIterator(E[] array, CloneListIterator.Mutator<E> mutator)

Construct a list iterator on a copy of the specified array. Use the specified list mutator to modify the original list.

CloneListIteratorback to summary
public CloneListIterator(List<? extends E> list)

Construct a list iterator on a copy of the specified list. The modification methods will not be supported, unless a subclass overrides them.

CloneListIteratorback to summary
public CloneListIterator(List<? extends E> list, CloneListIterator.Mutator<E> mutator)

Construct a list iterator on a copy of the specified list. Use the specified list mutator to modify the original list.

CloneListIteratorback to summary
protected CloneListIterator(CloneListIterator.Mutator<E> mutator, Object... array)

Internal constructor used by subclasses. Swap order of arguments to prevent collision with other constructor. The passed in array will *not* be cloned.

Method Detail

addback to summary
public void add(E o)

Implements java.util.ListIterator.add.

Doc from java.util.ListIterator.add.

Inserts the specified element into the list (optional operation). The element is inserted immediately before the element that would be returned by next, if any, and after the element that would be returned by previous, if any. (If the list contains no elements, the new element becomes the sole element on the list.) The new element is inserted before the implicit cursor: a subsequent call to next would be unaffected, and a subsequent call to previous would return the new element. (This call increases by one the value that would be returned by a call to nextIndex or previousIndex.)

Parameters
o:E

the element to insert

Annotations
@Override
addback to summary
protected void add(int index, E o)

Add the specified element to the original list.

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

hasNextback to summary
public boolean hasNext()

Implements java.util.ListIterator.hasNext.

Doc from java.util.ListIterator.hasNext.

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

Returns:boolean

true if the list iterator has more elements when traversing the list in the forward direction

Annotations
@Override
hasPreviousback to summary
public boolean hasPrevious()

Implements java.util.ListIterator.hasPrevious.

Doc from java.util.ListIterator.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.)

Returns:boolean

true if the list iterator has more elements when traversing the list in the reverse direction

Annotations
@Override
nestedNextback to summary
protected E nestedNext()

The list passed in during construction held elements of type 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[]).

Annotations
@SuppressWarnings:unchecked
nestedPreviousback to summary
protected E nestedPrevious()

The list passed in during construction held elements of type 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[]).

Annotations
@SuppressWarnings:unchecked
nextback to summary
public E next()

Implements java.util.ListIterator.next.

Doc from java.util.ListIterator.next.

Returns the next element in the list and advances the cursor position. This method may be called repeatedly to iterate through the list, or intermixed with calls to previous to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.)

Returns:E

the next element in the list

Annotations
@Override
nextIndexback to summary
public int nextIndex()

Implements java.util.ListIterator.nextIndex.

Doc from java.util.ListIterator.nextIndex.

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

Returns:int

the index of the element that would be returned by a subsequent call to next, or list size if the list iterator is at the end of the list

Annotations
@Override
previousback to summary
public E previous()

Implements java.util.ListIterator.previous.

Doc from java.util.ListIterator.previous.

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

Returns:E

the previous element in the list

Annotations
@Override
previousIndexback to summary
public int previousIndex()

Implements java.util.ListIterator.previousIndex.

Doc from java.util.ListIterator.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.)

Returns:int

the index of the element that would be returned by a subsequent call to previous, or -1 if the list iterator is at the beginning of the list

Annotations
@Override
removeback to summary
public void remove()

Implements java.util.ListIterator.remove.

Doc from java.util.ListIterator.remove.

Removes from the list the last element that was returned by next or previous (optional operation). This call can only be made once per call to next or previous. It can be made only if add has not been called after the last call to next or previous.

Annotations
@Override
removeback to summary
protected void remove(int index)

Remove the specified element from the original list.

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

setback to summary
public void set(E o)

Implements java.util.ListIterator.set.

Doc from java.util.ListIterator.set.

Replaces the last element returned by next or previous with the specified element (optional operation). This call can be made only if neither remove nor add have been called after the last call to next or previous.

Parameters
o:E

the element with which to replace the last element returned by next or previous

Annotations
@Override
setback to summary
protected void set(int index, E o)

Set the specified element in the original list.

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

org.eclipse.persistence.jpa.jpql.utility.iterator back to summary

public Interface CloneListIterator.Mutator<T>

Known Direct Implementers
org.eclipse.persistence.jpa.jpql.utility.iterator.CloneListIterator.Mutator.ReadOnly, org.eclipse.persistence.jpa.jpql.utility.iterable.CloneListIterable.DefaultMutator

Used by CloneListIterator to remove elements from the original list; since the list iterator does not have direct access to the original list.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Method Summary

Modifier and TypeMethod and Description
public void
add(int index, T o)

Add the specified object to the original list.

public void
remove(int index)

Remove the specified object from the original list.

public void
set(int index, T o)

Set the specified object in the original list.

Method Detail

addback to summary
public void add(int index, T o)

Add the specified object to the original list.

removeback to summary
public void remove(int index)

Remove the specified object from the original list.

setback to summary
public void set(int index, T o)

Set the specified object in the original list.

org.eclipse.persistence.jpa.jpql.utility.iterator back to summary

public final Class CloneListIterator.Mutator.ReadOnly<S>

extends Object
implements CloneListIterator.Mutator<S>, Serializable
Class Inheritance
  • java.lang.Object
  • org.eclipse.persistence.jpa.jpql.utility.iterator.CloneListIterator.Mutator.ReadOnly
All Implemented Interfaces
java.io.Serializable, org.eclipse.persistence.jpa.jpql.utility.iterator.CloneListIterator.Mutator

Field Summary

Modifier and TypeField and Description
public static final CloneListIterator.Mutator<T>
private static final long

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
add(int index, Object o)

Implements org.eclipse.persistence.jpa.jpql.utility.iterator.CloneListIterator.Mutator.add.

Add the specified object to the original list.
public static <R> CloneListIterator.Mutator<R>
private Object
public void
remove(int index)

Implements org.eclipse.persistence.jpa.jpql.utility.iterator.CloneListIterator.Mutator.remove.

Remove the specified object from the original list.
public void
set(int index, Object o)

Implements org.eclipse.persistence.jpa.jpql.utility.iterator.CloneListIterator.Mutator.set.

Set the specified object in the original list.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
public static final CloneListIterator.Mutator<T> INSTANCE
Annotations
@SuppressWarnings:rawtypes
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

ReadOnlyback to summary
private ReadOnly()

Method Detail

addback to summary
public void add(int index, Object o)

Implements org.eclipse.persistence.jpa.jpql.utility.iterator.CloneListIterator.Mutator.add.

Doc from org.eclipse.persistence.jpa.jpql.utility.iterator.CloneListIterator.Mutator.add.

Add the specified object to the original list.

Annotations
@Override
instanceback to summary
public static <R> CloneListIterator.Mutator<R> instance()
Annotations
@SuppressWarnings:unchecked
readResolveback to summary
private Object readResolve()
removeback to summary
public void remove(int index)

Implements org.eclipse.persistence.jpa.jpql.utility.iterator.CloneListIterator.Mutator.remove.

Doc from org.eclipse.persistence.jpa.jpql.utility.iterator.CloneListIterator.Mutator.remove.

Remove the specified object from the original list.

Annotations
@Override
setback to summary
public void set(int index, Object o)

Implements org.eclipse.persistence.jpa.jpql.utility.iterator.CloneListIterator.Mutator.set.

Doc from org.eclipse.persistence.jpa.jpql.utility.iterator.CloneListIterator.Mutator.set.

Set the specified object in the original list.

Annotations
@Override
org.eclipse.persistence.jpa.jpql.utility.iterator back to summary

private final Enum CloneListIterator.State

extends Enum<CloneListIterator.State>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final CloneListIterator.State
public static final CloneListIterator.State
public static final CloneListIterator.State

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static CloneListIterator.State
public static CloneListIterator.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

NEXTback to summary
public static final CloneListIterator.State NEXT
PREVIOUSback to summary
public static final CloneListIterator.State PREVIOUS
UNKNOWNback to summary
public static final CloneListIterator.State UNKNOWN

Constructor Detail

Stateback to summary
private State()

Method Detail

valueOfback to summary
public static CloneListIterator.State valueOf(String name)
valuesback to summary
public static CloneListIterator.State[] values()