Voyager ORB

com.objectspace.lib.timer
Class Stopwatch

java.lang.Object
  |
  +--com.objectspace.lib.timer.Stopwatch

public class Stopwatch
extends java.lang.Object
implements IStopwatch, java.io.Serializable

A Stopwatch offers basic timing facilities as well as the ability to record individual lap times.

Version:
3.0
See Also:
Serialized Form

Constructor Summary
Stopwatch()
          Construct myself to be a reset stopwatch.
 
Method Summary
 double getAverageLapTime()
          Return the average lap time in milliseconds.
 java.util.Date getDate()
          Return the current date.
 int getLapCount()
          Return the current lap count.
 long getLapTime()
          Return the last lap time.
 long[] getLapTimes()
          Return an array of longs that contain the number of milliseconds for each recorded lap or an empty array if lap times were not recorded.
 long getMilliseconds()
          Return the current time as milliseconds since January 1, 1970, 00:00:00 GMT.
 long getTotalTime()
          Return the sum of all the individual lap times in milliseconds.
 boolean isRecordLapTimes()
          Return true if the recording of lap times is enabled.
 void lap()
          Stop the stopwatch to record a lap time and then immediately start the stopwatch again.
 void reset()
          Reset the stopwatch, clear the lap times, and set the lap count to zero.
 void setRecordLapTimes(boolean flag)
          If flag is true, enable the recording of lap times.
 void start()
          Start the stopwatch.
 void stop()
          Stop the stopwatch, increment the lap count, and record the lap time if enabled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Stopwatch

public Stopwatch()
Construct myself to be a reset stopwatch.
Method Detail

getDate

public java.util.Date getDate()
Return the current date.
Specified by:
getDate in interface IStopwatch

getMilliseconds

public long getMilliseconds()
Return the current time as milliseconds since January 1, 1970, 00:00:00 GMT.
Specified by:
getMilliseconds in interface IStopwatch

reset

public void reset()
Reset the stopwatch, clear the lap times, and set the lap count to zero.
Specified by:
reset in interface IStopwatch

start

public void start()
Start the stopwatch.
Specified by:
start in interface IStopwatch

stop

public void stop()
Stop the stopwatch, increment the lap count, and record the lap time if enabled.
Specified by:
stop in interface IStopwatch

lap

public void lap()
Stop the stopwatch to record a lap time and then immediately start the stopwatch again.
Specified by:
lap in interface IStopwatch

setRecordLapTimes

public void setRecordLapTimes(boolean flag)
If flag is true, enable the recording of lap times.
Specified by:
setRecordLapTimes in interface IStopwatch

isRecordLapTimes

public boolean isRecordLapTimes()
Return true if the recording of lap times is enabled.
Specified by:
isRecordLapTimes in interface IStopwatch

getLapCount

public int getLapCount()
Return the current lap count.
Specified by:
getLapCount in interface IStopwatch

getLapTime

public long getLapTime()
Return the last lap time.
Specified by:
getLapTime in interface IStopwatch

getLapTimes

public long[] getLapTimes()
Return an array of longs that contain the number of milliseconds for each recorded lap or an empty array if lap times were not recorded.
Specified by:
getLapTimes in interface IStopwatch

getTotalTime

public long getTotalTime()
Return the sum of all the individual lap times in milliseconds.
Specified by:
getTotalTime in interface IStopwatch

getAverageLapTime

public double getAverageLapTime()
Return the average lap time in milliseconds.
Specified by:
getAverageLapTime in interface IStopwatch

ObjectSpace Inc.

(c) Copyright 1997-1999 ObjectSpace, Inc.
14850 Quorum Drive, Suite 500
Dallas, Texas 75240