aicas logoJamaicaVM 3.4 rel 9
RTSJ Implementation

javax.realtime
Class Clock

java.lang.Object
  extended by javax.realtime.Clock

public abstract class Clock
extends java.lang.Object

Jamaica Realtime Specification for Java class Clock.

A clock provides means to determine the current time (now) with a given resolution.


Constructor Summary
Clock()
          Constructor to be called by subclasses of Clock.
 
Method Summary
abstract  RelativeTime getEpochOffset()
          getEpochOffset returns the relative time of the offset from the Epoch (1.
static Clock getRealtimeClock()
          getRealtimeClock returns the default realtime clock.
abstract  RelativeTime getResolution()
          getResolution returns the resolution of this clock, i.e. the constant time interval between two consecutive ticks.
abstract  AbsoluteTime getTime()
          getTime returns a newly allocated object that contains the current time of this clock.
abstract  AbsoluteTime getTime(AbsoluteTime time)
          getTime store the current time of this clock into a previously allocated object Note that this time may be different from wallclock time for clocks that are not in sync with external time.
abstract  void setResolution(RelativeTime resolution)
          setResolution sets the resolution of this time to the provided value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Clock

public Clock()

Constructor to be called by subclasses of Clock.

Since this class is abstract, this constructor cannot be called from a class that is not a sub-class of Clock, it should therefore better be protected.

Method Detail

getEpochOffset

public abstract RelativeTime getEpochOffset()
                                     throws java.lang.UnsupportedOperationException

getEpochOffset returns the relative time of the offset from the Epoch (1. Jan 1970, 00h00:00) for this clock. This offset is ReltiveTime(0,0) for the realtime clock returned by getRealtimeClock().

Throws an UnsupportedOperationException if concept of date is not supported by this clock.

Returns:
newly allocated RelativeTime instance with the current offset past the Epoch for this clock.
Throws:
java.lang.UnsupportedOperationException - if concept of date not supported by this Clock.

getRealtimeClock

public static Clock getRealtimeClock()

getRealtimeClock returns the default realtime clock. The result is the singleton instance of this clock.

For JamaicaVM, on systems that have a timer that is synchronized with the external world, this returns a realtime clock that is synchronized with the external world. On systems whose timer is not synchronized with the external world, the time of the returned realtime clock may be different to the time used by the external world (e.g., the epoch may start at system boot time).

The result is allocated in immortal memory iff option -strictRTSJ is set for JamaicaVM. If this option is not set, the result will be in located in HeapMemory.

Returns:
the default realtime clock.

getResolution

public abstract RelativeTime getResolution()

getResolution returns the resolution of this clock, i.e. the constant time interval between two consecutive ticks.

A new object is allocated to hold the result

Returns:
the resolution of this clock.

getTime

public abstract AbsoluteTime getTime()

getTime returns a newly allocated object that contains the current time of this clock.

Note that this time may be different from wallclock time for clocks that are not in sync with external time.

Returns:
The curren time.

getTime

public abstract AbsoluteTime getTime(AbsoluteTime time)

getTime store the current time of this clock into a previously allocated object

Note that this time may be different from wallclock time for clocks that are not in sync with external time.

Parameters:
time - An instance of AbsoluteTime to hold the result. May be null, in this case this operation will be a NOP.
Returns:
The time parameters
Since:
RTSJ V1.0.1 the return value is AbsoluteTime and no longer void.

setResolution

public abstract void setResolution(RelativeTime resolution)

setResolution sets the resolution of this time to the provided value.

Parameters:
resolution - the new resolution.
Throws:
java.lang.IllegalArgumentException - if parameter is null or represents a negative or zero interval.
java.lang.UnsupportedOperationException - if setting of the timer is not supported for the given system.

aicas logoJamaicaVM 3.4 rel 9
RTSJ Implementation

aicas GmbH, Karlsruhe - Germany    www.aicas.com
Copyright 2001-2009 aicas GmbH. All Rights Reserved.