Class 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.
      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.
    • Constructor Summary

      Constructors 
      Constructor Description
      Alarm()
      Create a new alarm.
      Alarm​(java.lang.String mode, Time time, java.lang.String filename, java.lang.String message, boolean active)
      Create a new alarm.
    • Field Detail

      • MONTHLY

        public static final java.lang.String MONTHLY
        Alarm mode monthly.
        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
      • 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.
    • 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 class java.lang.Object
      • addPropertyChangeListener

        public void addPropertyChangeListener​(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​(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 class java.lang.Object