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,IndirectContainer
public class IndirectList<E> extends Vector<E> implements CollectionChangeTracker, IndirectCollection
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.
- Since:
- TOPLink/Java 2.5
- Author:
- Big Country
- See Also:
CollectionMapping,IndirectMap, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description IndirectList()PUBLIC: Construct an empty IndirectList so that its internal data array has size 10 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PropertyChangeListener_persistence_getPropertyChangeListener()INTERNAL: Return the property change listener for change tracking.void_persistence_setPropertyChangeListener(PropertyChangeListener changeListener)INTERNAL: Set the property change listener for change tracking.voidadd(int index, E element)booleanadd(E element)booleanaddAll(int index, Collection<? extends E> c)booleanaddAll(Collection<? extends E> c)voidaddElement(E obj)intcapacity()voidclear()voidclearDeferredChanges()INTERNAL: clear any changes that have been deferred to instantiation.Objectclone()PUBLIC:booleancontains(Object element)PUBLIC:booleancontainsAll(Collection<?> c)voidcopyInto(Object[] anArray)EelementAt(int index)Enumeration<E>elements()voidensureCapacity(int minCapacity)booleanequals(Object o)EfirstElement()Eget(int index)CollectiongetAddedElements()INTERNAL: Return the elements that have been added before instantiation.ObjectgetDelegateObject()INTERNAL: Return the real collection object.CollectiongetRemovedElements()INTERNAL: Return the elements that have been removed before instantiation.StringgetTrackedAttributeName()INTERNAL: Return the mapping attribute name, used to raise change events.ValueHolderInterfacegetValueHolder()INTERNAL: Return the valueHolder.booleanhasAddedElements()INTERNAL: Return if any elements that have been added before instantiation.booleanhasBeenRegistered()INTERNAL: return whether this IndirectList has been registered with the UnitOfWorkbooleanhasDeferredChanges()INTERNAL: Return if any elements that have been added or removed before instantiation.inthashCode()INTERNAL:booleanhasRemovedElements()INTERNAL: Return if any elements that have been removed before instantiation.booleanhasTrackedPropertyChangeListener()INTERNAL: Return if the collection has a property change listener for change tracking.intindexOf(Object elem)intindexOf(Object elem, int index)voidinsertElementAt(E obj, int index)booleanisEmpty()booleanisInstantiated()PUBLIC: Return whether the contents have been read from the database.booleanisListOrderBrokenInDb()Iterator<E>iterator()ElastElement()intlastIndexOf(Object elem)intlastIndexOf(Object elem, int index)ListIterator<E>listIterator()ListIterator<E>listIterator(int index)Eremove(int index)booleanremove(Object element)booleanremoveAll(Collection<?> c)voidremoveAllElements()booleanremoveElement(Object obj)voidremoveElementAt(int index)booleanretainAll(Collection<?> c)Eset(int index, E element)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 valueHolder)INTERNAL: Set the value holder.intsize()voidsort(Comparator<? super E> c)Sort content of this instance according to the order induced by provided comparator.List<E>subList(int fromIndex, int toIndex)Object[]toArray()<T> T[]toArray(T[] a)StringtoString()PUBLIC: Use the java.util.Vector#toString(); but wrap it with braces to indicate there is a bit of indirection.voidtrimToSize()-
Methods inherited from class java.util.Vector
forEach, removeIf, replaceAll, spliterator
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
-
-
-
Constructor Detail
-
IndirectList
public IndirectList()
PUBLIC: Construct an empty IndirectList so that its internal data array has size 10 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 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.- Parameters:
collection- a collection containing the elements to construct this IndirectList with.
-
-
Method Detail
-
add
public void add(int index, E element)
-
add
public boolean add(E element)
- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceList<E>- Overrides:
addin classVector<E>- See Also:
Vector.add(java.lang.Object)
-
addAll
public boolean addAll(int index, Collection<? extends E> c)
-
addAll
public boolean addAll(Collection<? extends E> c)
- Specified by:
addAllin interfaceCollection<E>- Specified by:
addAllin interfaceList<E>- Overrides:
addAllin classVector<E>- See Also:
Vector.addAll(java.util.Collection)
-
addElement
public void addElement(E obj)
- Overrides:
addElementin classVector<E>- See Also:
Vector.addElement(java.lang.Object)
-
capacity
public int capacity()
- Overrides:
capacityin classVector<E>- See Also:
Vector.capacity()
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceList<E>- Overrides:
clearin classVector<E>- See Also:
Vector.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
-
clone
public Object clone()
PUBLIC:- Overrides:
clonein classVector<E>- See Also:
This will result in a database query if necessary.
-
contains
public boolean contains(Object element)
PUBLIC:- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin interfaceList<E>- Overrides:
containsin classVector<E>- See Also:
Vector.contains(java.lang.Object)
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>- Overrides:
containsAllin classVector<E>- See Also:
Vector.containsAll(java.util.Collection)
-
copyInto
public void copyInto(Object[] anArray)
- Overrides:
copyIntoin classVector<E>- See Also:
Vector.copyInto(java.lang.Object[])
-
elementAt
public E elementAt(int index)
- Overrides:
elementAtin classVector<E>- See Also:
Vector.elementAt(int)
-
elements
public Enumeration<E> elements()
- Overrides:
elementsin classVector<E>- See Also:
Vector.elements()
-
ensureCapacity
public void ensureCapacity(int minCapacity)
- Overrides:
ensureCapacityin classVector<E>- See Also:
Vector.ensureCapacity(int)
-
equals
public boolean equals(Object o)
- Specified by:
equalsin interfaceCollection<E>- Specified by:
equalsin interfaceList<E>- Overrides:
equalsin classVector<E>- See Also:
Vector.equals(java.lang.Object)
-
firstElement
public E firstElement()
- Overrides:
firstElementin classVector<E>- See Also:
Vector.firstElement()
-
get
public E get(int index)
-
getDelegateObject
public Object getDelegateObject()
INTERNAL: Return the real collection object. This will force instantiation.- Specified by:
getDelegateObjectin interfaceIndirectCollection
-
getValueHolder
public ValueHolderInterface getValueHolder()
INTERNAL: Return the valueHolder. This method used to be synchronized, which caused deadlock.- Specified by:
getValueHolderin interfaceIndirectContainer- 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:- Specified by:
hashCodein interfaceCollection<E>- Specified by:
hashCodein interfaceList<E>- Overrides:
hashCodein classVector<E>- See Also:
Vector.hashCode()
-
indexOf
public int indexOf(Object elem)
-
indexOf
public int indexOf(Object elem, int index)
- Overrides:
indexOfin classVector<E>- See Also:
Vector.indexOf(java.lang.Object, int)
-
insertElementAt
public void insertElementAt(E obj, int index)
- Overrides:
insertElementAtin classVector<E>- See Also:
Vector.insertElementAt(java.lang.Object, int)
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection<E>- Specified by:
isEmptyin interfaceList<E>- Overrides:
isEmptyin classVector<E>- See Also:
Vector.isEmpty()
-
isInstantiated
public boolean isInstantiated()
PUBLIC: Return whether the contents have been read from the database.- Specified by:
isInstantiatedin interfaceIndirectContainer
-
lastElement
public E lastElement()
- Overrides:
lastElementin classVector<E>- See Also:
Vector.lastElement()
-
lastIndexOf
public int lastIndexOf(Object elem)
- Specified by:
lastIndexOfin interfaceList<E>- Overrides:
lastIndexOfin classVector<E>- See Also:
Vector.lastIndexOf(java.lang.Object)
-
lastIndexOf
public int lastIndexOf(Object elem, int index)
- Overrides:
lastIndexOfin classVector<E>- See Also:
Vector.lastIndexOf(java.lang.Object, int)
-
listIterator
public ListIterator<E> listIterator()
- Specified by:
listIteratorin interfaceList<E>- Overrides:
listIteratorin classVector<E>- See Also:
AbstractList.listIterator()
-
listIterator
public ListIterator<E> listIterator(int index)
- Specified by:
listIteratorin interfaceList<E>- Overrides:
listIteratorin classVector<E>- See Also:
AbstractList.listIterator(int)
-
remove
public E remove(int index)
-
remove
public boolean remove(Object element)
- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceList<E>- Overrides:
removein classVector<E>- See Also:
Vector.remove(java.lang.Object)
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceList<E>- Overrides:
removeAllin classVector<E>- See Also:
Vector.removeAll(java.util.Collection)
-
removeAllElements
public void removeAllElements()
- Overrides:
removeAllElementsin classVector<E>- See Also:
Vector.removeAllElements()
-
removeElement
public boolean removeElement(Object obj)
- Overrides:
removeElementin classVector<E>- See Also:
Vector.removeElement(java.lang.Object)
-
removeElementAt
public void removeElementAt(int index)
- Overrides:
removeElementAtin classVector<E>- See Also:
Vector.removeElementAt(int)
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAllin interfaceCollection<E>- Specified by:
retainAllin interfaceList<E>- Overrides:
retainAllin classVector<E>- See Also:
Vector.retainAll(java.util.Collection)
-
setElementAt
public void setElementAt(E obj, int index)
- Overrides:
setElementAtin classVector<E>- See Also:
Vector.setElementAt(java.lang.Object, int)
-
setSize
public void setSize(int newSize)
- Overrides:
setSizein classVector<E>- See Also:
Vector.setSize(int)
-
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
-
setValueHolder
public void setValueHolder(ValueHolderInterface valueHolder)
INTERNAL: Set the value holder.- Specified by:
setValueHolderin interfaceIndirectContainer
-
size
public int size()
- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceList<E>- Overrides:
sizein classVector<E>- See Also:
Vector.size()
-
sort
public void sort(Comparator<? super E> c)
Sort content of this instance according to the order induced by provided comparator.
-
toArray
public Object[] toArray()
- Specified by:
toArrayin interfaceCollection<E>- Specified by:
toArrayin interfaceList<E>- Overrides:
toArrayin classVector<E>- See Also:
Vector.toArray()
-
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArrayin interfaceCollection<E>- Specified by:
toArrayin interfaceList<E>- Overrides:
toArrayin classVector<E>- See Also:
Vector.toArray(java.lang.Object[])
-
toString
public String 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.- Overrides:
toStringin classVector<E>- See Also:
Vector.toString()
-
trimToSize
public void trimToSize()
- Overrides:
trimToSizein classVector<E>- See Also:
Vector.trimToSize()
-
_persistence_getPropertyChangeListener
public PropertyChangeListener _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
public void _persistence_setPropertyChangeListener(PropertyChangeListener changeListener)
INTERNAL: Set the property change listener for change tracking.- Specified by:
_persistence_setPropertyChangeListenerin interfaceChangeTracker
-
getTrackedAttributeName
public String getTrackedAttributeName()
INTERNAL: Return the mapping attribute name, used to raise change events.- Specified by:
getTrackedAttributeNamein interfaceCollectionChangeTracker
-
setTrackedAttributeName
public void setTrackedAttributeName(String attributeName)
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
public Collection getRemovedElements()
INTERNAL: Return the elements that have been removed before instantiation.- Specified by:
getRemovedElementsin interfaceIndirectCollection
-
getAddedElements
public Collection getAddedElements()
INTERNAL: Return the elements that have been added before instantiation.- Specified by:
getAddedElementsin interfaceIndirectCollection
-
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
-
isListOrderBrokenInDb
public boolean isListOrderBrokenInDb()
-
setIsListOrderBrokenInDb
public void setIsListOrderBrokenInDb(boolean isBroken)
-
-