SalesPoint Framework v3.1

sale
Interface Timer

All Superinterfaces:
Serializable
All Known Implementing Classes:
StepTimer

public interface Timer
extends Serializable

An object that is to be able to do the time management for your application has to implement this interface.

It is intended and therefore strongly recommended, that for higher flexibility implementations of this interface use an object implementing the Time interface to hold the current time and delegate most of the functionality to that object.

Since:
v2.0
Author:
Stephan Gambke

Method Summary
 void addTimerListener(TimerListener tlListener)
          Adds a listener for TimerEvents fired by this timer.
 Object getInterval()
          Get the current interval for calls to goAhead().
 Object getTime()
          Get the current time.
 Comparable getTimeStamp()
          Create and return a fresh time stamp.
 void goAhead()
          Increases the current time by an interval.
 void removeTimerListener(TimerListener tlListener)
          Removes a listener for TimerEvents.
 void setInterval(Object oInterval)
          Set the interval to be used by goAhead().
 void setTime(Object oTime)
          Set the current time.
 

Method Detail

setTime

public void setTime(Object oTime)
             throws IllegalArgumentException
Set the current time.

This method should call the equivalent method of the Time object and fire a timeSet event.

Of course, IllegalArgumentExceptions thrown by the Time object must be forwarded to the calling method.

Parameters:
oTime - the time to be set
Throws:
IllegalArgumentException - if the time does not meet the time object's class or format requirements
See Also:
TimerListener.onTimeSet(sale.events.TimerEvent)
Override:
Always

getTime

public Object getTime()
Get the current time.

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

Returns:
an Object representing the current time
Override:
Always

setInterval

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

An IllegalArgumentException is not yet thrown because the new interval is only stored.

This method should fire an intervalSet event.

Parameters:
oInterval - the interval to be set
See Also:
TimerListener.onIntervalSet(sale.events.TimerEvent)
Override:
Always

getInterval

public Object getInterval()
Get the current interval for calls to goAhead().

Returns:
an Object representing the interval
Override:
Always

addTimerListener

public void addTimerListener(TimerListener tlListener)
Adds a listener for TimerEvents fired by this timer.

Parameters:
tlListener - the listener to be added
See Also:
TimerListener
Override:
Always

removeTimerListener

public void removeTimerListener(TimerListener tlListener)
Removes a listener for TimerEvents.

Parameters:
tlListener - the listener to be removed
See Also:
TimerListener
Override:
Always

goAhead

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

This method should call the equivalent method at the Time object passing the interval set by through setInterval(). If no interval has been set yet, the Time object's getDefaultInterval() method can be used to get a valid default.

Additionally, a goneAhead event should be fired.

This method forwards IllegalArgumentExceptions thrown by the Time object's goAhead() method to the calling method.

Throws:
IllegalArgumentException - if the interval does not meet the time object's class or format requirements
See Also:
TimerListener.onGoneAhead(sale.events.TimerEvent)
Override:
Always

getTimeStamp

public Comparable getTimeStamp()
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.

Override:
Always

SalesPoint Framework v3.1