org.eclipse.persistence.indirection
Class IndirectList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector
              extended by org.eclipse.persistence.indirection.IndirectList
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, List, RandomAccess, ChangeTracker, CollectionChangeTracker, IndirectCollection, IndirectContainer

public class IndirectList
extends Vector
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:

TopLink will place an IndirectList in the instance variable when the containing domain object is read from the datatabase. With the first message sent to the IndirectList, the contents are fetched from the database and normal Collection/List/Vector behavior is resumed.

Since:
TOPLink/Java 2.5
Author:
Big Country
See Also:
CollectionMapping, IndirectMap, Serialized Form

Constructor Summary
IndirectList()
          PUBLIC: Construct an empty IndirectList so that its internal data array has size 10 and its standard capacity increment is zero.
IndirectList(Collection collection)
          PUBLIC: Construct an IndirectList containing the elements of the specified collection, in the order they are returned by the collection's iterator.
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.
 
Method Summary
 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.
 void add(int index, Object element)
           
 boolean add(Object element)
           
 boolean addAll(Collection c)
           
 boolean addAll(int index, Collection c)
           
 void addElement(Object obj)
           
 int capacity()
           
 void clear()
           
 Object clone()
          PUBLIC:
 boolean contains(Object element)
          PUBLIC:
 boolean containsAll(Collection c)
           
 void copyInto(Object[] anArray)
           
 Object elementAt(int index)
           
 Enumeration elements()
           
 void ensureCapacity(int minCapacity)
           
 boolean equals(Object o)
           
 Object firstElement()
           
 Object get(int index)
           
 Collection getAddedElements()
          INTERNAL: Return the elements that have been added before instantiation.
 Object getDelegateObject()
          INTERNAL: Return the real collection object.
 Collection getRemovedElements()
          INTERNAL: Return the elements that have been removed before instantiation.
 String getTrackedAttributeName()
          INTERNAL: Return the mapping attribute name, used to raise change events.
 ValueHolderInterface getValueHolder()
          INTERNAL: Return the valueHolder.
 boolean hasAddedElements()
          INTERNAL: Return if any elements that have been added before instantiation.
 boolean hasBeenRegistered()
          INTERNAL: return whether this IndirectList has been registered with the UnitOfWork
 boolean hasDeferredChanges()
          INTERNAL: Return if any elements that have been added or removed before instantiation.
 int hashCode()
          INTERNAL:
 boolean hasRemovedElements()
          INTERNAL: Return if any elements that have been removed before instantiation.
 boolean hasTrackedPropertyChangeListener()
          INTERNAL: Return if the collection has a property change listener for change tracking.
 int indexOf(Object elem)
           
 int indexOf(Object elem, int index)
           
 void insertElementAt(Object obj, int index)
           
 boolean isEmpty()
           
 boolean isInstantiated()
          PUBLIC: Return whether the contents have been read from the database.
 boolean isListOrderBrokenInDb()
           
 Iterator iterator()
           
 Object lastElement()
           
 int lastIndexOf(Object elem)
           
 int lastIndexOf(Object elem, int index)
           
 ListIterator listIterator()
           
 ListIterator listIterator(int index)
           
 Object remove(int index)
           
 boolean remove(Object element)
           
 boolean removeAll(Collection c)
           
 void removeAllElements()
           
 boolean removeElement(Object obj)
           
 void removeElementAt(int index)
           
 boolean retainAll(Collection c)
           
 Object set(int index, Object element)
           
 void setElementAt(Object 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 setValueHolder(ValueHolderInterface valueHolder)
          INTERNAL: Set the value holder.
 int size()
           
 List subList(int fromIndex, int toIndex)
           
 Object[] toArray()
           
 Object[] toArray(Object[] a)
           
 String toString()
          PUBLIC: Use the java.util.Vector#toString(); but wrap it with braces to indicate there is a bit of indirection.
 void trimToSize()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

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 vector
capacityIncrement - 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 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,
                Object element)
Specified by:
add in interface List
Overrides:
add in class Vector
See Also:
Vector.add(int, java.lang.Object)

add

public boolean add(Object element)
Specified by:
add in interface Collection
Specified by:
add in interface List
Overrides:
add in class Vector
See Also:
Vector.add(java.lang.Object)

addAll

public boolean addAll(int index,
                      Collection c)
Specified by:
addAll in interface List
Overrides:
addAll in class Vector
See Also:
Vector.addAll(int, java.util.Collection)

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface Collection
Specified by:
addAll in interface List
Overrides:
addAll in class Vector
See Also:
Vector.addAll(java.util.Collection)

addElement

public void addElement(Object obj)
Overrides:
addElement in class Vector
See Also:
Vector.addElement(java.lang.Object)

capacity

public int capacity()
Overrides:
capacity in class Vector
See Also:
Vector.capacity()

clear

public void clear()
Specified by:
clear in interface Collection
Specified by:
clear in interface List
Overrides:
clear in class Vector
See Also:
Vector.clear()

clone

public Object clone()
PUBLIC:

Overrides:
clone in class Vector
See Also:
This will result in a database query if necessary.

contains

public boolean contains(Object element)
PUBLIC:

Specified by:
contains in interface Collection
Specified by:
contains in interface List
Overrides:
contains in class Vector
See Also:
Vector.contains(java.lang.Object)

containsAll

public boolean containsAll(Collection c)
Specified by:
containsAll in interface Collection
Specified by:
containsAll in interface List
Overrides:
containsAll in class Vector
See Also:
Vector.containsAll(java.util.Collection)

copyInto

public void copyInto(Object[] anArray)
Overrides:
copyInto in class Vector
See Also:
Vector.copyInto(java.lang.Object[])

elementAt

public Object elementAt(int index)
Overrides:
elementAt in class Vector
See Also:
Vector.elementAt(int)

elements

public Enumeration elements()
Overrides:
elements in class Vector
See Also:
Vector.elements()

ensureCapacity

public void ensureCapacity(int minCapacity)
Overrides:
ensureCapacity in class Vector
See Also:
Vector.ensureCapacity(int)

equals

public boolean equals(Object o)
Specified by:
equals in interface Collection
Specified by:
equals in interface List
Overrides:
equals in class Vector
See Also:
Vector.equals(java.lang.Object)

firstElement

public Object firstElement()
Overrides:
firstElement in class Vector
See Also:
Vector.firstElement()

get

public Object get(int index)
Specified by:
get in interface List
Overrides:
get in class Vector
See Also:
Vector.get(int)

getDelegateObject

public Object getDelegateObject()
INTERNAL: Return the real collection object. This will force instantiation.

Specified by:
getDelegateObject in interface IndirectCollection

getValueHolder

public ValueHolderInterface getValueHolder()
INTERNAL: Return the valueHolder. This method used to be synchronized, which caused deadlock.

Specified by:
getValueHolder in interface IndirectContainer
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:
hashCode in interface Collection
Specified by:
hashCode in interface List
Overrides:
hashCode in class Vector
See Also:
Vector.hashCode()

indexOf

public int indexOf(Object elem)
Specified by:
indexOf in interface List
Overrides:
indexOf in class Vector
See Also:
Vector.indexOf(java.lang.Object)

indexOf

public int indexOf(Object elem,
                   int index)
Overrides:
indexOf in class Vector
See Also:
Vector.indexOf(java.lang.Object, int)

insertElementAt

public void insertElementAt(Object obj,
                            int index)
Overrides:
insertElementAt in class Vector
See Also:
Vector.insertElementAt(java.lang.Object, int)

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection
Specified by:
isEmpty in interface List
Overrides:
isEmpty in class Vector
See Also:
Vector.isEmpty()

isInstantiated

public boolean isInstantiated()
PUBLIC: Return whether the contents have been read from the database.

Specified by:
isInstantiated in interface IndirectContainer

iterator

public Iterator iterator()
Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface List
Overrides:
iterator in class Vector
See Also:
AbstractList.iterator()

lastElement

public Object lastElement()
Overrides:
lastElement in class Vector
See Also:
Vector.lastElement()

lastIndexOf

public int lastIndexOf(Object elem)
Specified by:
lastIndexOf in interface List
Overrides:
lastIndexOf in class Vector
See Also:
Vector.lastIndexOf(java.lang.Object)

lastIndexOf

public int lastIndexOf(Object elem,
                       int index)
Overrides:
lastIndexOf in class Vector
See Also:
Vector.lastIndexOf(java.lang.Object, int)

listIterator

public ListIterator listIterator()
Specified by:
listIterator in interface List
Overrides:
listIterator in class Vector
See Also:
AbstractList.listIterator()

listIterator

public ListIterator listIterator(int index)
Specified by:
listIterator in interface List
Overrides:
listIterator in class Vector
See Also:
AbstractList.listIterator(int)

remove

public Object remove(int index)
Specified by:
remove in interface List
Overrides:
remove in class Vector
See Also:
Vector.remove(int)

remove

public boolean remove(Object element)
Specified by:
remove in interface Collection
Specified by:
remove in interface List
Overrides:
remove in class Vector
See Also:
Vector.remove(java.lang.Object)

removeAll

public boolean removeAll(Collection c)
Specified by:
removeAll in interface Collection
Specified by:
removeAll in interface List
Overrides:
removeAll in class Vector
See Also:
Vector.removeAll(java.util.Collection)

removeAllElements

public void removeAllElements()
Overrides:
removeAllElements in class Vector
See Also:
Vector.removeAllElements()

removeElement

public boolean removeElement(Object obj)
Overrides:
removeElement in class Vector
See Also:
Vector.removeElement(java.lang.Object)

removeElementAt

public void removeElementAt(int index)
Overrides:
removeElementAt in class Vector
See Also:
Vector.removeElementAt(int)

retainAll

public boolean retainAll(Collection c)
Specified by:
retainAll in interface Collection
Specified by:
retainAll in interface List
Overrides:
retainAll in class Vector
See Also:
Vector.retainAll(java.util.Collection)

set

public Object set(int index,
                  Object element)
Specified by:
set in interface List
Overrides:
set in class Vector
See Also:
Vector.set(int, java.lang.Object)

setElementAt

public void setElementAt(Object obj,
                         int index)
Overrides:
setElementAt in class Vector
See Also:
Vector.setElementAt(java.lang.Object, int)

setSize

public void setSize(int newSize)
Overrides:
setSize in class Vector
See Also:
Vector.setSize(int)

setValueHolder

public void setValueHolder(ValueHolderInterface valueHolder)
INTERNAL: Set the value holder.

Specified by:
setValueHolder in interface IndirectContainer

size

public int size()
Specified by:
size in interface Collection
Specified by:
size in interface List
Overrides:
size in class Vector
See Also:
Vector.size()

subList

public List subList(int fromIndex,
                    int toIndex)
Specified by:
subList in interface List
Overrides:
subList in class Vector
See Also:
Vector.subList(int, int)

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection
Specified by:
toArray in interface List
Overrides:
toArray in class Vector
See Also:
Vector.toArray()

toArray

public Object[] toArray(Object[] a)
Specified by:
toArray in interface Collection
Specified by:
toArray in interface List
Overrides:
toArray in class Vector
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:
toString in class Vector
See Also:
Vector.toString()

trimToSize

public void trimToSize()
Overrides:
trimToSize in class Vector
See Also:
Vector.trimToSize()

_persistence_getPropertyChangeListener

public PropertyChangeListener _persistence_getPropertyChangeListener()
INTERNAL: Return the property change listener for change tracking.

Specified by:
_persistence_getPropertyChangeListener in interface ChangeTracker

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_setPropertyChangeListener in interface ChangeTracker

getTrackedAttributeName

public String getTrackedAttributeName()
INTERNAL: Return the mapping attribute name, used to raise change events.

Specified by:
getTrackedAttributeName in interface CollectionChangeTracker

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:
setTrackedAttributeName in interface CollectionChangeTracker

getRemovedElements

public Collection getRemovedElements()
INTERNAL: Return the elements that have been removed before instantiation.

Specified by:
getRemovedElements in interface IndirectCollection

getAddedElements

public Collection getAddedElements()
INTERNAL: Return the elements that have been added before instantiation.

Specified by:
getAddedElements in interface IndirectCollection

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 interface IndirectCollection

isListOrderBrokenInDb

public boolean isListOrderBrokenInDb()

setIsListOrderBrokenInDb

public void setIsListOrderBrokenInDb(boolean isBroken)