Class IndirectList<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.Vector<E>
org.eclipse.persistence.indirection.IndirectList<E>
- Type Parameters:
E
- the type of elements maintained by this list
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<E>
,Collection<E>
,List<E>
,RandomAccess
,ChangeTracker
,CollectionChangeTracker
,IndirectCollection<E,
,List<E>> IndirectContainer<List<E>>
public class IndirectList<E>
extends Vector<E>
implements CollectionChangeTracker, IndirectCollection<E,List<E>>
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:
- Declare the appropriate instance variable with type Collection/List/Vector (jdk1.2).
- Send the message #useTransparentCollection() to the appropriate CollectionMapping.
- See Also:
- Author:
- Big Country
-
Field Summary
Modifier and TypeFieldDescriptionReduce type casting.protected int
Store initial size for lazy init.protected boolean
PERF: Quick check flag if has been registered in a unit of work.protected ValueHolderInterface<List<E>>
Delegate indirection behavior to a value holder.Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
ConstructorDescriptionPUBLIC: Construct an empty IndirectList so that its internal data array has size10
and its standard capacity increment is zero.IndirectList
(int initialCapacity) PUBLIC: Construct an empty IndirectList with the specified initial capacity and with its capacity increment equal to zero.IndirectList
(int initialCapacity, int capacityIncrement) PUBLIC: Construct an empty IndirectList with the specified initial capacity and capacity increment.IndirectList
(Collection<? extends E> 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 TypeMethodDescriptionINTERNAL: Return the property change listener for change tracking.void
_persistence_setPropertyChangeListener
(PropertyChangeListener changeListener) INTERNAL: Set the property change listener for change tracking.void
boolean
boolean
addAll
(int index, Collection<? extends E> c) boolean
addAll
(Collection<? extends E> c) void
addElement
(E obj) INTERNAL: Return the freshly-built delegate.int
capacity()
void
clear()
void
INTERNAL: clear any changes that have been deferred to instantiation.clone()
PUBLIC:boolean
PUBLIC:boolean
containsAll
(Collection<?> c) void
elementAt
(int index) elements()
void
ensureCapacity
(int minCapacity) boolean
void
get
(int index) INTERNAL: Return the elements that have been added before instantiation.INTERNAL: Check whether the contents have been read from the database.INTERNAL: Return the real collection object.INTERNAL: Return the elements that have been removed before instantiation.INTERNAL: Return the mapping attribute name, used to raise change events.INTERNAL: Return the valueHolder.boolean
INTERNAL: Return if any elements that have been added before instantiation.boolean
INTERNAL: return whether this IndirectList has been registered with the UnitOfWorkboolean
INTERNAL: Return if any elements that have been added or removed before instantiation.int
hashCode()
INTERNAL:boolean
INTERNAL: Return if any elements that have been removed before instantiation.boolean
INTERNAL: Return if the collection has a property change listener for change tracking.int
int
void
insertElementAt
(E obj, int index) boolean
isEmpty()
boolean
PUBLIC: Return whether the contents have been read from the database.boolean
protected boolean
iterator()
int
lastIndexOf
(Object elem) int
lastIndexOf
(Object elem, int index) listIterator
(int index) 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) remove
(int index) boolean
boolean
removeAll
(Collection<?> c) void
boolean
removeElement
(Object obj) void
removeElementAt
(int index) boolean
void
replaceAll
(UnaryOperator<E> operator) boolean
retainAll
(Collection<?> c) void
setElementAt
(E obj, int index) void
setIsListOrderBrokenInDb
(boolean isBroken) void
setSize
(int newSize) void
setTrackedAttributeName
(String attributeName) INTERNAL: Set the mapping attribute name, used to raise change events.void
setUseLazyInstantiation
(boolean useLazyInstantiation) INTERNAL Set whether this collection should attempt do deal with adds and removes without retrieving the collection from the dBvoid
setValueHolder
(ValueHolderInterface<List<E>> valueHolder) INTERNAL: Set the value holder.protected boolean
INTERNAL: Return if add/remove should trigger instantiation or avoid.protected boolean
Return whether this collection should attempt do deal with adds and removes without retrieving the collection from the dBint
size()
void
sort
(Comparator<? super E> c) stream()
subList
(int fromIndex, int toIndex) Object[]
toArray()
<T> T[]
toArray
(T[] a) toString()
PUBLIC: Use the java.util.Vector#toString(); but wrap it with braces to indicate there is a bit of indirection.void
protected boolean
INTERNAL: Returns whether the mapping has listOrderField.Methods inherited from class java.util.Vector
removeRange
-
Field Details
-
delegate
Reduce type casting. -
valueHolder
Delegate indirection behavior to a value holder. -
initialCapacity
protected int initialCapacityStore initial size for lazy init. -
isRegistered
protected boolean isRegisteredPERF: Quick check flag if has been registered in a unit of work.
-
-
Constructor Details
-
IndirectList
public IndirectList()PUBLIC: Construct an empty IndirectList so that its internal data array has size10
and its standard capacity increment is zero. -
IndirectList
public IndirectList(int initialCapacity) PUBLIC: Construct an empty IndirectList with the specified initial capacity and with its capacity increment equal to zero.- Parameters:
initialCapacity
- the initial capacity of the vector- Throws:
IllegalArgumentException
- if the specified initial capacity is negative
-
IndirectList
public IndirectList(int initialCapacity, int capacityIncrement) PUBLIC: Construct an empty IndirectList with the specified initial capacity and capacity increment.- Parameters:
initialCapacity
- the initial capacity of the vectorcapacityIncrement
- the amount by which the capacity is increased when the vector overflows- Throws:
IllegalArgumentException
- if the specified initial capacity is negative
-
IndirectList
PUBLIC: Construct an IndirectList containing the elements of the specified collection, in the order they are returned by the collection's iterator.- Parameters:
collection
- a collection containing the elements to construct this IndirectList with.
-
-
Method Details
-
add
-
raiseAddChangeEvent
Raise the add change event and relationship maintenance. -
raiseAddChangeEvent
-
isRelationshipMaintenanceRequired
protected boolean isRelationshipMaintenanceRequired() -
raiseRemoveChangeEvent
Raise the remove change event. -
raiseRemoveChangeEvent
-
add
-
addAll
-
addAll
-
addElement
- Overrides:
addElement
in classVector<E>
- See Also:
-
buildDelegate
INTERNAL: Return the freshly-built delegate. -
capacity
public int capacity() -
clear
public void clear() -
clearDeferredChanges
public void clearDeferredChanges()INTERNAL: clear any changes that have been deferred to instantiation. Indirect collections with change tracking avoid instantiation on add/remove.- Specified by:
clearDeferredChanges
in interfaceIndirectCollection<E,
List<E>>
-
clone
PUBLIC: -
contains
PUBLIC: -
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceList<E>
- Overrides:
containsAll
in classVector<E>
- See Also:
-
copyInto
-
elementAt
-
elements
-
ensureCapacity
public void ensureCapacity(int minCapacity) - Overrides:
ensureCapacity
in classVector<E>
- See Also:
-
equals
-
firstElement
- Overrides:
firstElement
in classVector<E>
- See Also:
-
get
-
getDelegate
INTERNAL: Check whether the contents have been read from the database. If they have not, read them and set the delegate. This method used to be synchronized, which caused deadlock. -
getDelegateObject
INTERNAL: Return the real collection object. This will force instantiation.- Specified by:
getDelegateObject
in interfaceIndirectCollection<E,
List<E>>
-
getValueHolder
INTERNAL: Return the valueHolder. This method used to be synchronized, which caused deadlock.- Specified by:
getValueHolder
in interfaceIndirectContainer<E>
- Returns:
- org.eclipse.persistence.indirection.ValueHolderInterface A representation of the valueholder * which this container uses
-
hasBeenRegistered
public boolean hasBeenRegistered()INTERNAL: return whether this IndirectList has been registered with the UnitOfWork -
hashCode
public int hashCode()INTERNAL: -
indexOf
-
indexOf
-
insertElementAt
- Overrides:
insertElementAt
in classVector<E>
- See Also:
-
isEmpty
public boolean isEmpty() -
isInstantiated
public boolean isInstantiated()PUBLIC: Return whether the contents have been read from the database.- Specified by:
isInstantiated
in interfaceIndirectContainer<E>
-
iterator
-
lastElement
- Overrides:
lastElement
in classVector<E>
- See Also:
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceList<E>
- Overrides:
lastIndexOf
in classVector<E>
- See Also:
-
lastIndexOf
- Overrides:
lastIndexOf
in classVector<E>
- See Also:
-
listIterator
- Specified by:
listIterator
in interfaceList<E>
- Overrides:
listIterator
in classVector<E>
- See Also:
-
listIterator
- Specified by:
listIterator
in interfaceList<E>
- Overrides:
listIterator
in classVector<E>
- See Also:
-
remove
-
remove
-
removeAll
-
removeAllElements
public void removeAllElements()- Overrides:
removeAllElements
in classVector<E>
- See Also:
-
removeElement
- Overrides:
removeElement
in classVector<E>
- See Also:
-
removeElementAt
public void removeElementAt(int index) - Overrides:
removeElementAt
in classVector<E>
- See Also:
-
retainAll
-
set
-
setElementAt
- Overrides:
setElementAt
in classVector<E>
- See Also:
-
setSize
public void setSize(int newSize) -
setUseLazyInstantiation
public void setUseLazyInstantiation(boolean useLazyInstantiation) INTERNAL Set whether this collection should attempt do deal with adds and removes without retrieving the collection from the dB- Specified by:
setUseLazyInstantiation
in interfaceIndirectCollection<E,
List<E>>
-
setValueHolder
INTERNAL: Set the value holder.- Specified by:
setValueHolder
in interfaceIndirectContainer<E>
-
size
public int size() -
shouldUseLazyInstantiation
protected boolean shouldUseLazyInstantiation()Return whether this collection should attempt do deal with adds and removes without retrieving the collection from the dB- Returns:
-
subList
-
toArray
-
toArray
public <T> T[] toArray(T[] a) -
spliterator
- Specified by:
spliterator
in interfaceCollection<E>
- Specified by:
spliterator
in interfaceIterable<E>
- Specified by:
spliterator
in interfaceList<E>
- Overrides:
spliterator
in classVector<E>
-
replaceAll
- Specified by:
replaceAll
in interfaceList<E>
- Overrides:
replaceAll
in classVector<E>
-
removeIf
-
forEach
-
parallelStream
- Specified by:
parallelStream
in interfaceCollection<E>
-
stream
- Specified by:
stream
in interfaceCollection<E>
-
sort
-
toString
PUBLIC: Use the java.util.Vector#toString(); but wrap it with braces to indicate there is a bit of indirection. Don't allow this method to trigger a database read. -
trimToSize
public void trimToSize()- Overrides:
trimToSize
in classVector<E>
- See Also:
-
_persistence_getPropertyChangeListener
INTERNAL: Return the property change listener for change tracking.- Specified by:
_persistence_getPropertyChangeListener
in interfaceChangeTracker
-
hasTrackedPropertyChangeListener
public boolean hasTrackedPropertyChangeListener()INTERNAL: Return if the collection has a property change listener for change tracking. -
_persistence_setPropertyChangeListener
INTERNAL: Set the property change listener for change tracking.- Specified by:
_persistence_setPropertyChangeListener
in interfaceChangeTracker
-
getTrackedAttributeName
INTERNAL: Return the mapping attribute name, used to raise change events.- Specified by:
getTrackedAttributeName
in interfaceCollectionChangeTracker
-
setTrackedAttributeName
INTERNAL: Set the mapping attribute name, used to raise change events. This is required if the change listener is set.- Specified by:
setTrackedAttributeName
in interfaceCollectionChangeTracker
-
getRemovedElements
INTERNAL: Return the elements that have been removed before instantiation.- Specified by:
getRemovedElements
in interfaceIndirectCollection<E,
List<E>>
-
getAddedElements
INTERNAL: Return the elements that have been added before instantiation.- Specified by:
getAddedElements
in interfaceIndirectCollection<E,
List<E>>
-
hasAddedElements
public boolean hasAddedElements()INTERNAL: Return if any elements that have been added before instantiation. -
hasRemovedElements
public boolean hasRemovedElements()INTERNAL: Return if any elements that have been removed before instantiation. -
hasDeferredChanges
public boolean hasDeferredChanges()INTERNAL: Return if any elements that have been added or removed before instantiation.- Specified by:
hasDeferredChanges
in interfaceIndirectCollection<E,
List<E>>
-
shouldAvoidInstantiation
protected boolean shouldAvoidInstantiation()INTERNAL: Return if add/remove should trigger instantiation or avoid. Current instantiation is avoided is using change tracking. -
usesListOrderField
protected boolean usesListOrderField()INTERNAL: Returns whether the mapping has listOrderField. -
isListOrderBrokenInDb
public boolean isListOrderBrokenInDb() -
setIsListOrderBrokenInDb
public void setIsListOrderBrokenInDb(boolean isBroken)
-