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
FieldsModifier and TypeFieldDescriptionReduce type casting.protected intStore initial size for lazy init.protected booleanPERF: 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, elementDataFields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionPUBLIC: Construct an empty IndirectList so that its internal data array has size10and 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.voidbooleanbooleanaddAll(int index, Collection<? extends E> c) booleanaddAll(Collection<? extends E> c) voidaddElement(E obj) INTERNAL: Return the freshly-built delegate.intcapacity()voidclear()voidINTERNAL: clear any changes that have been deferred to instantiation.clone()PUBLIC:booleanPUBLIC:booleancontainsAll(Collection<?> c) voidelementAt(int index) elements()voidensureCapacity(int minCapacity) booleanvoidget(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.booleanINTERNAL: Return if any elements that have been added before instantiation.booleanINTERNAL: return whether this IndirectList has been registered with the UnitOfWorkbooleanINTERNAL: Return if any elements that have been added or removed before instantiation.inthashCode()INTERNAL:booleanINTERNAL: Return if any elements that have been removed before instantiation.booleanINTERNAL: Return if the collection has a property change listener for change tracking.intintvoidinsertElementAt(E obj, int index) booleanisEmpty()booleanPUBLIC: Return whether the contents have been read from the database.booleanprotected booleaniterator()intlastIndexOf(Object elem) intlastIndexOf(Object elem, int index) listIterator(int index) protected voidraiseAddChangeEvent(E element, Integer index) Raise the add change event and relationship maintenance.protected voidraiseAddChangeEvent(E element, Integer index, boolean isSet) protected voidraiseRemoveChangeEvent(Object element, Integer index) Raise the remove change event.protected voidraiseRemoveChangeEvent(Object element, Integer index, boolean isSet) remove(int index) booleanbooleanremoveAll(Collection<?> c) voidbooleanremoveElement(Object obj) voidremoveElementAt(int index) booleanvoidreplaceAll(UnaryOperator<E> operator) booleanretainAll(Collection<?> c) voidsetElementAt(E obj, int index) voidsetIsListOrderBrokenInDb(boolean isBroken) voidsetSize(int newSize) voidsetTrackedAttributeName(String attributeName) INTERNAL: Set the mapping attribute name, used to raise change events.voidsetUseLazyInstantiation(boolean useLazyInstantiation) INTERNAL Set whether this collection should attempt do deal with adds and removes without retrieving the collection from the dBvoidsetValueHolder(ValueHolderInterface<List<E>> valueHolder) INTERNAL: Set the value holder.protected booleanINTERNAL: Return if add/remove should trigger instantiation or avoid.protected booleanReturn whether this collection should attempt do deal with adds and removes without retrieving the collection from the dBintsize()voidsort(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.voidprotected booleanINTERNAL: 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 size10and 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:
addElementin 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:
clearDeferredChangesin interfaceIndirectCollection<E,List<E>>
-
clone
PUBLIC: -
contains
PUBLIC: -
containsAll
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>- Overrides:
containsAllin classVector<E>- See Also:
-
copyInto
-
elementAt
-
elements
-
ensureCapacity
public void ensureCapacity(int minCapacity) - Overrides:
ensureCapacityin classVector<E>- See Also:
-
equals
-
firstElement
- Overrides:
firstElementin 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:
getDelegateObjectin interfaceIndirectCollection<E,List<E>>
-
getValueHolder
INTERNAL: Return the valueHolder. This method used to be synchronized, which caused deadlock.- Specified by:
getValueHolderin 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:
insertElementAtin 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:
isInstantiatedin interfaceIndirectContainer<E>
-
iterator
-
lastElement
- Overrides:
lastElementin classVector<E>- See Also:
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList<E>- Overrides:
lastIndexOfin classVector<E>- See Also:
-
lastIndexOf
- Overrides:
lastIndexOfin classVector<E>- See Also:
-
listIterator
- Specified by:
listIteratorin interfaceList<E>- Overrides:
listIteratorin classVector<E>- See Also:
-
listIterator
- Specified by:
listIteratorin interfaceList<E>- Overrides:
listIteratorin classVector<E>- See Also:
-
remove
-
remove
-
removeAll
-
removeAllElements
public void removeAllElements()- Overrides:
removeAllElementsin classVector<E>- See Also:
-
removeElement
- Overrides:
removeElementin classVector<E>- See Also:
-
removeElementAt
public void removeElementAt(int index) - Overrides:
removeElementAtin classVector<E>- See Also:
-
retainAll
-
set
-
setElementAt
- Overrides:
setElementAtin 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:
setUseLazyInstantiationin interfaceIndirectCollection<E,List<E>>
-
setValueHolder
INTERNAL: Set the value holder.- Specified by:
setValueHolderin 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:
spliteratorin interfaceCollection<E>- Specified by:
spliteratorin interfaceIterable<E>- Specified by:
spliteratorin interfaceList<E>- Overrides:
spliteratorin classVector<E>
-
replaceAll
- Specified by:
replaceAllin interfaceList<E>- Overrides:
replaceAllin classVector<E>
-
removeIf
-
forEach
-
parallelStream
- Specified by:
parallelStreamin interfaceCollection<E>
-
stream
- Specified by:
streamin 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:
trimToSizein classVector<E>- See Also:
-
_persistence_getPropertyChangeListener
INTERNAL: Return the property change listener for change tracking.- Specified by:
_persistence_getPropertyChangeListenerin 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_setPropertyChangeListenerin interfaceChangeTracker
-
getTrackedAttributeName
INTERNAL: Return the mapping attribute name, used to raise change events.- Specified by:
getTrackedAttributeNamein interfaceCollectionChangeTracker
-
setTrackedAttributeName
INTERNAL: Set the mapping attribute name, used to raise change events. This is required if the change listener is set.- Specified by:
setTrackedAttributeNamein interfaceCollectionChangeTracker
-
getRemovedElements
INTERNAL: Return the elements that have been removed before instantiation.- Specified by:
getRemovedElementsin interfaceIndirectCollection<E,List<E>>
-
getAddedElements
INTERNAL: Return the elements that have been added before instantiation.- Specified by:
getAddedElementsin 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:
hasDeferredChangesin 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)
-