Class JobList<T extends Job>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean m_Finished
      indicates whether all jobs have finished.
      protected List<T> m_Jobs
      the jobs.
      protected HashSet<JobListCompleteListener> m_Listeners
      the listeners listening for all jobs to be completed.
      protected boolean m_Locked
      indicates whether a queue has been added to a JobRunner and can no longer be modified.
    • Constructor Summary

      Constructors 
      Constructor Description
      JobList()
      Initializes the queue.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int index, T element)
      Inserts the specified element at the specified position in this list.
      boolean add​(T e)
      Ensures that this collection contains the specified element.
      boolean addAll​(int index, Collection<? extends T> c)
      Inserts all of the elements in the specified collection into this list at the specified position.
      boolean addAll​(Collection<? extends T> c)
      Adds all the elements in the specified collection to this collection.
      void addJobListCompleteListener​(JobListCompleteListener l)
      Adds the listener to the internal list.
      void cleanUp()
      Cleans up data structures, frees up memory.
      void clear()
      Removes all the elements from this collection.
      boolean contains​(Object o)
      Returns true if this collection contains the specified element.
      boolean containsAll​(Collection<?> c)
      Returns true if this collection contains all of the elements in the specified collection.
      boolean equals​(Object obj)
      Compares the specified object with this collection for equality.
      T get​(int index)
      Returns the element at the specified position in this list.
      int hashCode()
      Returns the hash code value for this collection (just the hash code of the underlying job vector).
      int indexOf​(Object o)
      Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.
      boolean isEmpty()
      Returns true if this collection contains no elements.
      boolean isFinished()
      Returns whether all jobs in the list have been finished.
      boolean isLocked()
      Returns whether the queue has been locked due to being processed in a JobRunner or not.
      Iterator<T> iterator()
      Returns an iterator over the elements in this collection.
      void jobCompleted​(JobCompleteEvent e)
      Post process job.
      int lastIndexOf​(Object o)
      Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.
      ListIterator<T> listIterator()
      Returns a list iterator of the elements in this list (in proper sequence).
      ListIterator<T> listIterator​(int index)
      Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.
      protected void notifyJobListCompleteListeners​(JobListCompleteEvent e)
      Notifies all JobListComplete listeners.
      T remove​(int index)
      Removes the element at the specified position in this list.
      boolean remove​(Object o)
      Removes a single instance of the specified element from this collection, if it is present.
      boolean removeAll​(Collection<?> c)
      Removes all this collection's elements that are also contained in the specified collection.
      void removeJobListCompleteListener​(JobListCompleteListener l)
      Removes the listener from the internal list.
      boolean retainAll​(Collection<?> c)
      Retains only the elements in this collection that are contained in the specified collection.
      T set​(int index, T element)
      Replaces the element at the specified position in this list with the specified element.
      int size()
      Returns the number of elements in this collection.
      List<T> subList​(int fromIndex, int toIndex)
      Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
      Object[] toArray()
      Returns an array containing all of the elements in this collection.
      <T> T[] toArray​(T[] a)
      Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
    • Field Detail

      • m_Jobs

        protected List<T extends Job> m_Jobs
        the jobs.
      • m_Locked

        protected boolean m_Locked
        indicates whether a queue has been added to a JobRunner and can no longer be modified.
      • m_Finished

        protected boolean m_Finished
        indicates whether all jobs have finished.
    • Constructor Detail

      • JobList

        public JobList()
        Initializes the queue.
    • Method Detail

      • add

        public boolean add​(T e)
        Ensures that this collection contains the specified element.
        Specified by:
        add in interface Collection<T extends Job>
        Specified by:
        add in interface List<T extends Job>
        Parameters:
        e - the job to add
        Returns:
        true if this collection changed as a result of the call
      • addAll

        public boolean addAll​(Collection<? extends T> c)
        Adds all the elements in the specified collection to this collection.
        Specified by:
        addAll in interface Collection<T extends Job>
        Specified by:
        addAll in interface List<T extends Job>
        Parameters:
        c - the collection to add
        Returns:
        true if this collection changed as a result of the call
      • add

        public void add​(int index,
                        T element)
        Inserts the specified element at the specified position in this list.
        Specified by:
        add in interface List<T extends Job>
        Parameters:
        index - index at which the specified element is to be inserted
        element - the element to add
      • addAll

        public boolean addAll​(int index,
                              Collection<? extends T> c)
        Inserts all of the elements in the specified collection into this list at the specified position.
        Specified by:
        addAll in interface List<T extends Job>
        Parameters:
        index - index at which to insert first element from the specified collection.
        c - elements to be inserted into this list.
        Returns:
        true if the collection changed
      • clear

        public void clear()
        Removes all the elements from this collection.
        Specified by:
        clear in interface Collection<T extends Job>
        Specified by:
        clear in interface List<T extends Job>
      • contains

        public boolean contains​(Object o)
        Returns true if this collection contains the specified element.
        Specified by:
        contains in interface Collection<T extends Job>
        Specified by:
        contains in interface List<T extends Job>
        Parameters:
        o - the job to look for
        Returns:
        true if the job is in the list
      • containsAll

        public boolean containsAll​(Collection<?> c)
        Returns true if this collection contains all of the elements in the specified collection.
        Specified by:
        containsAll in interface Collection<T extends Job>
        Specified by:
        containsAll in interface List<T extends Job>
        Parameters:
        c - the collection to check against
        Returns:
        true if all elements are also in this collection
      • equals

        public boolean equals​(Object obj)
        Compares the specified object with this collection for equality.
        Specified by:
        equals in interface Collection<T extends Job>
        Specified by:
        equals in interface List<T extends Job>
        Overrides:
        equals in class Object
        Parameters:
        obj - the object to compare with
        Returns:
        true if the contained jobs, listeners and lock status are the same, false otherwise
      • hashCode

        public int hashCode()
        Returns the hash code value for this collection (just the hash code of the underlying job vector).
        Specified by:
        hashCode in interface Collection<T extends Job>
        Specified by:
        hashCode in interface List<T extends Job>
        Overrides:
        hashCode in class Object
        Returns:
        the hash code
      • get

        public T get​(int index)
        Returns the element at the specified position in this list.
        Specified by:
        get in interface List<T extends Job>
        Parameters:
        index - the index of the job
        Returns:
        the job at the specified position
      • indexOf

        public int indexOf​(Object o)
        Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.
        Specified by:
        indexOf in interface List<T extends Job>
        Parameters:
        o - the job to get the index for
        Returns:
        the index or -1 if not found
      • isEmpty

        public boolean isEmpty()
        Returns true if this collection contains no elements.
        Specified by:
        isEmpty in interface Collection<T extends Job>
        Specified by:
        isEmpty in interface List<T extends Job>
        Returns:
        true if no jobs present
      • lastIndexOf

        public int lastIndexOf​(Object o)
        Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.
        Specified by:
        lastIndexOf in interface List<T extends Job>
        Parameters:
        o - the job to look for
        Returns:
        the index or -1 if not found
      • listIterator

        public ListIterator<T> listIterator()
        Returns a list iterator of the elements in this list (in proper sequence).
        Specified by:
        listIterator in interface List<T extends Job>
        Returns:
        the iterator
      • listIterator

        public ListIterator<T> listIterator​(int index)
        Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.
        Specified by:
        listIterator in interface List<T extends Job>
        Parameters:
        index - the index to start the iterator
        Returns:
        the iterator
      • remove

        public boolean remove​(Object o)
        Removes a single instance of the specified element from this collection, if it is present.
        Specified by:
        remove in interface Collection<T extends Job>
        Specified by:
        remove in interface List<T extends Job>
        Parameters:
        o - the object to remove
        Returns:
        true if the collection changed
      • remove

        public T remove​(int index)
        Removes the element at the specified position in this list.
        Specified by:
        remove in interface List<T extends Job>
        Parameters:
        index - the index of the job to remove
        Returns:
        the job or null if locked
      • removeAll

        public boolean removeAll​(Collection<?> c)
        Removes all this collection's elements that are also contained in the specified collection.
        Specified by:
        removeAll in interface Collection<T extends Job>
        Specified by:
        removeAll in interface List<T extends Job>
        Parameters:
        c - the collection's objects to remove
        Returns:
        true if the collection changed
      • retainAll

        public boolean retainAll​(Collection<?> c)
        Retains only the elements in this collection that are contained in the specified collection.
        Specified by:
        retainAll in interface Collection<T extends Job>
        Specified by:
        retainAll in interface List<T extends Job>
        Parameters:
        c - the collection's objects to retain
        Returns:
        true if the collection changed
      • set

        public T set​(int index,
                     T element)
        Replaces the element at the specified position in this list with the specified element.
        Specified by:
        set in interface List<T extends Job>
        Parameters:
        index - the index of the job to replace
        element - the replacement
        Returns:
        the job or null if locked
      • subList

        public List<T> subList​(int fromIndex,
                               int toIndex)
        Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
        Specified by:
        subList in interface List<T extends Job>
        Parameters:
        fromIndex - the start index
        toIndex - the end index (exclusive)
        Returns:
        the sublist (of type JobList)
      • size

        public int size()
        Returns the number of elements in this collection.
        Specified by:
        size in interface Collection<T extends Job>
        Specified by:
        size in interface List<T extends Job>
        Returns:
        the number of jobs
      • toArray

        public Object[] toArray()
        Returns an array containing all of the elements in this collection.
        Specified by:
        toArray in interface Collection<T extends Job>
        Specified by:
        toArray in interface List<T extends Job>
        Returns:
        the array of jobs
      • toArray

        public <T> T[] toArray​(T[] a)
        Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
        Specified by:
        toArray in interface Collection<T extends Job>
        Specified by:
        toArray in interface List<T extends Job>
        Type Parameters:
        T - the type of array
        Parameters:
        a - the array to fill
        Returns:
        the array of jobs
      • isLocked

        public boolean isLocked()
        Returns whether the queue has been locked due to being processed in a JobRunner or not.
        Returns:
        true if queue is being processed and therefore locked
      • addJobListCompleteListener

        public void addJobListCompleteListener​(JobListCompleteListener l)
        Adds the listener to the internal list.
        Parameters:
        l - the listener to add
      • removeJobListCompleteListener

        public void removeJobListCompleteListener​(JobListCompleteListener l)
        Removes the listener from the internal list.
        Parameters:
        l - the listener to remove
      • notifyJobListCompleteListeners

        protected void notifyJobListCompleteListeners​(JobListCompleteEvent e)
        Notifies all JobListComplete listeners.
        Parameters:
        e - the event to send
      • isFinished

        public boolean isFinished()
        Returns whether all jobs in the list have been finished.
        Returns:
        true if all jobs have finished
      • jobCompleted

        public void jobCompleted​(JobCompleteEvent e)
        Post process job. If all jobs got completed, the list of JobListCompleteListener will be notified.
        Specified by:
        jobCompleted in interface JobCompleteListener
        Parameters:
        e - the event
      • cleanUp

        public void cleanUp()
        Cleans up data structures, frees up memory.
        Specified by:
        cleanUp in interface CleanUpHandler