org.ka2ddo.util
Class ReschedulableTimerTask

java.lang.Object
  extended by org.ka2ddo.util.ReschedulableTimerTask
All Implemented Interfaces:
java.lang.Comparable<ReschedulableTimerTask>, java.lang.Runnable

public abstract class ReschedulableTimerTask
extends java.lang.Object
implements java.lang.Runnable, java.lang.Comparable<ReschedulableTimerTask>

This class defines a timer task whose delivery time can be changed while the timer is pending delivery, and can be rescheduled any number of times.


Constructor Summary
ReschedulableTimerTask()
          Constructor for a ReschedulableTimerTask.
 
Method Summary
 void cancel()
          Stop running this task, taking it off the pending queue.
 int compareTo(ReschedulableTimerTask o)
          Test the order of this task relative to other tasks.
 boolean equals(java.lang.Object obj)
          Test if this is the same task instance.
 int hashCode()
          Get the hashcode for this object.
 boolean isActive()
          Test if this task is actively queued to a timer.
 void resched(ReschedulableTimer queue, java.util.Date wakeupTime)
          Queue this task to the specified timer to be executed at the specified time.
 void resched(ReschedulableTimer queue, java.util.Date wakeupTime, long repeatInterval)
          Queue this task to the specified timer to be executed at the specified time.
 void resched(ReschedulableTimer queue, int delay)
          Queue this task to the specified timer to be executed after the specified period of time.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 

Constructor Detail

ReschedulableTimerTask

public ReschedulableTimerTask()
Constructor for a ReschedulableTimerTask.

Method Detail

resched

public void resched(ReschedulableTimer queue,
                    int delay)
Queue this task to the specified timer to be executed after the specified period of time.

Parameters:
queue - ReschedulableTimer to manage this task
delay - interval in milliseconds before this task should be executed

resched

public void resched(ReschedulableTimer queue,
                    java.util.Date wakeupTime)
Queue this task to the specified timer to be executed at the specified time.

Parameters:
queue - ReschedulableTimer to manage this task
wakeupTime - Date object defining the time at which this task should be executed (or as soon after as possible)

resched

public void resched(ReschedulableTimer queue,
                    java.util.Date wakeupTime,
                    long repeatInterval)
Queue this task to the specified timer to be executed at the specified time.

Parameters:
queue - ReschedulableTimer to manage this task
wakeupTime - Date object defining the time at which this task should be executed (or as soon after as possible)
repeatInterval - time in milliseconds after last scheduled run time that this task should run again

cancel

public void cancel()
Stop running this task, taking it off the pending queue.


compareTo

public final int compareTo(ReschedulableTimerTask o)
Test the order of this task relative to other tasks.

Specified by:
compareTo in interface java.lang.Comparable<ReschedulableTimerTask>
Parameters:
o - another ReschedulableTimerTask
Returns:
-1 if this task is due earlier than the other task, 0 if due at the same time, or +1 if this task is due after the other task

equals

public final boolean equals(java.lang.Object obj)
Test if this is the same task instance.

Overrides:
equals in class java.lang.Object
Parameters:
obj - some object
Returns:
boolean true if it is this object

hashCode

public final int hashCode()
Get the hashcode for this object.

Overrides:
hashCode in class java.lang.Object
Returns:
hashcode

isActive

public boolean isActive()
Test if this task is actively queued to a timer.

Returns:
if this task is scheduled to be executed