Class IndirectList<E>

  • Type Parameters:
    E - the type of elements maintained by this list
    All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, java.util.RandomAccess, ChangeTracker, CollectionChangeTracker, IndirectCollection, IndirectContainer

    public class IndirectList<E>
    extends java.util.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.
    EclipseLink 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

      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​(java.util.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
      java.beans.PropertyChangeListener _persistence_getPropertyChangeListener()
      INTERNAL: Return the property change listener for change tracking.
      void _persistence_setPropertyChangeListener​(java.beans.PropertyChangeListener changeListener)
      INTERNAL: Set the property change listener for change tracking.
      void add​(int index, E element)  
      boolean add​(E element)  
      boolean addAll​(int index, java.util.Collection<? extends E> c)  
      boolean addAll​(java.util.Collection<? extends E> c)  
      void addElement​(E obj)  
      int capacity()  
      void clear()  
      void clearDeferredChanges()
      INTERNAL: clear any changes that have been deferred to instantiation.
      java.lang.Object clone()
      PUBLIC:
      boolean contains​(java.lang.Object element)
      PUBLIC:
      boolean containsAll​(java.util.Collection<?> c)  
      void copyInto​(java.lang.Object[] anArray)  
      E elementAt​(int index)  
      java.util.Enumeration<E> elements()  
      void ensureCapacity​(int minCapacity)  
      boolean equals​(java.lang.Object o)  
      E firstElement()  
      E get​(int index)  
      java.util.Collection getAddedElements()
      INTERNAL: Return the elements that have been added before instantiation.
      java.lang.Object getDelegateObject()
      INTERNAL: Return the real collection object.
      java.util.Collection getRemovedElements()
      INTERNAL: Return the elements that have been removed before instantiation.
      java.lang.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​(java.lang.Object elem)  
      int indexOf​(java.lang.Object elem, int index)  
      void insertElementAt​(E obj, int index)  
      boolean isEmpty()  
      boolean isInstantiated()
      PUBLIC: Return whether the contents have been read from the database.
      boolean isListOrderBrokenInDb()  
      java.util.Iterator<E> iterator()  
      E lastElement()  
      int lastIndexOf​(java.lang.Object elem)  
      int lastIndexOf​(java.lang.Object elem, int index)  
      java.util.ListIterator<E> listIterator()  
      java.util.ListIterator<E> listIterator​(int index)  
      E remove​(int index)  
      boolean remove​(java.lang.Object element)  
      boolean removeAll​(java.util.Collection<?> c)  
      void removeAllElements()  
      boolean removeElement​(java.lang.Object obj)  
      void removeElementAt​(int index)  
      boolean retainAll​(java.util.Collection<?> c)  
      E set​(int index, E element)  
      void setElementAt​(E obj, int index)  
      void setIsListOrderBrokenInDb​(boolean isBroken)  
      void setSize​(int newSize)  
      void setTrackedAttributeName​(java.lang.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 dB
      void setValueHolder​(ValueHolderInterface valueHolder)
      INTERNAL: Set the value holder.
      int size()  
      void sort​(java.util.Comparator<? super E> c)
      Sort content of this instance according to the order induced by provided comparator.
      java.util.List<E> subList​(int fromIndex, int toIndex)  
      java.lang.Object[] toArray()  
      <T> T[] toArray​(T[] a)  
      java.lang.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.util.Vector

        forEach, removeIf, replaceAll, spliterator
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • 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:
        java.lang.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:
        java.lang.IllegalArgumentException - if the specified initial capacity is negative
      • IndirectList

        public IndirectList​(java.util.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)
        Specified by:
        add in interface java.util.List<E>
        Overrides:
        add in class java.util.Vector<E>
        See Also:
        Vector.add(int, java.lang.Object)
      • add

        public boolean add​(E element)
        Specified by:
        add in interface java.util.Collection<E>
        Specified by:
        add in interface java.util.List<E>
        Overrides:
        add in class java.util.Vector<E>
        See Also:
        Vector.add(java.lang.Object)
      • addAll

        public boolean addAll​(int index,
                              java.util.Collection<? extends E> c)
        Specified by:
        addAll in interface java.util.List<E>
        Overrides:
        addAll in class java.util.Vector<E>
        See Also:
        Vector.addAll(int, java.util.Collection)
      • addAll

        public boolean addAll​(java.util.Collection<? extends E> c)
        Specified by:
        addAll in interface java.util.Collection<E>
        Specified by:
        addAll in interface java.util.List<E>
        Overrides:
        addAll in class java.util.Vector<E>
        See Also:
        Vector.addAll(java.util.Collection)
      • addElement

        public void addElement​(E obj)
        Overrides:
        addElement in class java.util.Vector<E>
        See Also:
        Vector.addElement(java.lang.Object)
      • capacity

        public int capacity()
        Overrides:
        capacity in class java.util.Vector<E>
        See Also:
        Vector.capacity()
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<E>
        Specified by:
        clear in interface java.util.List<E>
        Overrides:
        clear in class java.util.Vector<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:
        clearDeferredChanges in interface IndirectCollection
      • clone

        public java.lang.Object clone()
        PUBLIC:
        Overrides:
        clone in class java.util.Vector<E>
        See Also:
        This will result in a database query if necessary.
      • contains

        public boolean contains​(java.lang.Object element)
        PUBLIC:
        Specified by:
        contains in interface java.util.Collection<E>
        Specified by:
        contains in interface java.util.List<E>
        Overrides:
        contains in class java.util.Vector<E>
        See Also:
        Vector.contains(java.lang.Object)
      • containsAll

        public boolean containsAll​(java.util.Collection<?> c)
        Specified by:
        containsAll in interface java.util.Collection<E>
        Specified by:
        containsAll in interface java.util.List<E>
        Overrides:
        containsAll in class java.util.Vector<E>
        See Also:
        Vector.containsAll(java.util.Collection)
      • copyInto

        public void copyInto​(java.lang.Object[] anArray)
        Overrides:
        copyInto in class java.util.Vector<E>
        See Also:
        Vector.copyInto(java.lang.Object[])
      • elementAt

        public E elementAt​(int index)
        Overrides:
        elementAt in class java.util.Vector<E>
        See Also:
        Vector.elementAt(int)
      • elements

        public java.util.Enumeration<E> elements()
        Overrides:
        elements in class java.util.Vector<E>
        See Also:
        Vector.elements()
      • ensureCapacity

        public void ensureCapacity​(int minCapacity)
        Overrides:
        ensureCapacity in class java.util.Vector<E>
        See Also:
        Vector.ensureCapacity(int)
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Collection<E>
        Specified by:
        equals in interface java.util.List<E>
        Overrides:
        equals in class java.util.Vector<E>
        See Also:
        Vector.equals(java.lang.Object)
      • firstElement

        public E firstElement()
        Overrides:
        firstElement in class java.util.Vector<E>
        See Also:
        Vector.firstElement()
      • get

        public E get​(int index)
        Specified by:
        get in interface java.util.List<E>
        Overrides:
        get in class java.util.Vector<E>
        See Also:
        Vector.get(int)
      • getDelegateObject

        public java.lang.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 java.util.Collection<E>
        Specified by:
        hashCode in interface java.util.List<E>
        Overrides:
        hashCode in class java.util.Vector<E>
        See Also:
        Vector.hashCode()
      • indexOf

        public int indexOf​(java.lang.Object elem)
        Specified by:
        indexOf in interface java.util.List<E>
        Overrides:
        indexOf in class java.util.Vector<E>
        See Also:
        Vector.indexOf(java.lang.Object)
      • indexOf

        public int indexOf​(java.lang.Object elem,
                           int index)
        Overrides:
        indexOf in class java.util.Vector<E>
        See Also:
        Vector.indexOf(java.lang.Object, int)
      • insertElementAt

        public void insertElementAt​(E obj,
                                    int index)
        Overrides:
        insertElementAt in class java.util.Vector<E>
        See Also:
        Vector.insertElementAt(java.lang.Object, int)
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<E>
        Specified by:
        isEmpty in interface java.util.List<E>
        Overrides:
        isEmpty in class java.util.Vector<E>
        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 java.util.Iterator<E> iterator()
        Specified by:
        iterator in interface java.util.Collection<E>
        Specified by:
        iterator in interface java.lang.Iterable<E>
        Specified by:
        iterator in interface java.util.List<E>
        Overrides:
        iterator in class java.util.Vector<E>
        See Also:
        AbstractList.iterator()
      • lastElement

        public E lastElement()
        Overrides:
        lastElement in class java.util.Vector<E>
        See Also:
        Vector.lastElement()
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object elem)
        Specified by:
        lastIndexOf in interface java.util.List<E>
        Overrides:
        lastIndexOf in class java.util.Vector<E>
        See Also:
        Vector.lastIndexOf(java.lang.Object)
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object elem,
                               int index)
        Overrides:
        lastIndexOf in class java.util.Vector<E>
        See Also:
        Vector.lastIndexOf(java.lang.Object, int)
      • listIterator

        public java.util.ListIterator<E> listIterator()
        Specified by:
        listIterator in interface java.util.List<E>
        Overrides:
        listIterator in class java.util.Vector<E>
        See Also:
        AbstractList.listIterator()
      • listIterator

        public java.util.ListIterator<E> listIterator​(int index)
        Specified by:
        listIterator in interface java.util.List<E>
        Overrides:
        listIterator in class java.util.Vector<E>
        See Also:
        AbstractList.listIterator(int)
      • remove

        public E remove​(int index)
        Specified by:
        remove in interface java.util.List<E>
        Overrides:
        remove in class java.util.Vector<E>
        See Also:
        Vector.remove(int)
      • remove

        public boolean remove​(java.lang.Object element)
        Specified by:
        remove in interface java.util.Collection<E>
        Specified by:
        remove in interface java.util.List<E>
        Overrides:
        remove in class java.util.Vector<E>
        See Also:
        Vector.remove(java.lang.Object)
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<E>
        Specified by:
        removeAll in interface java.util.List<E>
        Overrides:
        removeAll in class java.util.Vector<E>
        See Also:
        Vector.removeAll(java.util.Collection)
      • removeAllElements

        public void removeAllElements()
        Overrides:
        removeAllElements in class java.util.Vector<E>
        See Also:
        Vector.removeAllElements()
      • removeElement

        public boolean removeElement​(java.lang.Object obj)
        Overrides:
        removeElement in class java.util.Vector<E>
        See Also:
        Vector.removeElement(java.lang.Object)
      • removeElementAt

        public void removeElementAt​(int index)
        Overrides:
        removeElementAt in class java.util.Vector<E>
        See Also:
        Vector.removeElementAt(int)
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<E>
        Specified by:
        retainAll in interface java.util.List<E>
        Overrides:
        retainAll in class java.util.Vector<E>
        See Also:
        Vector.retainAll(java.util.Collection)
      • set

        public E set​(int index,
                     E element)
        Specified by:
        set in interface java.util.List<E>
        Overrides:
        set in class java.util.Vector<E>
        See Also:
        Vector.set(int, java.lang.Object)
      • setElementAt

        public void setElementAt​(E obj,
                                 int index)
        Overrides:
        setElementAt in class java.util.Vector<E>
        See Also:
        Vector.setElementAt(java.lang.Object, int)
      • setSize

        public void setSize​(int newSize)
        Overrides:
        setSize in class java.util.Vector<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:
        setUseLazyInstantiation in interface IndirectCollection
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<E>
        Specified by:
        size in interface java.util.List<E>
        Overrides:
        size in class java.util.Vector<E>
        See Also:
        Vector.size()
      • sort

        public void sort​(java.util.Comparator<? super E> c)
        Sort content of this instance according to the order induced by provided comparator.
        Specified by:
        sort in interface java.util.List<E>
        Overrides:
        sort in class java.util.Vector<E>
        Parameters:
        c - The comparator to determine the order of the array. A null value indicates that the elements' natural ordering should be used.
        Since:
        2.6.0 with JDK 1.8
      • subList

        public java.util.List<E> subList​(int fromIndex,
                                         int toIndex)
        Specified by:
        subList in interface java.util.List<E>
        Overrides:
        subList in class java.util.Vector<E>
        See Also:
        Vector.subList(int, int)
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface java.util.List<E>
        Overrides:
        toArray in class java.util.Vector<E>
        See Also:
        Vector.toArray()
      • toArray

        public <T> T[] toArray​(T[] a)
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface java.util.List<E>
        Overrides:
        toArray in class java.util.Vector<E>
        See Also:
        Vector.toArray(java.lang.Object[])
      • toString

        public java.lang.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 java.util.Vector<E>
        See Also:
        Vector.toString()
      • trimToSize

        public void trimToSize()
        Overrides:
        trimToSize in class java.util.Vector<E>
        See Also:
        Vector.trimToSize()
      • _persistence_getPropertyChangeListener

        public java.beans.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​(java.beans.PropertyChangeListener changeListener)
        INTERNAL: Set the property change listener for change tracking.
        Specified by:
        _persistence_setPropertyChangeListener in interface ChangeTracker
      • setTrackedAttributeName

        public void setTrackedAttributeName​(java.lang.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 java.util.Collection getRemovedElements()
        INTERNAL: Return the elements that have been removed before instantiation.
        Specified by:
        getRemovedElements in interface IndirectCollection
      • getAddedElements

        public java.util.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)