Top Description Fields Constructors Methods
org.eclipse.persistence.indirection

public Class IndirectList<E>

extends Vector<E>
implements CollectionChangeTracker, IndirectCollection<E, List<E>>
Class Inheritance
All Implemented Interfaces
org.eclipse.persistence.indirection.IndirectCollection, org.eclipse.persistence.indirection.IndirectContainer, org.eclipse.persistence.descriptors.changetracking.CollectionChangeTracker, org.eclipse.persistence.descriptors.changetracking.ChangeTracker
Type Parameters
<E>
the type of elements maintained by this list
Imports
java.beans.PropertyChangeListener, java.util.ArrayList, .Collection, .Comparator, .Enumeration, .Iterator, .List, .ListIterator, .Spliterator, .Vector, java.util.function.Consumer, .Predicate, .UnaryOperator, java.util.stream.Stream, org.eclipse.persistence.descriptors.changetracking.CollectionChangeEvent, .CollectionChangeTracker, org.eclipse.persistence.internal.descriptors.changetracking.AttributeChangeListener, org.eclipse.persistence.internal.indirection.UnitOfWorkQueryValueHolder, .UnitOfWorkValueHolder, org.eclipse.persistence.mappings.CollectionMapping, .DatabaseMapping

IndirectList allows a domain class to take advantage of TopLink indirection without having to declare its instance variable as a ValueHolderInterface.

To use an IndirectList:

EclipseLink will place an IndirectList in the instance variable when the containing domain object is read from the database. With the first message sent to the IndirectList, the contents are fetched from the database and normal Collection/List/Vector behavior is resumed.
Author
Big Country
Since
TOPLink/Java 2.5
See Also
org.eclipse.persistence.mappings.CollectionMapping, org.eclipse.persistence.indirection.IndirectMap

Field Summary

Modifier and TypeField and Description
private transient List<E>
addedElements

Store added elements to avoid instantiation on add.

private transient String
attributeName

The mapping attribute name, used to raise change events.

private transient PropertyChangeListener
changeListener

Change tracking listener.

protected volatile Vector<E>
delegate

Reduce type casting.

protected int
initialCapacity

Store initial size for lazy init.

private boolean
isListOrderBrokenInDb

If the mapping using IndirectList has listOrderfield != null then this flag indicates whether the list in the db has invalid order: either row(s) with null order value(s) or/and "holes" in order.

protected boolean
isRegistered

PERF: Quick check flag if has been registered in a unit of work.

private transient List<E>
removedElements

Store removed elements to avoid instantiation on remove.

private boolean
useLazyInstantiation

This value is used to determine if we should attempt to do adds and removes from the list without actually instantiating the list from the database.

protected volatile ValueHolderInterface<List<E>>
valueHolder

Delegate indirection behavior to a value holder.

Inherited from java.util.Vector:
capacityIncrementelementCountelementData

Constructor Summary

AccessConstructor and Description
public
IndirectList()

PUBLIC: Construct an empty IndirectList so that its internal data array has size 10 and its standard capacity increment is zero.

public
IndirectList(int
the initial capacity of the vector
initialCapacity
)

PUBLIC: Construct an empty IndirectList with the specified initial capacity and with its capacity increment equal to zero.

public
IndirectList(int
the initial capacity of the vector
initialCapacity
,
int
the amount by which the capacity is increased when the vector overflows
capacityIncrement
)

PUBLIC: Construct an empty IndirectList with the specified initial capacity and capacity increment.

public
IndirectList(Collection<? extends E>
a collection containing the elements to construct this IndirectList with.
collection
)

PUBLIC: Construct an IndirectList containing the elements of the specified collection, in the order they are returned by the collection's iterator.

Method Summary

Modifier and TypeMethod and Description
public PropertyChangeListener
public void
public void
add(int
index at which the specified element is to be inserted
index
,
E
element to be inserted
element
)

Overrides java.util.Vector.add.

Implements java.util.List.add.

Inserts the specified element at the specified position in this Vector.
public boolean
add(E
element to be appended to this Vector
element
)

Overrides java.util.Vector.add.

Implements java.util.List.add, java.util.Collection.add.

Appends the specified element to the end of this Vector.
public boolean
addAll(int
index at which to insert the first element from the specified collection
index
,
Collection<? extends E>
elements to be inserted into this Vector
c
)

Overrides java.util.Vector.addAll.

Implements java.util.List.addAll.

Inserts all of the elements in the specified Collection into this Vector at the specified position.
public boolean
addAll(Collection<? extends E>
elements to be inserted into this Vector
c
)

Overrides java.util.Vector.addAll.

Implements java.util.List.addAll, java.util.Collection.addAll.

Appends all of the elements in the specified Collection to the end of this Vector, in the order that they are returned by the specified Collection's Iterator.
public void
addElement(E
the component to be added
obj
)

Overrides java.util.Vector.addElement.

Adds the specified component to the end of this vector, increasing its size by one.
protected Vector<E>
buildDelegate()

INTERNAL: Return the freshly-built delegate.

public int
capacity()

Overrides java.util.Vector.capacity.

Returns the current capacity of this vector.
public void
clear()

Overrides java.util.Vector.clear.

Implements java.util.List.clear, java.util.Collection.clear.

Removes all of the elements from this Vector.
public void
clearDeferredChanges()

Implements org.eclipse.persistence.indirection.IndirectCollection.clearDeferredChanges.

INTERNAL: clear any changes that have been deferred to instantiation.
public synchronized Object
clone()

Overrides java.util.Vector.clone.

PUBLIC:
public boolean
contains(Object
element whose presence in this vector is to be tested
element
)

Overrides java.util.Vector.contains.

Implements java.util.List.contains, java.util.Collection.contains.

PUBLIC:
public boolean
containsAll(Collection<?>
a collection whose elements will be tested for containment in this Vector
c
)

Overrides java.util.Vector.containsAll.

Implements java.util.List.containsAll, java.util.Collection.containsAll.

Returns true if this Vector contains all of the elements in the specified Collection.
public synchronized void
copyInto(Object[]
the array into which the components get copied
anArray
)

Overrides java.util.Vector.copyInto.

Copies the components of this vector into the specified array.
public E
elementAt(int
an index into this vector
index
)

Overrides java.util.Vector.elementAt.

Returns the component at the specified index.
public Enumeration<E>
elements()

Overrides java.util.Vector.elements.

Returns an enumeration of the components of this vector.
public void
ensureCapacity(int
the desired minimum capacity
minCapacity
)

Overrides java.util.Vector.ensureCapacity.

Increases the capacity of this vector, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.
public boolean
equals(Object
the Object to be compared for equality with this Vector
o
)

Overrides java.util.Vector.equals.

Implements java.util.List.equals, java.util.Collection.equals.

Compares the specified Object with this Vector for equality.
public E
firstElement()

Overrides java.util.Vector.firstElement.

Returns the first component (the item at index 0) of this vector.
public void
forEach(Consumer<? super E>
The action to be performed for each element
action
)

Overrides java.util.Vector.forEach.

Overrides default java.lang.Iterable.forEach.

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.
public E
get(int
index of the element to return
index
)

Overrides java.util.Vector.get.

Implements java.util.List.get.

Returns the element at the specified position in this Vector.
public List<E>
getAddedElements()

Implements org.eclipse.persistence.indirection.IndirectCollection.getAddedElements.

INTERNAL: Return the elements that have been added before instantiation.
protected Vector<E>
getDelegate()

INTERNAL: Check whether the contents have been read from the database.

public List<E>
getDelegateObject()

Implements org.eclipse.persistence.indirection.IndirectCollection.getDelegateObject.

INTERNAL: Return the real collection object.
public List<E>
getRemovedElements()

Implements org.eclipse.persistence.indirection.IndirectCollection.getRemovedElements.

INTERNAL: Return the elements that have been removed before instantiation.
public String
getTrackedAttributeName()

Implements org.eclipse.persistence.descriptors.changetracking.CollectionChangeTracker.getTrackedAttributeName.

INTERNAL: Return the mapping attribute name, used to raise change events.
public ValueHolderInterface<List<E>>
public boolean
hasAddedElements()

INTERNAL: Return if any elements that have been added before instantiation.

public boolean
hasBeenRegistered()

INTERNAL: return whether this IndirectList has been registered with the UnitOfWork

public boolean
hasDeferredChanges()

Implements org.eclipse.persistence.indirection.IndirectCollection.hasDeferredChanges.

INTERNAL: Return if any elements that have been added or removed before instantiation.
public int
public boolean
hasRemovedElements()

INTERNAL: Return if any elements that have been removed before instantiation.

public boolean
hasTrackedPropertyChangeListener()

INTERNAL: Return if the collection has a property change listener for change tracking.

public int
indexOf(Object
element to search for
elem
)

Overrides java.util.Vector.indexOf.

Implements java.util.List.indexOf.

Returns the index of the first occurrence of the specified element in this vector, or -1 if this vector does not contain the element.
public int
indexOf(Object
element to search for
elem
,
int
index to start searching from
index
)

Overrides java.util.Vector.indexOf.

Returns the index of the first occurrence of the specified element in this vector, searching forwards from index, or returns -1 if the element is not found.
public void
insertElementAt(E
the component to insert
obj
,
int
where to insert the new component
index
)

Overrides java.util.Vector.insertElementAt.

Inserts the specified object as a component in this vector at the specified index.
public boolean
isEmpty()

Overrides java.util.Vector.isEmpty.

Implements java.util.List.isEmpty, java.util.Collection.isEmpty.

Tests if this vector has no components.
public boolean
isInstantiated()

Implements org.eclipse.persistence.indirection.IndirectContainer.isInstantiated.

PUBLIC: Return whether the contents have been read from the database.
public boolean
protected boolean
public Iterator<E>
iterator()

Overrides java.util.Vector.iterator.

Implements java.util.List.iterator, java.util.Collection.iterator.

Returns an iterator over the elements in this list in proper sequence.
public E
lastElement()

Overrides java.util.Vector.lastElement.

Returns the last component of the vector.
public int
lastIndexOf(Object
element to search for
elem
)

Overrides java.util.Vector.lastIndexOf.

Implements java.util.List.lastIndexOf.

Returns the index of the last occurrence of the specified element in this vector, or -1 if this vector does not contain the element.
public int
lastIndexOf(Object
element to search for
elem
,
int
index to start searching backwards from
index
)

Overrides java.util.Vector.lastIndexOf.

Returns the index of the last occurrence of the specified element in this vector, searching backwards from index, or returns -1 if the element is not found.
public ListIterator<E>
listIterator()

Overrides java.util.Vector.listIterator.

Implements java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence).
public ListIterator<E>
listIterator(final int
index of the first element to be returned from the list iterator (by a call to next)
index
)

Overrides java.util.Vector.listIterator.

Implements java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list.
public Stream<E>
parallelStream()

Overrides default java.util.Collection.parallelStream.

Returns a possibly parallel Stream with this collection as its source.
protected void
raiseAddChangeEvent(E element, Integer index)

Raise the add change event and relationship maintenance.

protected void
raiseAddChangeEvent(E element, Integer index, boolean isSet)

protected void
raiseRemoveChangeEvent(Object element, Integer index)

Raise the remove change event.

protected void
raiseRemoveChangeEvent(Object element, Integer index, boolean isSet)

public E
remove(int
the index of the element to be removed
index
)

Overrides java.util.Vector.remove.

Implements java.util.List.remove.

Removes the element at the specified position in this Vector.
public boolean
remove(Object
element to be removed from this Vector, if present
element
)

Overrides java.util.Vector.remove.

Implements java.util.List.remove, java.util.Collection.remove.

Removes the first occurrence of the specified element in this Vector If the Vector does not contain the element, it is unchanged.
public boolean
removeAll(Collection<?>
a collection of elements to be removed from the Vector
c
)

Overrides java.util.Vector.removeAll.

Implements java.util.List.removeAll, java.util.Collection.removeAll.

Removes from this Vector all of its elements that are contained in the specified Collection.
public void
removeAllElements()

Overrides java.util.Vector.removeAllElements.

Removes all components from this vector and sets its size to zero.
public boolean
removeElement(Object
the component to be removed
obj
)

Overrides java.util.Vector.removeElement.

Removes the first (lowest-indexed) occurrence of the argument from this vector.
public void
removeElementAt(int
the index of the object to remove
index
)

Overrides java.util.Vector.removeElementAt.

Deletes the component at the specified index.
public synchronized boolean
removeIf(Predicate<? super E>
a predicate which returns true for elements to be removed
filter
)

Overrides java.util.Vector.removeIf.

Overrides default java.util.Collection.removeIf.

Removes all of the elements of this collection that satisfy the given predicate.
public synchronized void
replaceAll(UnaryOperator<E>
the operator to apply to each element
operator
)

Overrides java.util.Vector.replaceAll.

Overrides default java.util.List.replaceAll.

Replaces each element of this list with the result of applying the operator to that element.
public boolean
retainAll(Collection<?>
a collection of elements to be retained in this Vector (all other elements are removed)
c
)

Overrides java.util.Vector.retainAll.

Implements java.util.List.retainAll, java.util.Collection.retainAll.

Retains only the elements in this Vector that are contained in the specified Collection.
public E
set(int
index of the element to replace
index
,
E
element to be stored at the specified position
element
)

Overrides java.util.Vector.set.

Implements java.util.List.set.

Replaces the element at the specified position in this Vector with the specified element.
public void
setElementAt(E
what the component is to be set to
obj
,
int
the specified index
index
)

Overrides java.util.Vector.setElementAt.

Sets the component at the specified index of this vector to be the specified object.
public void
setIsListOrderBrokenInDb(boolean isBroken)

public void
setSize(int
the new size of this vector
newSize
)

Overrides java.util.Vector.setSize.

Sets the size of this vector.
public void
setTrackedAttributeName(String attributeName)

Implements org.eclipse.persistence.descriptors.changetracking.CollectionChangeTracker.setTrackedAttributeName.

INTERNAL: Set the mapping attribute name, used to raise change events.
public void
setUseLazyInstantiation(boolean useLazyInstantiation)

Implements org.eclipse.persistence.indirection.IndirectCollection.setUseLazyInstantiation.

INTERNAL Set whether this collection should attempt do deal with adds and removes without retrieving the collection from the dB
public void
protected boolean
shouldAvoidInstantiation()

INTERNAL: Return if add/remove should trigger instantiation or avoid.

protected boolean
shouldUseLazyInstantiation()

Return whether this collection should attempt do deal with adds and removes without retrieving the collection from the dB

public int
size()

Overrides java.util.Vector.size.

Implements java.util.List.size, java.util.Collection.size.

Returns the number of components in this vector.
public void
sort(Comparator<? super E>
the Comparator used to compare list elements. A null value indicates that the elements' natural ordering should be used
c
)

Overrides java.util.Vector.sort.

Overrides default java.util.List.sort.

Sorts this list according to the order induced by the specified Comparator.
public Spliterator<E>
spliterator()

Overrides java.util.Vector.spliterator.

Overrides default java.util.List.spliterator, java.util.Collection.spliterator.

Creates a late-binding and fail-fast Spliterator over the elements in this list.
public Stream<E>
stream()

Overrides default java.util.Collection.stream.

Returns a sequential Stream with this collection as its source.
public List<E>
subList(int
low endpoint (inclusive) of the subList
fromIndex
,
int
high endpoint (exclusive) of the subList
toIndex
)

Overrides java.util.Vector.subList.

Implements java.util.List.subList.

Returns a view of the portion of this List between fromIndex, inclusive, and toIndex, exclusive.
public Object[]
toArray()

Overrides java.util.Vector.toArray.

Implements java.util.List.toArray, java.util.Collection.toArray.

Returns an array containing all of the elements in this Vector in the correct order.
public <T> T[]
toArray(T[]
the array into which the elements of the Vector are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
a
)

Overrides java.util.Vector.toArray.

Implements java.util.List.toArray, java.util.Collection.toArray.

Returns an array containing all of the elements in this Vector in the correct order; the runtime type of the returned array is that of the specified array.
public String
toString()

Overrides java.util.Vector.toString.

PUBLIC: Use the java.util.Vector#toString(); but wrap it with braces to indicate there is a bit of indirection.
public void
trimToSize()

Overrides java.util.Vector.trimToSize.

Trims the capacity of this vector to be the vector's current size.
protected boolean
usesListOrderField()

INTERNAL: Returns whether the mapping has listOrderField.

Inherited from java.util.Vector:
removeRange