javax.realtime
Class RealtimeClock

java.lang.Object
  extended byjavax.realtime.Clock
      extended byjavax.realtime.RealtimeClock

public class RealtimeClock
extends Clock

The class RealtimeClock provides access to the "Wall-Clock" time. In the current implementation the resolution of the clock is of the order of microseconds.

Implementation Note: This class is implemented by using the method call gettimeofday, so it has a resolution that depends on the resolution guaranteed by the underlying OS. If you need to make real fine grain time measurement than you should use that class HighResolutionClock. This class provide nanosecond time accuracy in most plaform.

Author:
Angelo Corsaro, Morgan Deters
See Also:
HighResolutionClock

Method Summary
 RelativeTime getEpochOffset()
          Gets the relative time of the offset of the epoch of this Clock from the Epoch.
 RelativeTime getResolution()
          Return the resolution of the clock -- the interval between ticks.
 AbsoluteTime getTime()
          Return the current time in a freshly allocated object.
 AbsoluteTime getTime(AbsoluteTime time)
          Return the current time in an existing object.
static RealtimeClock instance()
          Get the singleton instance of RealtimeClock.
 void setResolution(RelativeTime resolution)
          Set the resolution of this.
 
Methods inherited from class javax.realtime.Clock
getRealtimeClock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

instance

public static RealtimeClock instance()
Get the singleton instance of RealtimeClock.

Returns:
the singleton instance of RealtimeClock

getEpochOffset

public RelativeTime getEpochOffset()
Gets the relative time of the offset of the epoch of this Clock from the Epoch. This clock implementation returns RelativeTime(0,0) in accordance with the spec.

Specified by:
getEpochOffset in class Clock
Returns:
a newly-allocated RelativeTime object representing the offset of the epoch; the returned object is associated with this Clock
Since:
0.4.0

getResolution

public RelativeTime getResolution()
Return the resolution of the clock -- the interval between ticks.

Specified by:
getResolution in class Clock
Returns:
A RelativeTime object representing the resolution of this.

setResolution

public void setResolution(RelativeTime resolution)
Set the resolution of this. For some hardwhere clocks setting resolution impossible and if called on those nothing happens.

Implementation Note: If the requested resolution overceeds the one obtainable by the underlying hardware this method guarantees that the finest resolution possible is set.

Specified by:
setResolution in class Clock
Parameters:
resolution - The new resolution of this.

getTime

public AbsoluteTime getTime()
Return the current time in a freshly allocated object.

Specified by:
getTime in class Clock
Returns:
An AbsoluteTime object representing the current time.

getTime

public AbsoluteTime getTime(AbsoluteTime time)
Return the current time in an existing object. The time represented by the given AbsoluteTime is changed some time between the invocation of the method and the return of the method.

Specified by:
getTime in class Clock
Parameters:
time - The AbsoluteTime object which will have its time changed; if null, this call has no effect
Returns:
time


jRate is developed and maintained by the jRate project development team.
Copyright (c) 2001-2006 Angelo Corsaro and Morgan Deters.