Class Timer

  • All Implemented Interfaces:
    ITimer, java.io.Serializable
    Direct Known Subclasses:
    TickTimer

    public class Timer
    extends java.lang.Object
    implements ITimer, java.io.Serializable
    A timer for being notified at a specified timepoint.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected IClock clock
      The clock.
      protected static int count
      The instance count.
      protected int number
      The instance number.
      protected long time
      The time delta before the alarm.
      protected ITimedObject to
      The timed object.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Timer​(long time, IClock clock, ITimedObject to)
      Create a new timer.
    • Field Detail

      • count

        protected static int count
        The instance count.
      • time

        protected long time
        The time delta before the alarm.
      • clock

        protected IClock clock
        The clock.
      • number

        protected int number
        The instance number.
    • Constructor Detail

      • Timer

        protected Timer​(long time,
                        IClock clock,
                        ITimedObject to)
        Create a new timer.
    • Method Detail

      • getNotificationTime

        public long getNotificationTime()
        Get the next absolute alarm timepoint.
        Specified by:
        getNotificationTime in interface ITimer
        Returns:
        The next timepoint.
      • setNotificationTime

        public void setNotificationTime​(long time)
        Change notification time.
        Specified by:
        setNotificationTime in interface ITimer
        Parameters:
        The - notification time.
      • cancel

        public void cancel()
        Cancel the timer.
        Specified by:
        cancel in interface ITimer
      • getNumber

        protected int getNumber()
        Get the number.
        Returns:
        The number.