stella.parameter
Class AlarmWatch

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.parameter.AbstractParameter
                  extended by stella.parameter.AbstractValue
                      extended by stella.parameter.StopWatch
                          extended by stella.parameter.AlarmWatch
All Implemented Interfaces:
Cloneable, Parameter, StatePreserving, ParameterDepending, Value, ExitCleaning, Initializable, LocalizedSupplying, Preserving, PropertySupplying, Reloadable, ResourceSupplying

public class AlarmWatch
extends StopWatch

An alarm watch acts like a stop watch, but additionally implements notification after a certain amount of time has been accumulated in the stop watch.


Nested Class Summary
private  class AlarmWatch.AlarmNotify
          The thread that watches the accumulated time and notifies the monitor if the alarm intervall has elapsed.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  long accumulate
          The time to accumulation for a notifiacation to occur.
private static long DEFACCURACY
          The default accuracy.
private static long DEFALARM
          The default alarm intervall.
static String KEY_ACCURACY
          The key linked to the sleeping intervall for time-out rechecks.
static String KEY_ALARM
          The key linked to alarm intervall.
private  Object notify
          The object that shuld be notified if alarm time has elapsed.
 
Fields inherited from class stella.parameter.StopWatch
KEY_INIT, KEY_TIME
 
Fields inherited from class stella.parameter.AbstractParameter
KEY_FORMAT, KEY_NAME, KEY_PRESERVE, UNKNOWN
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Constructor Summary
AlarmWatch(Map prop)
          Constructs a new alarm watch.
 
Method Summary
 void setAlarm(long newalarm)
          Sets an alarm intervall.
 void setMonitor(Object sleeper)
          Sets the object that waits for the alarm.
 void start()
          Starts the alarm clock.
 
Methods inherited from class stella.parameter.StopWatch
getFormatted, getValue, isCounting, preserve, registerParameter, rescanned, reset, restart, restore, setValue, stop
 
Methods inherited from class stella.parameter.AbstractValue
get, set
 
Methods inherited from class stella.parameter.AbstractParameter
createParameter, delivers, exit, getFormatted, getName, getPreserveFile, getString, getString, init, register, setName, toString
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, setObject, setProperties, setProperty, stringProperties
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface stella.Parameter
get, getName, getString, set
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 
Methods inherited from interface util.Initializable
init
 
Methods inherited from interface util.ExitCleaning
exit
 
Methods inherited from interface util.Reloadable
reload
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

KEY_ALARM

public static final String KEY_ALARM
The key linked to alarm intervall.

See Also:
Constant Field Values

KEY_ACCURACY

public static final String KEY_ACCURACY
The key linked to the sleeping intervall for time-out rechecks.

See Also:
Constant Field Values

DEFALARM

private static final long DEFALARM
The default alarm intervall. Zero means no notification.

See Also:
Constant Field Values

DEFACCURACY

private static final long DEFACCURACY
The default accuracy. Alarms will only be accurate to this time.

See Also:
Constant Field Values

notify

private Object notify
The object that shuld be notified if alarm time has elapsed.


accumulate

private long accumulate
The time to accumulation for a notifiacation to occur.

Constructor Detail

AlarmWatch

public AlarmWatch(Map prop)
Constructs a new alarm watch. In the default setup, no notifiaction will occur.

Method Detail

setAlarm

public void setAlarm(long newalarm)
Sets an alarm intervall. The notify object will be notified after enough time has been accumulated in this alarm watch.

Parameters:
time - The alarm intervall in ms. Zero resets the alarm.
See Also:
setMonitor(java.lang.Object)

setMonitor

public void setMonitor(Object sleeper)
Sets the object that waits for the alarm. This method must always be called before the start() method, otherwise notifiaction will not occur. If the method is called when the alarm watch is running, an IllegalThreadStateException is thrown.


start

public void start()
Starts the alarm clock. If a monitor was registered to this alarm watch with setMonitor(java.lang.Object), a thread is started that checks on regular intervalls (see KEY_ACCURACY) if the alarm intervall has elapsed. As soon as the accumulated time has passed or reached the alarm intervall, the monitor is notified.

Overrides:
start in class StopWatch