org.starhope.appius.physica
Class Kalendor

java.lang.Object
  extended by java.util.TimerTask
      extended by org.starhope.appius.physica.Kalendor
All Implemented Interfaces:
Runnable

public class Kalendor
extends TimerTask

Author:
brpocock@star-hope.org

Nested Class Summary
private static class Kalendor.KalendorFutureThread
          WRITEME: Document this type.
 
Field Summary
private  ConcurrentHashMap<Long,Runnable> activities
          scheduled activities
private  Map<Long,Class<?>> owners
          What class scheduled things?
 
Constructor Summary
Kalendor()
           
 
Method Summary
 Runnable cancel(long when)
          Cancel a scheduled event
 void clearMySchedule()
          clear all activities for the calling class
 void clearScheduleFor(Class<?> klass)
          Clear all activities scheduled for a given class
 boolean equals(Object obj)
           
private  Class<?> getCallerClass()
          figure out the class who called into one of my routines using stack inspection
 Map<Long,Runnable> getMySchedule()
          get all scheduled activities for the calling class
 Map<Long,Runnable> getSchedule()
          Get a set of events that are owned by a given class
 Map<Long,Runnable> getScheduleFor(Class<?> klass)
          Get a set of events that are owned by a given class
 void run()
          WRITEME: Document this method brpocock@star-hope.org
 long schedule(long when, Runnable activity)
           
 String toString()
           
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

activities

private final ConcurrentHashMap<Long,Runnable> activities
scheduled activities


owners

private final Map<Long,Class<?>> owners
What class scheduled things?

Constructor Detail

Kalendor

public Kalendor()
Method Detail

cancel

public Runnable cancel(long when)
Cancel a scheduled event

Parameters:
when - the precise moment at which the event is handled
Returns:
the canceled event

clearMySchedule

public void clearMySchedule()
clear all activities for the calling class


clearScheduleFor

public void clearScheduleFor(Class<?> klass)
Clear all activities scheduled for a given class

Parameters:
klass - the class who registered the scheduled activity

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

getCallerClass

private Class<?> getCallerClass()
figure out the class who called into one of my routines using stack inspection

Returns:
the class calling us

getMySchedule

public Map<Long,Runnable> getMySchedule()
get all scheduled activities for the calling class

Returns:
all scheduled activities for the calling class

getSchedule

public Map<Long,Runnable> getSchedule()
Get a set of events that are owned by a given class

Returns:
a map of event handles (time to fire) and runnables.

getScheduleFor

public Map<Long,Runnable> getScheduleFor(Class<?> klass)
Get a set of events that are owned by a given class

Parameters:
klass - the class who scheduled the events
Returns:
a map of event handles (time to fire) and runnables.

run

public void run()
WRITEME: Document this method brpocock@star-hope.org

Specified by:
run in interface Runnable
Specified by:
run in class TimerTask

schedule

public long schedule(long when,
                     Runnable activity)
Parameters:
when - when to schedule the activity
activity - what to do
Returns:
the time when the activity will actually be performed, which may differ slightly, and can be used to cancel an event.

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()