org.salespointframework.core
Class AutoTimer

java.lang.Object
  extended by org.salespointframework.core.AutoTimer
All Implemented Interfaces:
Timer

public class AutoTimer
extends java.lang.Object
implements Timer

A timer that has the functionality of the StepTimer and additionally can increase the time automatically.

Since:
2010
Author:
Thomas Kissinger

Field Summary
(package private)  long delay
          delay between increase steps
(package private)  int interval
          interval in ms by which the dates becomes increased
(package private)  java.lang.Thread thread
          Time thread
(package private)  java.util.GregorianCalendar time
          current date
(package private)  java.util.List<TimerListener> timerListeners
          List of attached TimerListeners
 
Constructor Summary
AutoTimer()
          Default Constructor.
AutoTimer(java.util.GregorianCalendar time, int interval, boolean start)
          Constructor
 
Method Summary
 void addTimerListener(TimerListener tlListener)
          Add a TimerListene to observer list
protected  void fireTimeChanged()
           
 long getDelay()
           
 java.lang.Object getInterval()
          Get the current interval for calls to goAhead().
 java.lang.Object getTime()
          Get the current time.
 java.lang.Comparable getTimeStamp()
          Create and return a fresh time stamp.
 void goAhead()
          Increases the date by interval
 void goAhead(int millis)
          increase the date by given ms
 void removeTimerListener(TimerListener tlListener)
          Removes the given TimerListener from the observer list
 void setDelay(long delay)
          Set the delay between increase steps
 void setInterval(java.lang.Object oInterval)
          Set the interval, by which the date becomes increased on each step
 void setTime(java.lang.Object oTime)
          Set the date
 void start()
          Starts the timer
 void stop()
          Stops the timer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

time

java.util.GregorianCalendar time
current date


interval

int interval
interval in ms by which the dates becomes increased


delay

long delay
delay between increase steps


timerListeners

java.util.List<TimerListener> timerListeners
List of attached TimerListeners


thread

java.lang.Thread thread
Time thread

Constructor Detail

AutoTimer

public AutoTimer()
Default Constructor. Uses actual Date - increases by 1 second - starts automatically


AutoTimer

public AutoTimer(java.util.GregorianCalendar time,
                 int interval,
                 boolean start)
Constructor

Parameters:
time - the initial date
interval - increase interval. delay also.
start. - if true, the timer starts immediately
Method Detail

start

public void start()
Starts the timer


stop

public void stop()
Stops the timer


fireTimeChanged

protected void fireTimeChanged()

addTimerListener

public void addTimerListener(TimerListener tlListener)
Add a TimerListene to observer list

Specified by:
addTimerListener in interface Timer
Parameters:
tlListener - the listener to be added
See Also:
TimerListener

getInterval

public java.lang.Object getInterval()
Description copied from interface: Timer
Get the current interval for calls to goAhead().

Specified by:
getInterval in interface Timer
Returns:
an Object representing the interval

getTime

public java.lang.Object getTime()
Description copied from interface: Timer
Get the current time.

This method should call the equivalent method of the Time object.

Specified by:
getTime in interface Timer
Returns:
an Object representing the current time

getTimeStamp

public java.lang.Comparable getTimeStamp()
Description copied from interface: Timer
Create and return a fresh time stamp.

This method should call the Time object's getTimeStamp() method passing a long value representing the number of the time stamp in this time period.

Specified by:
getTimeStamp in interface Timer

goAhead

public void goAhead()
             throws java.lang.IllegalArgumentException
Increases the date by interval

Specified by:
goAhead in interface Timer
Throws:
java.lang.IllegalArgumentException - if the interval does not meet the time object's class or format requirements
See Also:
TimerListener.onGoneAhead(org.salespointframework.core.events.TimerEvent)

getDelay

public long getDelay()

setDelay

public void setDelay(long delay)
Set the delay between increase steps

Parameters:
delay - in ms

goAhead

public void goAhead(int millis)
increase the date by given ms

Parameters:
millis -

removeTimerListener

public void removeTimerListener(TimerListener tlListener)
Removes the given TimerListener from the observer list

Specified by:
removeTimerListener in interface Timer
Parameters:
tlListener - the listener to be removed
See Also:
TimerListener

setInterval

public void setInterval(java.lang.Object oInterval)
Set the interval, by which the date becomes increased on each step

Specified by:
setInterval in interface Timer
Parameters:
oInterval - the interval to be set
See Also:
TimerListener.onIntervalSet(org.salespointframework.core.events.TimerEvent)

setTime

public void setTime(java.lang.Object oTime)
             throws java.lang.IllegalArgumentException
Set the date

Specified by:
setTime in interface Timer
Parameters:
oTime - the time to be set
Throws:
java.lang.IllegalArgumentException - if the time does not meet the time object's class or format requirements
See Also:
TimerListener.onTimeSet(org.salespointframework.core.events.TimerEvent)