frysk.event
Class TimerEvent

java.lang.Object
  extended by frysk.event.TimerEvent
All Implemented Interfaces:
Event, Comparable

public abstract class TimerEvent
extends Object
implements Event, Comparable

A timer event. Fires MILLISECONDS into the future (possibly repeated at PERIODMILLIS intervals).


Constructor Summary
TimerEvent(long offsetMillis)
          Create a once-only timer that schedules an event TIMEMILLIS milliseconds into the future.
TimerEvent(long offsetMillis, long periodMillis)
          Create an interval timer that schedules its first event OFFSETMILLIS milliseconds into the future, and then schedules further events every PERIODMILLIS milliseconds after that.
 
Method Summary
 int compareTo(Object o)
          Timer events are ordered by time.
 long getCount()
          For the interval timer, return the number of intervals since the last periodMillis timer event was delivered.
 long getTimeMillis()
          Return the time, in milliseconds, that this timer event is next expected to fire.
 String toString()
          Return the TimerEvent as a string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface frysk.event.Event
execute
 

Constructor Detail

TimerEvent

public TimerEvent(long offsetMillis)
Create a once-only timer that schedules an event TIMEMILLIS milliseconds into the future.


TimerEvent

public TimerEvent(long offsetMillis,
                  long periodMillis)
Create an interval timer that schedules its first event OFFSETMILLIS milliseconds into the future, and then schedules further events every PERIODMILLIS milliseconds after that. Should a backlog of events form (where the next event becomes due before the previous event has been delivered) then only a single event will be delivered. The method getCount returns the number of events that should have been delivered.

Method Detail

compareTo

public int compareTo(Object o)
Timer events are ordered by time.

Specified by:
compareTo in interface Comparable

getTimeMillis

public long getTimeMillis()
Return the time, in milliseconds, that this timer event is next expected to fire.


getCount

public long getCount()
For the interval timer, return the number of intervals since the last periodMillis timer event was delivered. See (long, long).


toString

public String toString()
Return the TimerEvent as a string.

Overrides:
toString in class Object