org.crosswire.common.progress
Interface Progress

All Known Implementing Classes:
Job

public interface Progress

A Generic way of keeping track of Threads and monitoring their progress.

Author:
DM Smith
See Also:
for license details.
The copyright to this program is held by it's authors.

Field Summary
static int UNKNOWN
          Indicate that the total amount of work is unknown.
 
Method Summary
 void beginJob(String sectionName)
          Start the task measured from 0 to 100.
 void beginJob(String sectionName, int totalWork)
          Start the task reporting progress toward total work.
 void beginJob(String sectionName, URI predictURI)
          Start the task using timings from a prior run as a guess for the current run.
 void cancel()
          Cancel the job (if possible).
 void done()
          Called to indicate that we are finished doing work.
 String getJobName()
           
 ProgressMode getProgressMode()
          Gets the current ProgressMode.
 String getSectionName()
          The section name is used in reporting progress.
 int getTotalWork()
           
 int getWork()
          Return the computed percentage as an integer, typically from 0 to 100.
 int getWorkDone()
           
 void incrementWorkDone(int step)
          Indicate progress toward the whole.
 boolean isCancelable()
          Might the job be cancelable?
 boolean isFinished()
          Used to determine whether job is done or canceled or reached totalWork.
 void setCancelable(boolean newCancelable)
          Indicates whether the job is cancelable or not.
 void setSectionName(String name)
          We have moved onto another section so update the section title.
 void setTotalWork(int totalWork)
          Set the total amount of work to be done.
 void setWork(int progress)
          Indicate progress toward 100%.
 void setWorkDone(int progress)
          Indicate progress toward the whole.
 

Field Detail

UNKNOWN

static final int UNKNOWN
Indicate that the total amount of work is unknown.

See Also:
Constant Field Values
Method Detail

beginJob

void beginJob(String sectionName)
Start the task measured from 0 to 100. It is the caller's responsibility to compute percentages.

Parameters:
sectionName - the initial name of the job.

beginJob

void beginJob(String sectionName,
              int totalWork)
Start the task reporting progress toward total work. Percentages will be computed on behalf of the caller.

Parameters:
sectionName - the initial name of the job.
totalWork - the total amount that is to be worked.

beginJob

void beginJob(String sectionName,
              URI predictURI)
Start the task using timings from a prior run as a guess for the current run. If there are no predictions then progress is faked.

Parameters:
sectionName - the initial name of the job.
predictURI - the URI of a properties file from which past behavior is read and the results of the current run are stored.

getJobName

String getJobName()
Returns:
the job name

getProgressMode

ProgressMode getProgressMode()
Gets the current ProgressMode. Builders of progress bars should use an indeterminant progress bar for ProgressMode.UNKNOWN and ProgressMode.PREDICTIVE.

Returns:
the current progress mode.

getTotalWork

int getTotalWork()
Returns:
the total amount of work to be done, or UNKNOWN if it not known

setTotalWork

void setTotalWork(int totalWork)
Set the total amount of work to be done. This can be called any time. It is the responsibility of the caller for it to be meaningful. It is ignored when the task is started with a prediction properties file.

Parameters:
totalWork - the total amount of work to be done in units that make sense to the caller.

getWork

int getWork()
Return the computed percentage as an integer, typically from 0 to 100.

Returns:
the amount of work done as a percentage

setWork

void setWork(int progress)
Indicate progress toward 100%. Note this is just a call to setWorkDone.

Parameters:
progress - a part of the whole.

getWorkDone

int getWorkDone()
Returns:
the amount of work done so far as reported by the caller

setWorkDone

void setWorkDone(int progress)
Indicate progress toward the whole. It is up to the caller to give a value that makes sense. When using 100 as a basis, it is typically a number from 0 to 100. In every case, it is a number from 0 to totalWork.

Parameters:
progress - a part of the whole.

incrementWorkDone

void incrementWorkDone(int step)
Indicate progress toward the whole. It is up to the caller to give a value that makes sense.

Parameters:
step - the amount of work done since the last call.

getSectionName

String getSectionName()
The section name is used in reporting progress.

Returns:
the current section name

setSectionName

void setSectionName(String name)
We have moved onto another section so update the section title. The section name is used in reporting progress.

Parameters:
name - the name of the section

done

void done()
Called to indicate that we are finished doing work.


cancel

void cancel()
Cancel the job (if possible). If isCancelable() is false, then the job will be canceled if cancelable becomes true. There is no guarantee that


isFinished

boolean isFinished()
Used to determine whether job is done or canceled or reached totalWork.


isCancelable

boolean isCancelable()
Might the job be cancelable?


setCancelable

void setCancelable(boolean newCancelable)
Indicates whether the job is cancelable or not.

Parameters:
newCancelable - The state to set.

Copyright ? 2003-2011