Package com.biglybt.ui.swt.progress
Class ProgressReporterStack
- java.lang.Object
-
- com.biglybt.ui.swt.progress.ProgressReporterStack
-
class ProgressReporterStack extends java.lang.Object
A convenience Stack for trackingProgressReporter
sWhen 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 blocksprivate java.util.Stack
reporterStack
-
Constructor Summary
Constructors Constructor Description ProgressReporterStack()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(IProgressReporter reporter)
Returns whether or not the givenIProgressReporter
is already in the stackint
getActiveCount()
Returns the number of reporters in the stack that are still activeint
getErrorCount()
Returns the number of reporters in the stack that are in error stateIProgressReporter
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 listboolean
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 stackIProgressReporter
pop()
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
-
-
-
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 givenProgressReporter
;- Returns:
true
if the given reporter is found; otherwisefalse
-
contains
public boolean contains(IProgressReporter reporter)
Returns whether or not the givenIProgressReporter
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 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
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
-
-