org.rhq.core.util.progresswatch
Class ProgressWatcher

java.lang.Object
  extended by org.rhq.core.util.progresswatch.ProgressWatcher

public class ProgressWatcher
extends Object

Simple class who's goal is to: 1) Total up the amount of work to be done 2) Track the amount of work that is actually done 3) Report the % of the work completed The amount of work is arbitrary and stored in simple integer format. Percent complete is calculated based on the finished work divided by the work remaining. Possible additions to the future could add ability to track timing (current, remaining estimate).

Author:
mmccune

Constructor Summary
ProgressWatcher()
           
 
Method Summary
 void addWork(int workToAdd)
          Add a unit of work to be completed.
 void finishWork(int workToRemove)
          Indicate that a # of work units has been completed.
 int getPercentComplete()
          Get the percentage complete of the total work specified.
 void resetToZero()
          Reset the ProgressWatcher to zero.
 void setTotalWork(int totalWorkIn)
          Set the total amount of work to be completed.
 void start()
          Start watching the progress of a given amount of work.
 void stop()
          Indicate this ProgressWatcher is finished watching.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProgressWatcher

public ProgressWatcher()
Method Detail

start

public void start()
Start watching the progress of a given amount of work.


getPercentComplete

public int getPercentComplete()
                       throws IllegalStateException
Get the percentage complete of the total work specified.

Returns:
float 0-100% of the amount of work copleted. integer so no decimal points.
Throws:
IllegalStateException - if this ProgressWatcher has not been started yet.

setTotalWork

public void setTotalWork(int totalWorkIn)
Set the total amount of work to be completed.

Parameters:
totalWorkIn - to set.

addWork

public void addWork(int workToAdd)
Add a unit of work to be completed.

Parameters:
workToAdd -

finishWork

public void finishWork(int workToRemove)
Indicate that a # of work units has been completed.

Parameters:
workToRemove -

stop

public void stop()
Indicate this ProgressWatcher is finished watching.


resetToZero

public void resetToZero()
Reset the ProgressWatcher to zero.



Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.