|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.crosswire.common.progress.Job
public final class Job
A Generic method of keeping track of Threads and monitoring their progress.
for license details.
The copyright to this program is held by it's authors.
Nested Class Summary | |
---|---|
(package private) class |
Job.PredictTask
So we can fake progress for Jobs that don't tell us how they are doing |
Field Summary | |
---|---|
private Map |
current
The timings as measured this time |
private boolean |
finished
Have we just finished? |
private int |
guessedpc
The guessed progress |
private boolean |
interruptable
Does this job allow interruptions? |
private String |
jobdesc
A short descriptive phrase |
private List |
listeners
People that want to know about "interruptable" changes |
private static Logger |
log
The log stream |
private int |
percentend
The percentage at the end of this section |
private Map |
predicted
The timings loaded from where they were saved after the last run |
private int |
predictedlen
How long to we predict this job is going to last? |
private URL |
predicturl
The URL to which we load and save timings |
private int |
reportedpc
The officially reported progress |
private long |
sectionend
When do we expect this section to end |
private long |
sectionstart
When did this section start? |
private long |
start
When did this job start? |
private String |
statedesc
Description of what we are doing |
private Timer |
updater
The timer that lets us post fake progress events |
private Thread |
work
Optional thread to monitor progress |
Constructor Summary | |
---|---|
protected |
Job(String description,
URL predicturl,
Thread work,
boolean fakeupdates)
Create a new Job. |
Method Summary | |
---|---|
void |
addWorkListener(WorkListener li)
Add a listener to the list |
void |
done()
Called to indicate that we are finished with the dialog |
protected void |
fireStateChanged()
|
private int |
getAgeFromMap(Map props,
String message)
Predict a percentage complete |
String |
getJobDescription()
Get a short descriptive phrase |
int |
getPercent()
Get estimated the percent progress, extrapolating between sections |
int |
getReportedPercent()
Get the last reported total percent progress |
String |
getStateDescription()
Accessor for the job description |
protected void |
guessProgress()
Get estimated the percent progress, extrapolating between sections |
void |
ignoreTimings()
Typically called from in a catch block, this ensures that we don't save the timing file because we have a messed up run. |
void |
interrupt()
Interrupt the job (if possible) |
boolean |
isFinished()
Shortcut to check if percent == 100 |
boolean |
isInterruptable()
Might the job be interruptable? |
private void |
loadPredictions()
Load the predictive timings if any |
private void |
predictSection(String message)
Predict a percentage complete |
void |
removeWorkListener(WorkListener li)
Remote a listener from the list |
private void |
savePredictions()
Save the known timings to a properties file. |
void |
setInterruptable(boolean newInterruptable)
|
void |
setProgress(int percent,
String statedesc)
We have moved onto another section so update the percentage complete and the section title. |
void |
setProgress(String statedesc)
We have moved onto another section so update the section title and if available used previous runs to predict timings. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private boolean interruptable
private boolean finished
private int reportedpc
private int guessedpc
private long sectionend
private long sectionstart
private int percentend
private String jobdesc
private Thread work
private String statedesc
private long start
private Map current
private Map predicted
private int predictedlen
private URL predicturl
private Timer updater
private List listeners
private static final Logger log
Constructor Detail |
---|
protected Job(String description, URL predicturl, Thread work, boolean fakeupdates)
description
- Short description of this jobpredicturl
- Optional URL to save/load prediction times fromwork
- Optional thread to use in request to stop workMethod Detail |
---|
public void setProgress(String statedesc)
public void setProgress(int percent, String statedesc)
public void done()
public void ignoreTimings()
public String getStateDescription()
public void interrupt()
public boolean isInterruptable()
public void setInterruptable(boolean newInterruptable)
newInterruptable
- The interruptable to set.public boolean isFinished()
public int getPercent()
public int getReportedPercent()
public String getJobDescription()
public void addWorkListener(WorkListener li)
public void removeWorkListener(WorkListener li)
protected void fireStateChanged()
private int getAgeFromMap(Map props, String message)
protected void guessProgress()
private void predictSection(String message)
private void loadPredictions()
private void savePredictions()
|
Copyright ยจ 2003-2006 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |