|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.aavalla.utils.jobpool.Job<R,P>
public abstract class Job<R,P>
Field Summary | |
---|---|
protected static java.lang.Throwable |
CANCELLEDRESULT
Derived classes' work() methods should return or throw this object, if they are cancelled. |
Constructor Summary | |
---|---|
Job()
Constructs a job and sets it's parameter (which will be passed to {@link #work(java.lang.Object)] to null. |
|
Job(P p)
Constructs a job and sets it's parameter |
Method Summary | ||
---|---|---|
protected boolean |
addCategory(JobCategory cat)
|
|
protected boolean |
addConflictingCategory(JobCategory cat)
|
|
boolean |
addJobFinishedListener(JobFinishedListener l)
Adds a listener to be notified when this job has ended. |
|
boolean |
addJobFinishedListenerSwing(JobFinishedListener l)
Adds a listener to be notified when this job has ended. |
|
protected void |
addSubjob(Job sub)
|
|
boolean |
cancelPending()
Returns true, if this job has a cancel pending ie. |
|
int |
compareTo(Job o)
Compares Jobs by priorities. |
|
java.util.EnumSet<JobCategory> |
getCategories()
Returns the categories this job is a part of. |
|
java.util.EnumSet<JobCategory> |
getConflictingCategories()
Returns the categories this job conflicts with. |
|
long |
getExecutionTime()
Returns execution time in nanoseconds. |
|
java.lang.String |
getName()
Returns the name of this job. |
|
JobPriority |
getPriority()
Returns the priority of this job. |
|
int |
getProgress()
Returns the progress of this job as a number {-1, [0..100]}. |
|
JobState |
getState()
Returns the state this job is currently in. |
|
java.lang.String |
getStatus()
Returns the last job's status message reported in the Job's execute() method by calling reportStatus(String) . |
|
boolean |
getUseRecursiveCancel()
|
|
long |
getWaitingTime()
Returns the time spent waiting for other threads for data. |
|
boolean |
isAncestorOf(Job j)
Returns true if this job is an ancestor of the job given as parameter ie. |
|
boolean |
isSilent()
Returns true, if this job is set to be silent ie. |
|
boolean |
removeJobFinishedListener(JobFinishedListener l)
Removes a listener. |
|
protected void |
reportProgress(int newProgress)
Reports the progress of this job to listeners including the pool. |
|
protected void |
reportStatus(java.lang.String newStatus)
|
|
void |
setCancelPending(boolean cancel)
|
|
protected void |
setCategories(java.util.Set<JobCategory> catset)
|
|
protected void |
setConflictingCategories(java.util.Set<JobCategory> catset)
|
|
void |
setName(java.lang.String name)
Sets the name for this job. |
|
protected void |
setPriority(JobPriority newPriority)
Sets the priority for this job. |
|
protected void |
setSilent(boolean silent)
|
|
protected void |
setSupportsCancellation(boolean supCan)
|
|
void |
setUseRecursiveCancel(boolean recCancel)
|
|
boolean |
sharesAncestorWith(Job j)
Returns true, if this job and the job given as parameter share an ancestor ie. |
|
boolean |
supportsCancellation()
Returns true, if this Job has been set to support cancellation. |
|
java.lang.String |
toString()
Returns the name and state of this job as string. |
|
protected
|
waitSubJob(Job<S,?> sub)
|
|
protected abstract R |
work(P p)
ABSTRACT PROTECTED |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.Throwable CANCELLEDRESULT
Constructor Detail |
---|
public Job(P p)
p
- parameter (will be passed to execute()
).ParameterizedJob
public Job()
Method Detail |
---|
public final JobState getState()
JobState
public java.lang.String toString()
toString
in class java.lang.Object
public final java.lang.String getName()
setName(java.lang.String)
public final int getProgress()
public final java.lang.String getStatus()
execute()
method by calling reportStatus(String)
.
Not null.
public final JobPriority getPriority()
JobPool
.
JobPriority
public final long getExecutionTime()
public final long getWaitingTime()
public final java.util.EnumSet<JobCategory> getCategories()
JobPool
. Can be empty, but not null.
getConflictingCategories()
public final java.util.EnumSet<JobCategory> getConflictingCategories()
JobPool
. Can be empty, but
not null.
getCategories()
public boolean isSilent()
JobPool
-created UI. Note that even silent jobs are
counted in JobPool.getRunningThreadsCount()
and
sJobPool.getUnfinishedRootJobsCount()
.
public boolean isAncestorOf(Job j)
j
-
sharesAncestorWith(net.aavalla.utils.jobpool.Job)
public boolean sharesAncestorWith(Job j)
j
- job
isAncestorOf(net.aavalla.utils.jobpool.Job)
public final boolean supportsCancellation()
work(java.lang.Object)
methods ought to check
cancelPending()
periodically.
public final boolean getUseRecursiveCancel()
public final boolean cancelPending()
setCancelPending(boolean)
. Jobs that support cancellation,
ought to check this periodically in their work(java.lang.Object)
method.
public final void setName(java.lang.String name) throws java.lang.IllegalStateException
name
- new name for the job
java.lang.IllegalStateException
- Thrown, if called after the job has been
added to a JobPool
ie when
getState()!=JobState.CREATED
public final void setCancelPending(boolean cancel)
public final void setUseRecursiveCancel(boolean recCancel)
public final boolean addJobFinishedListener(JobFinishedListener l)
l
- listener to add
java.lang.IllegalStateException
- Thrown if called after this Job has already
finished or failed.public final boolean addJobFinishedListenerSwing(JobFinishedListener l)
l
- listener to add
java.lang.IllegalStateException
- Thrown if called after this Job has already
finished or failed.public final boolean removeJobFinishedListener(JobFinishedListener l)
l
- listener to remove
public final int compareTo(Job o)
equals()
. Used
by JobPool
to determine the order of starting jobs.
compareTo
in interface java.lang.Comparable<Job>
o
- other job to compare to
protected final void setPriority(JobPriority newPriority) throws java.lang.IllegalStateException
newPriority
- priority for this job
java.lang.IllegalStateException
- Thrown if trying to set priority when
this job's state is anything else than CREATED.protected final boolean addCategory(JobCategory cat) throws java.lang.IllegalStateException
java.lang.IllegalStateException
protected final void setCategories(java.util.Set<JobCategory> catset) throws java.lang.IllegalStateException
java.lang.IllegalStateException
protected final boolean addConflictingCategory(JobCategory cat) throws java.lang.IllegalStateException
java.lang.IllegalStateException
protected final void setConflictingCategories(java.util.Set<JobCategory> catset) throws java.lang.IllegalStateException
java.lang.IllegalStateException
protected final void setSupportsCancellation(boolean supCan)
protected final void setSilent(boolean silent) throws java.lang.IllegalStateException
java.lang.IllegalStateException
protected final void reportProgress(int newProgress)
newProgress
- protected final void reportStatus(java.lang.String newStatus)
protected final void addSubjob(Job sub)
protected final <S> S waitSubJob(Job<S,?> sub) throws java.lang.Throwable
java.lang.Throwable
protected abstract R work(P p) throws java.lang.Throwable
java.lang.Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |