Class ThreadCursoredList

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List, java.util.RandomAccess

    public class ThreadCursoredList
    extends java.util.Vector
    Special List/Vector subclass that allows concurrent population of the contents while the list is in use. The list will allow iteration while it is still being populated to allow concurrent processing of the contents. Other API such as size that require to full contents know will wait until the list is notified as being complete. This is use to allow the rows and objects of a read-all query to be processed concurrently.
    Since:
    OracleAS 10g TopLink (10.0.3)
    Author:
    James Sutherland
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.RuntimeException exception
      Used to throw exception that occur from the concurrent population thread.
      protected boolean isComplete
      Store if the list is fully populated.
      • Fields inherited from class java.util.Vector

        capacityIncrement, elementCount, elementData
      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      ThreadCursoredList()
      Construct an empty list so that its internal data array has size 10 and its standard capacity increment is zero.
      ThreadCursoredList​(int initialCapacity)
      Construct an empty list with the specified initial capacity and with its capacity increment equal to zero.
      ThreadCursoredList​(int initialCapacity, int capacityIncrement)
      Construct an empty list with the specified initial capacity and capacity increment.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int index, java.lang.Object element)
      Add and notify any waiters that there are new elements.
      boolean add​(java.lang.Object element)
      Add and notify any waiters that there are new elements.
      boolean addAll​(int index, java.util.Collection collection)
      Add and notify any waiters that there are new elements.
      boolean addAll​(java.util.Collection collection)
      Add and notify any waiters that there are new elements.
      void addElement​(java.lang.Object object)
      Add and notify any waiters that there are new elements.
      void clear()
      First wait until complete.
      java.lang.Object clone()
      First wait until complete.
      boolean contains​(java.lang.Object element)
      If it does not contain the object must wait until it is complete.
      boolean containsAll​(java.util.Collection collection)
      If it does not contain the object must wait until it is complete.
      void copyInto​(java.lang.Object[] array)
      First wait until complete.
      java.lang.Object elementAt​(int index)
      If the index is beyond the size wait until complete.
      java.util.Enumeration elements()
      Allow concurrent streaming of the elements.
      boolean equals​(java.lang.Object object)
      First wait until complete.
      java.lang.Object firstElement()
      Wait until has an element or is complete.
      java.lang.Object get​(int index)
      Wait until has the element or is complete.
      java.lang.RuntimeException getException()
      Return any exception that was throw from concurrent population thread.
      protected int getSize()  
      boolean hasException()
      Return if any exception that was throw from concurrent population thread.
      int hashCode()
      First wait until complete.
      int indexOf​(java.lang.Object element)
      If does not contain the object wait until complete.
      int indexOf​(java.lang.Object element, int index)
      If does not contain the object wait until complete.
      void insertElementAt​(java.lang.Object element, int index)
      Add the element a notify any waiters that there are new elements.
      boolean isComplete()
      Return if the list is complete.
      boolean isEmpty()
      If empty wait until an element has been added or is complete.
      java.util.Iterator iterator()  
      java.lang.Object lastElement()
      First wait until complete.
      int lastIndexOf​(java.lang.Object element)
      First wait until complete.
      int lastIndexOf​(java.lang.Object element, int index)
      First wait until complete.
      java.util.ListIterator listIterator()  
      java.util.ListIterator listIterator​(int index)
      Iterate while waiting at end until complete.
      java.lang.Object remove​(int index)
      If index is missing wait until is there.
      boolean remove​(java.lang.Object element)
      If object is missing wait until complete.
      boolean removeAll​(java.util.Collection collection)
      First wait until complete.
      void removeAllElements()
      First wait until complete.
      boolean removeElement​(java.lang.Object element)
      If missing wait until complete.
      void removeElementAt​(int index)
      If index is missing wait until reasched or complete.
      boolean retainAll​(java.util.Collection collection)
      First wait until complete.
      java.lang.Object set​(int index, java.lang.Object element)
      If index is missing wait until reached or complete.
      void setElementAt​(java.lang.Object element, int index)
      If index is missing wait until reached or complete.
      void setIsComplete​(boolean isComplete)
      Set the list complete and notify any waiters.
      int size()
      First wait until complete.
      java.util.List subList​(int fromIndex, int toIndex)
      If index is missing wait until reached or complete.
      void throwException​(java.lang.RuntimeException exception)
      Record that the population thread hit an exception, that should be thrown to the processing thread on the next access.
      java.lang.Object[] toArray()
      First wait until complete.
      java.lang.Object[] toArray​(java.lang.Object[] array)
      First wait until complete.
      java.lang.String toString()
      First wait until complete.
      void trimToSize()
      First wait until complete.
      void waitUntilAdd()
      Wait until a new element has been added.
      void waitUntilComplete()
      Wait until the list has been fully populated.
      • Methods inherited from class java.util.Vector

        capacity, ensureCapacity, forEach, removeIf, removeRange, replaceAll, setSize, sort, spliterator
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, stream, toArray
    • Field Detail

      • isComplete

        protected boolean isComplete
        Store if the list is fully populated.
      • exception

        protected java.lang.RuntimeException exception
        Used to throw exception that occur from the concurrent population thread.
    • Constructor Detail

      • ThreadCursoredList

        public ThreadCursoredList()
        Construct an empty list so that its internal data array has size 10 and its standard capacity increment is zero.
      • ThreadCursoredList

        public ThreadCursoredList​(int initialCapacity)
        Construct an empty list with the specified initial capacity and with its capacity increment equal to zero.
      • ThreadCursoredList

        public ThreadCursoredList​(int initialCapacity,
                                  int capacityIncrement)
        Construct an empty list with the specified initial capacity and capacity increment.
    • Method Detail

      • add

        public void add​(int index,
                        java.lang.Object element)
        Add and notify any waiters that there are new elements.
        Specified by:
        add in interface java.util.List
        Overrides:
        add in class java.util.Vector
      • add

        public boolean add​(java.lang.Object element)
        Add and notify any waiters that there are new elements.
        Specified by:
        add in interface java.util.Collection
        Specified by:
        add in interface java.util.List
        Overrides:
        add in class java.util.Vector
      • addAll

        public boolean addAll​(int index,
                              java.util.Collection collection)
        Add and notify any waiters that there are new elements.
        Specified by:
        addAll in interface java.util.List
        Overrides:
        addAll in class java.util.Vector
      • addAll

        public boolean addAll​(java.util.Collection collection)
        Add and notify any waiters that there are new elements.
        Specified by:
        addAll in interface java.util.Collection
        Specified by:
        addAll in interface java.util.List
        Overrides:
        addAll in class java.util.Vector
      • addElement

        public void addElement​(java.lang.Object object)
        Add and notify any waiters that there are new elements.
        Overrides:
        addElement in class java.util.Vector
      • clear

        public void clear()
        First wait until complete.
        Specified by:
        clear in interface java.util.Collection
        Specified by:
        clear in interface java.util.List
        Overrides:
        clear in class java.util.Vector
      • clone

        public java.lang.Object clone()
        First wait until complete.
        Overrides:
        clone in class java.util.Vector
      • hasException

        public boolean hasException()
        Return if any exception that was throw from concurrent population thread.
      • getException

        public java.lang.RuntimeException getException()
        Return any exception that was throw from concurrent population thread.
      • throwException

        public void throwException​(java.lang.RuntimeException exception)
        Record that the population thread hit an exception, that should be thrown to the processing thread on the next access. This also records the list and complete.
      • isComplete

        public boolean isComplete()
        Return if the list is complete. If an exception was thrown during the concurrent population throw the exception.
      • setIsComplete

        public void setIsComplete​(boolean isComplete)
        Set the list complete and notify any waiters.
      • waitUntilComplete

        public void waitUntilComplete()
        Wait until the list has been fully populated.
      • waitUntilAdd

        public void waitUntilAdd()
        Wait until a new element has been added.
      • contains

        public boolean contains​(java.lang.Object element)
        If it does not contain the object must wait until it is complete.
        Specified by:
        contains in interface java.util.Collection
        Specified by:
        contains in interface java.util.List
        Overrides:
        contains in class java.util.Vector
      • containsAll

        public boolean containsAll​(java.util.Collection collection)
        If it does not contain the object must wait until it is complete.
        Specified by:
        containsAll in interface java.util.Collection
        Specified by:
        containsAll in interface java.util.List
        Overrides:
        containsAll in class java.util.Vector
      • copyInto

        public void copyInto​(java.lang.Object[] array)
        First wait until complete.
        Overrides:
        copyInto in class java.util.Vector
      • elementAt

        public java.lang.Object elementAt​(int index)
        If the index is beyond the size wait until complete.
        Overrides:
        elementAt in class java.util.Vector
      • getSize

        protected int getSize()
      • elements

        public java.util.Enumeration elements()
        Allow concurrent streaming of the elements.
        Overrides:
        elements in class java.util.Vector
      • equals

        public boolean equals​(java.lang.Object object)
        First wait until complete.
        Specified by:
        equals in interface java.util.Collection
        Specified by:
        equals in interface java.util.List
        Overrides:
        equals in class java.util.Vector
      • firstElement

        public java.lang.Object firstElement()
        Wait until has an element or is complete.
        Overrides:
        firstElement in class java.util.Vector
      • get

        public java.lang.Object get​(int index)
        Wait until has the element or is complete.
        Specified by:
        get in interface java.util.List
        Overrides:
        get in class java.util.Vector
      • hashCode

        public int hashCode()
        First wait until complete.
        Specified by:
        hashCode in interface java.util.Collection
        Specified by:
        hashCode in interface java.util.List
        Overrides:
        hashCode in class java.util.Vector
      • indexOf

        public int indexOf​(java.lang.Object element)
        If does not contain the object wait until complete.
        Specified by:
        indexOf in interface java.util.List
        Overrides:
        indexOf in class java.util.Vector
      • indexOf

        public int indexOf​(java.lang.Object element,
                           int index)
        If does not contain the object wait until complete.
        Overrides:
        indexOf in class java.util.Vector
      • insertElementAt

        public void insertElementAt​(java.lang.Object element,
                                    int index)
        Add the element a notify any waiters that there are new elements.
        Overrides:
        insertElementAt in class java.util.Vector
      • isEmpty

        public boolean isEmpty()
        If empty wait until an element has been added or is complete.
        Specified by:
        isEmpty in interface java.util.Collection
        Specified by:
        isEmpty in interface java.util.List
        Overrides:
        isEmpty in class java.util.Vector
      • iterator

        public java.util.Iterator iterator()
        Specified by:
        iterator in interface java.util.Collection
        Specified by:
        iterator in interface java.lang.Iterable
        Specified by:
        iterator in interface java.util.List
        Overrides:
        iterator in class java.util.Vector
      • lastElement

        public java.lang.Object lastElement()
        First wait until complete.
        Overrides:
        lastElement in class java.util.Vector
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object element)
        First wait until complete.
        Specified by:
        lastIndexOf in interface java.util.List
        Overrides:
        lastIndexOf in class java.util.Vector
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object element,
                               int index)
        First wait until complete.
        Overrides:
        lastIndexOf in class java.util.Vector
      • listIterator

        public java.util.ListIterator listIterator()
        Specified by:
        listIterator in interface java.util.List
        Overrides:
        listIterator in class java.util.Vector
      • listIterator

        public java.util.ListIterator listIterator​(int index)
        Iterate while waiting at end until complete.
        Specified by:
        listIterator in interface java.util.List
        Overrides:
        listIterator in class java.util.Vector
      • remove

        public java.lang.Object remove​(int index)
        If index is missing wait until is there.
        Specified by:
        remove in interface java.util.List
        Overrides:
        remove in class java.util.Vector
      • remove

        public boolean remove​(java.lang.Object element)
        If object is missing wait until complete.
        Specified by:
        remove in interface java.util.Collection
        Specified by:
        remove in interface java.util.List
        Overrides:
        remove in class java.util.Vector
      • removeAll

        public boolean removeAll​(java.util.Collection collection)
        First wait until complete.
        Specified by:
        removeAll in interface java.util.Collection
        Specified by:
        removeAll in interface java.util.List
        Overrides:
        removeAll in class java.util.Vector
      • removeAllElements

        public void removeAllElements()
        First wait until complete.
        Overrides:
        removeAllElements in class java.util.Vector
      • removeElement

        public boolean removeElement​(java.lang.Object element)
        If missing wait until complete.
        Overrides:
        removeElement in class java.util.Vector
      • removeElementAt

        public void removeElementAt​(int index)
        If index is missing wait until reasched or complete.
        Overrides:
        removeElementAt in class java.util.Vector
      • retainAll

        public boolean retainAll​(java.util.Collection collection)
        First wait until complete.
        Specified by:
        retainAll in interface java.util.Collection
        Specified by:
        retainAll in interface java.util.List
        Overrides:
        retainAll in class java.util.Vector
      • set

        public java.lang.Object set​(int index,
                                    java.lang.Object element)
        If index is missing wait until reached or complete.
        Specified by:
        set in interface java.util.List
        Overrides:
        set in class java.util.Vector
      • setElementAt

        public void setElementAt​(java.lang.Object element,
                                 int index)
        If index is missing wait until reached or complete.
        Overrides:
        setElementAt in class java.util.Vector
      • size

        public int size()
        First wait until complete.
        Specified by:
        size in interface java.util.Collection
        Specified by:
        size in interface java.util.List
        Overrides:
        size in class java.util.Vector
      • subList

        public java.util.List subList​(int fromIndex,
                                      int toIndex)
        If index is missing wait until reached or complete.
        Specified by:
        subList in interface java.util.List
        Overrides:
        subList in class java.util.Vector
      • toArray

        public java.lang.Object[] toArray()
        First wait until complete.
        Specified by:
        toArray in interface java.util.Collection
        Specified by:
        toArray in interface java.util.List
        Overrides:
        toArray in class java.util.Vector
      • toArray

        public java.lang.Object[] toArray​(java.lang.Object[] array)
        First wait until complete.
        Specified by:
        toArray in interface java.util.Collection
        Specified by:
        toArray in interface java.util.List
        Overrides:
        toArray in class java.util.Vector
      • toString

        public java.lang.String toString()
        First wait until complete.
        Overrides:
        toString in class java.util.Vector
      • trimToSize

        public void trimToSize()
        First wait until complete.
        Overrides:
        trimToSize in class java.util.Vector