Package jadex.bdiv3.examples.alarmclock
Class Alarm
- java.lang.Object
-
- jadex.bdiv3.examples.alarmclock.Alarm
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public class Alarm extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable
This class encapsulates the functionality of an alarm.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
active
The active state.protected long
alarmdate
Cached alarm date.static java.lang.String[]
ALARMS
All alarm modes.protected boolean
calc_allowed
static java.lang.String
DAILY
Alarm mode daily.protected java.lang.String
filename
The alarm sound filename.static java.lang.String
HOURLY
Alarm mode hourly.protected java.lang.String
message
The alaram message.protected java.lang.String
mode
The alarm mode.static java.lang.String
MONTHLY
Alarm mode monthly.static int
NO_ALARM
No alarmtime -> calculate.static java.lang.String
ONCE
Alarm mode once.java.beans.PropertyChangeSupport
pcs
The helper object for bean events.protected Time
time
The alarm time.static java.lang.String
TIMER
Alarm mode timer.static int
UNKNOWN
Unknown alarmtime -> calculate.static java.lang.String
WEEKLY
Alarm mode weekly.static java.lang.String
YEARLY
Alarm mode yearly.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list.protected java.lang.Object
clone()
Creates and returns a copy of this object.long
getAlarmtime(long currenttime)
Get the alarm time.java.lang.String
getFilename()
Get the filename.java.net.URL
getFilenameUrl()
Get the filename.java.lang.String
getMessage()
Get the message.java.lang.String
getMode()
Get the mode.Time
getTime()
Get the alarm time.boolean
isActive()
Test if the alarm is active.void
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list.void
setActive(boolean active)
Set the alarm state.void
setAlarmtime(long alarmdate)
Save the alarmtime.void
setFilename(java.lang.String filename)
Set the filename.void
setMessage(java.lang.String message)
Set the message.void
setMode(java.lang.String mode)
Set the mode.void
setNextAlarmtime(long currenttime)
Calculate and save the next alarmtime.void
setTime(Time time)
Set the alarm time.java.lang.String
toString()
Get the string representation.void
triggerd()
Indicate that an alarm occurred.
-
-
-
Field Detail
-
TIMER
public static final java.lang.String TIMER
Alarm mode timer.- See Also:
- Constant Field Values
-
ONCE
public static final java.lang.String ONCE
Alarm mode once.- See Also:
- Constant Field Values
-
HOURLY
public static final java.lang.String HOURLY
Alarm mode hourly.- See Also:
- Constant Field Values
-
DAILY
public static final java.lang.String DAILY
Alarm mode daily.- See Also:
- Constant Field Values
-
WEEKLY
public static final java.lang.String WEEKLY
Alarm mode weekly.- See Also:
- Constant Field Values
-
MONTHLY
public static final java.lang.String MONTHLY
Alarm mode monthly.- See Also:
- Constant Field Values
-
YEARLY
public static final java.lang.String YEARLY
Alarm mode yearly.- See Also:
- Constant Field Values
-
ALARMS
public static final java.lang.String[] ALARMS
All alarm modes.
-
UNKNOWN
public static final int UNKNOWN
Unknown alarmtime -> calculate.- See Also:
- Constant Field Values
-
NO_ALARM
public static final int NO_ALARM
No alarmtime -> calculate.- See Also:
- Constant Field Values
-
mode
protected java.lang.String mode
The alarm mode.
-
filename
protected java.lang.String filename
The alarm sound filename.
-
message
protected java.lang.String message
The alaram message.
-
time
protected Time time
The alarm time.
-
alarmdate
protected long alarmdate
Cached alarm date.
-
calc_allowed
protected boolean calc_allowed
-
active
protected boolean active
The active state.
-
pcs
public transient java.beans.PropertyChangeSupport pcs
The helper object for bean events.
-
-
Constructor Detail
-
Alarm
public Alarm()
Create a new alarm. Bean constructor. Clock needs to be set manually, later.
-
Alarm
public Alarm(java.lang.String mode, Time time, java.lang.String filename, java.lang.String message, boolean active)
Create a new alarm.- Parameters:
mode
- The alarm mode (once, hourly, daily, weekly, monthly, yearly)time
- The alarm time.filename
- The alarm sound.message
- The alarm message.
-
-
Method Detail
-
getMode
public java.lang.String getMode()
Get the mode.- Returns:
- The mode.
-
setMode
public void setMode(java.lang.String mode)
Set the mode.- Parameters:
mode
- The mode.
-
getFilename
public java.lang.String getFilename()
Get the filename.- Returns:
- The filename.
-
getFilenameUrl
public java.net.URL getFilenameUrl()
Get the filename.
-
setFilename
public void setFilename(java.lang.String filename)
Set the filename.- Parameters:
filename
- The filename.
-
getMessage
public java.lang.String getMessage()
Get the message.- Returns:
- The message.
-
setMessage
public void setMessage(java.lang.String message)
Set the message.- Parameters:
message
- The message.
-
getAlarmtime
public long getAlarmtime(long currenttime)
Get the alarm time.
-
setAlarmtime
public void setAlarmtime(long alarmdate)
Save the alarmtime.- Parameters:
alarmdate
- The alarmdate.
-
triggerd
public void triggerd()
Indicate that an alarm occurred.
-
setNextAlarmtime
public void setNextAlarmtime(long currenttime)
Calculate and save the next alarmtime.
-
isActive
public boolean isActive()
Test if the alarm is active.- Returns:
- True, if active.
-
setActive
public void setActive(boolean active)
Set the alarm state.- Parameters:
active
- True for active.
-
getTime
public Time getTime()
Get the alarm time.- Returns:
- The alarm time.
-
setTime
public void setTime(Time time)
Set the alarm time.- Parameters:
time
- The alarm time.
-
clone
protected java.lang.Object clone()
Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object- Overrides:
clone
in classjava.lang.Object
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. The listener is registered for all properties.- Parameters:
listener
- The PropertyChangeListener to be added.
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.- Parameters:
listener
- The PropertyChangeListener to be removed.
-
toString
public java.lang.String toString()
Get the string representation.- Overrides:
toString
in classjava.lang.Object
-
-