Class ProgressReporterStack
java.lang.Object
com.biglybt.ui.swt.progress.ProgressReporterStack
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(IProgressReporter reporter) Returns whether or not the givenIProgressReporteris already in the stackintReturns the number of reporters in the stack that are still activeintReturns the number of reporters in the stack that are in error stateGet the next active reporter.getReporters(boolean onlyActive) Returns a list of reporters; this list can safely be manipulated because it is not directly referencing the internal listbooleanA convenience method for quickly determining whether more than one reporter is still active.peek()Returns the reporter at the top of the stackpop()Remove and return the reporter at the top of the stackvoidpush(IProgressReporter reporter) Pushes the given reporter on top of the stack; additionally remove any other occurrence of the reporter.booleanremove(IProgressReporter reporter) Remove the givenProgressReporter;intsize()voidtrim()Trim the list by removing all inactive reporters
-
Field Details
-
reporterStack
-
lockObject
A dummy object used purely for implementing synchronized blocks
-
-
Constructor Details
-
ProgressReporterStack
ProgressReporterStack()
-
-
Method Details
-
push
Pushes the given reporter on top of the stack; additionally remove any other occurrence of the reporter.- Parameters:
reporter-
-
peek
-
remove
Remove the givenProgressReporter;- Returns:
trueif the given reporter is found; otherwisefalse
-
contains
Returns whether or not the givenIProgressReporteris already in the stack- Parameters:
reporter-- Returns:
-
pop
-
trim
public void trim()Trim the list by removing all inactive reporters -
getReporters
Returns a list of reporters; this list can safely be manipulated because it is not directly referencing the internal list- Parameters:
onlyActive-trueto return only reporters that are still active,falseto 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 callinggetActiveCount()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:
trueif there are at least 2 active reporters;falseotherwise
-
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;
nullif none are active or none are found
-