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 Details

    • EstimatedProgressMeter

      public EstimatedProgressMeter(int estimatedTotal)
      Parameters:
      estimatedTotal - the estimated total
      Throws:
      IllegalArgumentException - if estimatedTotal is less than zero.
  • Method Details

    • 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)