com.atlassian.confluence.util
Class EstimatedProgressMeter

java.lang.Object
  extended by com.atlassian.confluence.util.EstimatedProgressMeter

public class EstimatedProgressMeter
extends java.lang.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
EstimatedProgressMeter(int estimatedTotal)
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EstimatedProgressMeter

public EstimatedProgressMeter(int estimatedTotal)
Parameters:
estimatedTotal - the estimated total
Throws:
java.lang.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:
java.lang.IllegalArgumentException - if estimatedTotal is less than zero.
java.lang.IllegalStateException - if this is called after progress has started (that is, incrementCount() has been called at least once)


Copyright © 2003-2014 Atlassian. All Rights Reserved.