com.liquidatom.derbyscore.domain
Class Clock

java.lang.Object
  extended by com.liquidatom.derbyscore.domain.Clock
All Implemented Interfaces:
java.util.concurrent.locks.ReadWriteLock

@ThreadSafe
public class Clock
extends java.lang.Object
implements java.util.concurrent.locks.ReadWriteLock

A basic implementation of a clock which keeps track of time as it elapses and provides hooks for listeners to be notified when certain events occur on the clock.

Author:
Russell Francis (russ@metro-six.com)

Constructor Summary
Clock(Duration duration, boolean padMinutes)
           
 
Method Summary
 boolean addListener(ClockListener listener)
           
 void begin()
          Start this clock running.
 void beginAndSynchronizeTo(Clock clock)
           
 void end()
          End the execution of this clock.
protected  void fireOnBegin()
           
protected  void fireOnChanged()
           
protected  void fireOnEnd()
           
protected  void fireOnPause()
           
protected  void fireOnResume()
           
protected  void fireOnTerminate()
           
 java.lang.String getDisplayTime()
           
 boolean isEnded()
           
 boolean isPaused()
           
 boolean isTerminated()
           
 void pause()
          Pause the execution of this clock.
 java.util.concurrent.locks.Lock readLock()
           
 boolean removeListener(ClockListener listener)
           
 void reset(Duration duration)
           
 void resume()
          Resume execution of the clock.
 void terminate()
           
 void tick(long currentTimeMillis)
           
 java.util.concurrent.locks.Lock writeLock()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Clock

public Clock(Duration duration,
             boolean padMinutes)
Method Detail

addListener

public boolean addListener(ClockListener listener)

removeListener

public boolean removeListener(ClockListener listener)

fireOnChanged

protected void fireOnChanged()

fireOnBegin

protected void fireOnBegin()

fireOnEnd

protected void fireOnEnd()

fireOnTerminate

protected void fireOnTerminate()

fireOnPause

protected void fireOnPause()

fireOnResume

protected void fireOnResume()

isEnded

public boolean isEnded()

terminate

public void terminate()

isTerminated

public boolean isTerminated()

isPaused

public boolean isPaused()

pause

public void pause()
Pause the execution of this clock.


resume

public void resume()
Resume execution of the clock.


reset

public void reset(Duration duration)

getDisplayTime

public java.lang.String getDisplayTime()

begin

public void begin()
Start this clock running.


beginAndSynchronizeTo

public void beginAndSynchronizeTo(Clock clock)

end

public void end()
End the execution of this clock.


tick

public void tick(long currentTimeMillis)

readLock

public java.util.concurrent.locks.Lock readLock()
Specified by:
readLock in interface java.util.concurrent.locks.ReadWriteLock

writeLock

public java.util.concurrent.locks.Lock writeLock()
Specified by:
writeLock in interface java.util.concurrent.locks.ReadWriteLock