Class ProgressReporterStack


  • class ProgressReporterStack
    extends java.lang.Object
    A convenience Stack for tracking ProgressReporters

    When a reporter is pushed onto the stack we remove any other occurrences of the same reporter so that there is at most one instance of a particular reporter in the stack at any time

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Object lockObject
      A dummy object used purely for implementing synchronized blocks
      private java.util.Stack reporterStack  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contains​(IProgressReporter reporter)
      Returns whether or not the given IProgressReporter is already in the stack
      int getActiveCount()
      Returns the number of reporters in the stack that are still active
      int getErrorCount()
      Returns the number of reporters in the stack that are in error state
      IProgressReporter getNextActiveReporter()
      Get the next active reporter.
      java.util.List getReporters​(boolean onlyActive)
      Returns a list of reporters; this list can safely be manipulated because it is not directly referencing the internal list
      boolean hasMultipleActive()
      A convenience method for quickly determining whether more than one reporter is still active.
      IProgressReporter peek()
      Returns the reporter at the top of the stack
      IProgressReporter pop()
      Remove and return the reporter at the top of the stack
      void push​(IProgressReporter reporter)
      Pushes the given reporter on top of the stack; additionally remove any other occurrence of the reporter.
      boolean remove​(IProgressReporter reporter)
      Remove the given ProgressReporter;
      int size()  
      void trim()
      Trim the list by removing all inactive reporters
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • reporterStack

        private java.util.Stack reporterStack
      • lockObject

        private java.lang.Object lockObject
        A dummy object used purely for implementing synchronized blocks
    • Constructor Detail

      • ProgressReporterStack

        ProgressReporterStack()
    • Method Detail

      • push

        public void push​(IProgressReporter reporter)
        Pushes the given reporter on top of the stack; additionally remove any other occurrence of the reporter.
        Parameters:
        reporter -
      • peek

        public IProgressReporter peek()
        Returns the reporter at the top of the stack
        Returns:
      • remove

        public boolean remove​(IProgressReporter reporter)
        Remove the given ProgressReporter;
        Returns:
        true if the given reporter is found; otherwise false
      • contains

        public boolean contains​(IProgressReporter reporter)
        Returns whether or not the given IProgressReporter is already in the stack
        Parameters:
        reporter -
        Returns:
      • pop

        public IProgressReporter pop()
        Remove and return the reporter at the top of the stack
        Returns:
      • trim

        public void trim()
        Trim the list by removing all inactive reporters
      • getReporters

        public java.util.List getReporters​(boolean onlyActive)
        Returns a list of reporters; this list can safely be manipulated because it is not directly referencing the internal list
        Parameters:
        onlyActive - true to return only reporters that are still active, false to return all reporters
        Returns:
        List
      • size

        public int size()
      • getActiveCount

        public int getActiveCount()
        Returns the number of reporters in the stack that are still active
        Returns:
      • getErrorCount

        public int getErrorCount()
        Returns the number of reporters in the stack that are in error state
        Returns:
      • hasMultipleActive

        public boolean hasMultipleActive()
        A convenience method for quickly determining whether more than one reporter is still active. This method can be much quicker than calling getActiveCount() and inspecting the returned value if the number of reporters is high since we may not have to go through the entire list before getting the result
        Returns:
        true if there are at least 2 active reporters; false otherwise
      • getNextActiveReporter

        public IProgressReporter getNextActiveReporter()
        Get the next active reporter.

        NOTE: this is different from calling peek() since the next active reporter may not be at the top of the stack

        Returns:
        ProgressReporter the next reporter on the stack that is still active; null if none are active or none are found