com.sas.util
Interface AlarmInterface

All Superinterfaces:
AlarmSource, com.sas.beans.PropertyChangeSource, com.sas.util.TimeIntervals, TimerInterface
All Known Implementing Classes:
Alarm

public interface AlarmInterface
extends TimerInterface, AlarmSource

An interface for Alarm objects.

Alarms are objects which send AlarmEvents at regular intervals.

For example, an Alarm object may be used in a document editor to support an autosave operations. An alarm can be created to fire at ten minute intervals (10 * AlarmInterface.ONE_MINUTE) and the alarm listener can be an object which performs the autosave if the document has been modified since the last autosave.

Properties

Name interval
Type long
Default value 0
Short description alarm interval
Description number of milliseconds the alarm waits between firing recurring AlarmEvents.
Namedelay
Type long
Default value 0
Short description Initial delay before firing
Description Number of milliseconds the alarm will wait before first firing an AlarmEvent.
Namecount
Type int
Default value 0
Short description Number of times to fire the alarm
Description Number of times to fire the alarm

See Also:
Alarm

Field Summary
 
Fields inherited from interface com.sas.util.TimeIntervals
ONE_DAY, ONE_HOUR, ONE_MINUTE, ONE_SECOND, ONE_WEEK
 
Method Summary
 void addAlarmListener(AlarmListener listener)
          Add a listener for the AlarmEvent event.
 int getCount()
          Get the numbre of times the Alarm will fire before stopping.
 long getDelay()
          Get the amount of time the Alarm will wait before first firing.
 long getInterval()
          Retrieve the alarm interval.
 void removeAlarmListener(AlarmListener listener)
          Remove a listener for the AlarmEvent event.
 void setCount(int count)
          Set the number of times the alarm will fire.
 void setDelay(long delayMillis)
          Set the amount of time the Alarm will wait before first firing.
 void setInterval(long newIntervalMillis)
          Set the interval at which the alarm fires.
 void setStartTime(long startTime)
          Set the timer's start time.
 void setStopTime(long stopTime)
          Set the timer's stop time.
 
Methods inherited from interface com.sas.util.TimerInterface
getDuration, getStartTime, getStopTime, isRunning, setRunning, start, stop
 

Method Detail

getInterval

long getInterval()
Retrieve the alarm interval. This is the amount of time, in milliseconds, between alarm events fired by the alarm. The interval is only approximate; not all platforms support precise timing.

Returns:
the alarm's interval.

setInterval

void setInterval(long newIntervalMillis)
Set the interval at which the alarm fires. If the new interval is shorter than the current interval, and the alarm is running, the alarm may fire sooner than previously scheduled. This is necessary, for instance, if you change the interval form ONE_HOUR to ONE_SECOND; you don't want to have to wait an hour for the new interval to take effect. If the new interval is larger than the current interval and the alarm is running, the alarm will still fire as previously scheduled, then assume the new interval. The interval is only approximate; not all platforms support precise millisecond timing.

Parameters:
newIntervalMillis - the new alarm interval, in milliseconds.

setDelay

void setDelay(long delayMillis)
Set the amount of time the Alarm will wait before first firing. The delay is only approximate; not all platforms support precise millisecond timing.

Parameters:
delayMillis - the alarm delay, in milliseconds.

getDelay

long getDelay()
Get the amount of time the Alarm will wait before first firing. The interval is only approximate; not all platforms support precise millisecond timing.

Returns:
the alarm delay, in milliseconds.

setCount

void setCount(int count)
Set the number of times the alarm will fire.

Parameters:
count - the number of times the alarm will fire. count is valid only if the interval is non-zero.

getCount

int getCount()
Get the numbre of times the Alarm will fire before stopping.

Returns:
the alarm count

addAlarmListener

void addAlarmListener(AlarmListener listener)
Add a listener for the AlarmEvent event.

Specified by:
addAlarmListener in interface AlarmSource
Parameters:
listener - an object which handles AlarmEvent events the listener is not added a second time if it already exists in the list of listeners for this event.
See Also:
AlarmSource

removeAlarmListener

void removeAlarmListener(AlarmListener listener)
Remove a listener for the AlarmEvent event. Nothing happens if the listener is not in the list of listeners for this event.

Specified by:
removeAlarmListener in interface AlarmSource
Parameters:
listener - an object which handles AlarmEvent events
See Also:
AlarmSource

setStartTime

void setStartTime(long startTime)
Set the timer's start time. This operation is only valid on an alarm that is not running; it sets the initial delay based on the specified startTime.

Parameters:
startTime - the time the timer should start, in number of milliseconds since the Epoch

setStopTime

void setStopTime(long stopTime)
Set the timer's stop time.

Parameters:
stopTime - the time the timer should stop, in milliseconds since the Epoch. If stopTime and count are 0 and interval is greater than zero, the timer will repeat indefinitely.



Copyright © 2009 SAS Institute Inc. All Rights Reserved.