SalesPoint Framework v3.1

sale
Class StepTimer

java.lang.Object
  extended bysale.StepTimer
All Implemented Interfaces:
Serializable, Timer
Direct Known Subclasses:
AutoTimer

public class StepTimer
extends Object
implements Timer

This is a rather simple implementation of the Timer interface.

It requires a Time object to work with. Every increasing of the timer has to be explicitly triggered by the goAhead() method.

Since:
v2.0
Author:
Stephan Gambke
See Also:
Serialized Form

Field Summary
protected  ListenerHelper m_lhListeners
          The listeners registered with this timer.
protected  Time m_tTime
          The current Time.
 
Constructor Summary
StepTimer()
          Create a new timer wich uses an instance of Step as the time object.
StepTimer(Time tTimeObject)
          Create a new timer wich uses the given Time object.
 
Method Summary
 void addTimerListener(TimerListener tlListener)
          Add a TimerListener which will receive TimerEvents triggered by this timer.
protected  void fireGoneAhead()
          Fire a goneAhead event.
protected  void fireIntervalSet()
          Fire an intervalSet event.
protected  void fireTimeSet()
          Fire a timeSet event.
 Object getInterval()
          Get the current interval.
 Object getTime()
          Get the current time.
 Time getTimeObject()
          Returns the object that contains the time.
 Comparable getTimeStamp()
          Create and return a fresh time stamp.
 void goAhead()
          Increase the time by the current interval.
 void removeTimerListener(TimerListener tlListener)
          Remove the given TimerListener.
 void setInterval(Object oInterval)
          Set the interval to be used by the goAhead() method.
 void setTime(Object oTime)
          Set the time and fire a timeSet event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_tTime

protected Time m_tTime
The current Time.


m_lhListeners

protected ListenerHelper m_lhListeners
The listeners registered with this timer.

Constructor Detail

StepTimer

public StepTimer()
Create a new timer wich uses an instance of Step as the time object.


StepTimer

public StepTimer(Time tTimeObject)
Create a new timer wich uses the given Time object.

Parameters:
tTimeObject - the time object to use
Method Detail

setTime

public void setTime(Object oTime)
             throws IllegalArgumentException
Set the time and fire a timeSet event.

The time has to be in a format that can be processed by the Time object.

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

getTime

public Object getTime()
Get the current time. This is delegated to the Time object.

Specified by:
getTime in interface Timer
Returns:
an Object representing the current time, the exact type depends on the time object
Override:
Never

getTimeObject

public Time getTimeObject()
Returns the object that contains the time.

Returns:
the Time object.
Override:
Never

setInterval

public void setInterval(Object oInterval)
Set the interval to be used by the goAhead() method.

The given interval has to be of a proper type to be used with the time object's goAhead() method.

Specified by:
setInterval in interface Timer
Parameters:
oInterval - the interval to be used
See Also:
TimerListener.onIntervalSet(sale.events.TimerEvent)
Override:
Never

getInterval

public Object getInterval()
Get the current interval.

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

addTimerListener

public void addTimerListener(TimerListener tlListener)
Add a TimerListener which will receive TimerEvents triggered by this timer.

Specified by:
addTimerListener in interface Timer
Parameters:
tlListener - the listener to be registered.
See Also:
TimerListener
Override:
Never

removeTimerListener

public void removeTimerListener(TimerListener tlListener)
Remove the given TimerListener.

Specified by:
removeTimerListener in interface Timer
Parameters:
tlListener - the listener to be deregistered.
See Also:
TimerListener
Override:
Never

goAhead

public void goAhead()
             throws IllegalArgumentException
Increase the time by the current interval.

If no interval has been set yet, the interval given by the Time.getDefaultInterval() method of the time object is used.

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

getTimeStamp

public Comparable getTimeStamp()
Create and return a fresh time stamp.

Specified by:
getTimeStamp in interface Timer
Returns:
a fresh time stamp.
Override:
Never

fireTimeSet

protected void fireTimeSet()
Fire a timeSet event.

Override:
Never

fireIntervalSet

protected void fireIntervalSet()
Fire an intervalSet event.

Override:
Never

fireGoneAhead

protected void fireGoneAhead()
Fire a goneAhead event.

Override:
Never

SalesPoint Framework v3.1