stella.parameter
Class AlarmWatch
java.lang.Object
util.PropertyContainer
util.PropertyResources
util.PropertyBundles
stella.parameter.AbstractParameter
stella.parameter.AbstractValue
stella.parameter.StopWatch
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. |
|
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. |
|
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.AbstractParameter |
createParameter, delivers, exit, getFormatted, getName, getPreserveFile, getString, getString, init, register, setName, toString |
| 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 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 |
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.
AlarmWatch
public AlarmWatch(Map prop)
- Constructs a new alarm watch. In the default setup, no notifiaction
will occur.
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