|
||||||||||
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.
Distribution Licence: JSword is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. The License is available on the internet here, or by writing to: Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA The copyright to this program is held by it's authors. |
Licence
Nested Class Summary | |
---|---|
private class |
Job.PredictAction
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 |
(package private) PropertyChangeSupport |
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 swing 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 |
addPropertyChangeListener(PropertyChangeListener li)
Interface for people to be notified of changes to the current Font. |
void |
done()
Called to indicate that we are finished with the dialog |
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 |
removePropertyChangeListener(PropertyChangeListener li)
Interface for people to be notified of changes to the current Font. |
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
PropertyChangeSupport 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()
private int getAgeFromMap(Map props, String message)
protected void guessProgress()
private void predictSection(String message)
private void loadPredictions()
private void savePredictions()
public void addPropertyChangeListener(PropertyChangeListener li)
li
- The new listener classpublic void removePropertyChangeListener(PropertyChangeListener li)
li
- The listener class to be deleted
|
Copyright ? 2003-2004 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |