Package com.atlassian.confluence.util
Class EstimatedProgressMeter
- java.lang.Object
-
- com.atlassian.confluence.util.EstimatedProgressMeter
-
public class EstimatedProgressMeter extends Object
A progress meter to be used in situations where the total cannot be determined efficiently or conveniently up front. Instead, this progress meter will take an estimate for the total and never increment the progress past 99%, unless specifically told to.
-
-
Constructor Summary
Constructors Constructor Description EstimatedProgressMeter(int estimatedTotal)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
complete()
Sets the percent complete of this progress meter to 100%, regardless of where the progress is currently up to.int
getCount()
int
getEstimatedTotal()
int
getPercentageComplete()
int
incrementCount()
Increases the current count or progress by one.void
setEstimatedTotal(int estimatedTotal)
Sets the estimatedTotal.
-
-
-
Constructor Detail
-
EstimatedProgressMeter
public EstimatedProgressMeter(int estimatedTotal)
- Parameters:
estimatedTotal
- the estimated total- Throws:
IllegalArgumentException
- if estimatedTotal is less than zero.
-
-
Method Detail
-
incrementCount
public int incrementCount()
Increases the current count or progress by one. Returns the current count after the update.
-
getPercentageComplete
public int getPercentageComplete()
- Returns:
- the current percentage complete
-
complete
public void complete()
Sets the percent complete of this progress meter to 100%, regardless of where the progress is currently up to.
-
getCount
public int getCount()
- Returns:
- the current count. It is possible for the count to exceed the estimated total.
-
getEstimatedTotal
public int getEstimatedTotal()
- Returns:
- the estimated total
-
setEstimatedTotal
public void setEstimatedTotal(int estimatedTotal)
Sets the estimatedTotal. This method is useful when the estimatedTotal is not available at construction time. Note: this method can only be used when the count has not been incremented.- Parameters:
estimatedTotal
- the estimated total- Throws:
IllegalArgumentException
- if estimatedTotal is less than zero.IllegalStateException
- if this is called after progress has started (that is,incrementCount()
has been called at least once)
-
-