gui.run
Class RunJob

java.lang.Object
  extended by gui.run.RunJob
All Implemented Interfaces:
RunProgressInterface, java.lang.Runnable
Direct Known Subclasses:
CheckForDeathJobFile, CheckForDeathJobProperties

public abstract class RunJob
extends java.lang.Object
implements java.lang.Runnable, RunProgressInterface


Field Summary
static int MAX_PRIORITY
          The maximum priority that a RunJob can have.
static int MIN_PRIORITY
          The minimum priority that a RunJob can have.
static int NORM_PRIORITY
          The default priority that is assigned to a RunJob.
 
Constructor Summary
RunJob(double seconds)
          Runs the run() method every seconds.
RunJob(double seconds, boolean wait)
          Run the RunJob every seconds If wait is true then do not start the RunJob until the start method is invoked.
RunJob(double seconds, boolean wait, int maximumNumberOfTimesRun)
          Run the RunJob every so many seconds If wait is true then do not start the RunJob until the start method is invoked.
RunJob(double seconds, boolean wait, int maximumNumberOfTimesToRun, boolean isDaemon)
          Run the RunJob every seconds If wait is true then do not start the RunJob until the start method is invoked.
RunJob(double seconds, boolean wait, int maximumNumberOfTimesRun, boolean isDaemon, int priority)
          Run the RunJob every seconds If wait is true then do not start the RunJob until the start method is invoked.
 
Method Summary
 long getCurrent()
          How many ms you have left.
 long getLengthOfTask()
           
 java.lang.String getMessage()
           
 java.lang.String getName()
          Gets the name of this RunJob (and the thread upon which the RunJob is based

First the checkAccess method of this thread is called with no arguments.

 int getNumberOfTimesRun()
           
 int getPriority()
          Returns this RunJob's priority.
 boolean isAlive()
          Tests if this RunJob is alive.
 boolean isDaemon()
          Tests if the RunJob is a daemon RunJob.
 boolean isDone()
           
static void main(java.lang.String[] args)
           
 void restart()
           
 void setName(java.lang.String name)
          Changes the name of this RunJob (and thread upon which the RunJob is based, to be equal to the argument name.
 void setPriority(int priority)
          Changes the priority of this RunJob.
 void start()
          Start will restart a RunJob that was stopped.
 void stop()
          Stops the RunJob by causing a thread death.
 java.lang.String toString()
          Returns a string representation of this RunJob, including the RunJob's name, priority, and thread group to which the RunJob's thread belongs.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 

Field Detail

MIN_PRIORITY

public static final int MIN_PRIORITY
The minimum priority that a RunJob can have.

See Also:
Constant Field Values

NORM_PRIORITY

public static final int NORM_PRIORITY
The default priority that is assigned to a RunJob.

See Also:
Constant Field Values

MAX_PRIORITY

public static final int MAX_PRIORITY
The maximum priority that a RunJob can have.

See Also:
Constant Field Values
Constructor Detail

RunJob

public RunJob(double seconds)
Runs the run() method every seconds. The job starts right away.

Parameters:
seconds - shows how many seconds between jobs

RunJob

public RunJob(double seconds,
              boolean wait)
Run the RunJob every seconds If wait is true then do not start the RunJob until the start method is invoked. Otherwise, start right away.

Parameters:
seconds - shows how many seconds between jobs
wait - if true, will wait before start

RunJob

public RunJob(double seconds,
              boolean wait,
              int maximumNumberOfTimesRun)
Run the RunJob every so many seconds If wait is true then do not start the RunJob until the start method is invoked. Otherwise, start right away. If the maximumNumberOfTimesRun is present, then the job only executes maximumNumberOfTimesRun times.

Parameters:
seconds - shows how many seconds between jobs
wait - if true, will wait before start
maximumNumberOfTimesRun - Integer.MINVALUE is infinite

RunJob

public RunJob(double seconds,
              boolean wait,
              int maximumNumberOfTimesToRun,
              boolean isDaemon)
Run the RunJob every seconds If wait is true then do not start the RunJob until the start method is invoked. Otherwise, start right away. If the count is present, then the job only executes count. isDaemon Marks this RunJob as either a daemon RunJob or a user RunJob. The Java Virtual Machine exits when the only RunJobs running are all daemon RunJobs and all Threads are daemon threads. The default value for isDaemon is false.

Parameters:
seconds - seconds of wait between jobs
wait - true if you want to delay start
maximumNumberOfTimesToRun - number of times to execute. Integer.MINVALUE is infinite
isDaemon - true if you want to exit on main exit

RunJob

public RunJob(double seconds,
              boolean wait,
              int maximumNumberOfTimesRun,
              boolean isDaemon,
              int priority)
Run the RunJob every seconds If wait is true then do not start the RunJob until the start method is invoked. Otherwise, start right away. If the maximumNumberOfTimesRun is present, then the job only executes maximumNumberOfTimesRun. isDaemon Marks this RunJob as either a daemon RunJob or a user RunJob. The Java Virtual Machine exits when the only RunJobs running are all daemon RunJobs and all Threads are daemon threads. The default value for isDaemon is false.

Parameters:
seconds - seconds of wait between jobs
wait - true if you want to delay start
maximumNumberOfTimesRun - number of times to execute. Integer.MINVALUE is infinite
isDaemon - true if you want to exit on main exit
priority - the internal threads priority.
Method Detail

getNumberOfTimesRun

public int getNumberOfTimesRun()
Returns:
the number of times the RunJob was run.

setPriority

public void setPriority(int priority)
Changes the priority of this RunJob.

This may result in throwing a SecurityException.

Otherwise, the priority of this RunJob is set to the smaller of the specified newPriority and the maximum permitted priority of the RunJobs's thread group. If the priority is smaller than MIN_PRIORITY then it will be set to MIN_PRIORITY. If the priority is greater than MAX_PRIORITY then it will be set to MAX_PRIORITY. This avoids illegal arguments.

Parameters:
priority - priority to set this RunJob to
Throws:
java.lang.SecurityException - if the current RunJob cannot modify its thread.
See Also:
getPriority(), MAX_PRIORITY, MIN_PRIORITY

getPriority

public final int getPriority()
Returns this RunJob's priority.

Returns:
this RunJob's priority.
See Also:
setPriority(int), Thread.setPriority(int)

getLengthOfTask

public long getLengthOfTask()
Specified by:
getLengthOfTask in interface RunProgressInterface
Returns:
the length of the task in ms.

start

public void start()
Start will restart a RunJob that was stopped. It will also start a RunJob that was never started.

Specified by:
start in interface RunProgressInterface

isDone

public boolean isDone()
Specified by:
isDone in interface RunProgressInterface
Returns:
true if the task is finished.

setName

public void setName(java.lang.String name)
Changes the name of this RunJob (and thread upon which the RunJob is based, to be equal to the argument name.

First the checkAccess method of this thread is called with no arguments. This may result in throwing a SecurityException.

Parameters:
name - the new name for this thread.

getName

public java.lang.String getName()
Gets the name of this RunJob (and the thread upon which the RunJob is based

First the checkAccess method of this thread is called with no arguments. This may result in throwing a SecurityException.

Returns:
the name of the internal thread

stop

public void stop()
Stops the RunJob by causing a thread death. A start() invocation Will make a new thread and restart the RunJob.

Specified by:
stop in interface RunProgressInterface

getCurrent

public long getCurrent()
Description copied from interface: RunProgressInterface
How many ms you have left.

Specified by:
getCurrent in interface RunProgressInterface
Returns:

getMessage

public java.lang.String getMessage()
Specified by:
getMessage in interface RunProgressInterface
Returns:
a message that identifies this task

isDaemon

public boolean isDaemon()
Tests if the RunJob is a daemon RunJob.

Returns:
true if this RunJob is a daemon RunJob; false otherwise.

isAlive

public boolean isAlive()
Tests if this RunJob is alive. A RunJob is alive if it has been started and has not yet run for the requisite number of times.

Returns:
true if this RunJob is alive; false otherwise.

toString

public java.lang.String toString()
Returns a string representation of this RunJob, including the RunJob's name, priority, and thread group to which the RunJob's thread belongs.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this thread.

restart

public void restart()

main

public static void main(java.lang.String[] args)