Package com.biglybt.ui.swt.progress
Class ProgressReporterStack
java.lang.Object
com.biglybt.ui.swt.progress.ProgressReporterStack
A convenience Stack for tracking
ProgressReporter
s
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 TypeMethodDescriptionboolean
contains
(IProgressReporter reporter) Returns whether or not the givenIProgressReporter
is already in the stackint
Returns the number of reporters in the stack that are still activeint
Returns 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 listboolean
A 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 stackvoid
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 givenProgressReporter
;int
size()
void
trim()
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
Returns the reporter at the top of the stack- Returns:
-
remove
Remove the givenProgressReporter
;- Returns:
true
if the given reporter is found; otherwisefalse
-
contains
Returns whether or not the givenIProgressReporter
is already in the stack- Parameters:
reporter
-- Returns:
-
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
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 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:
true
if there are at least 2 active reporters;false
otherwise
-
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
-