aicas logoJamaica 6.1 release 1

javax.realtime
Class Clock

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

public abstract class Clock
extends Object

Jamaica Real-Time 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 RealtimeClock.
abstract  RelativeTime getResolution()
          getResolution returns the resolution of this clock, i.e.
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
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 UnsupportedOperationException

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

Throws an UnsupportedOperationException if the concept of date is not supported by this clock, e.g. if this is a clock corresponding to the CPU execution time of the VM.

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

getRealtimeClock

public static Clock getRealtimeClock()

getRealtimeClock returns the default RealtimeClock. 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 RealtimeClock that is synchronized with the external world. On systems whose timer is not synchronized with the external world, the time of the returned RealtimeClock 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 located in HeapMemory.

Returns:
the default RealtimeClock.

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 current 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:
IllegalArgumentException - if parameter is null or represents a negative or zero interval.
UnsupportedOperationException - if setting of the timer is not supported for the given system.

aicas logoJamaica 6.1 release 1

aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2012 aicas GmbH. All Rights Reserved.