aicas logoJamaica 6.4 release 1

javax.realtime
Class HighResolutionTime

java.lang.Object
  extended by javax.realtime.HighResolutionTime
All Implemented Interfaces:
Cloneable, Comparable<Object>
Direct Known Subclasses:
AbsoluteTime, RelativeTime

public abstract class HighResolutionTime
extends Object
implements Comparable<Object>, Cloneable

Jamaica Real-Time Specification for Java abstract class HighResolutionTime.


Method Summary
abstract  AbsoluteTime absolute(Clock clock)
          absolute converts this time to an absolute time relative to the given clock.
abstract  AbsoluteTime absolute(Clock clock, AbsoluteTime dest)
          absolute converts this time to an absolute time relative to the given clock.
 Object clone()
          produces a clone of this object.
 int compareTo(HighResolutionTime time)
          compareTo compares this to another HighResolutionTime object.
 int compareTo(Object object)
          compareTo compares this to another object.
 boolean equals(HighResolutionTime time)
          equals checks if this and time are equal.
 boolean equals(Object object)
          equals checks if this and object are equal.
 Clock getClock()
          getClock returns a reference to the clock associated with this.
 long getMilliseconds()
          getMilliseconds returns the milliseconds part of this time object.
 int getNanoseconds()
          getNanoseconds returns the nanoseconds part of this time object.The time represented by this is getMilliseconds()*1000000+ getNanosecondes() ns.
 int hashCode()
          hashCode calculates a hashCode for this.
abstract  RelativeTime relative(Clock clock)
          relative returns a new relative time object for this relative to the given clock.
abstract  RelativeTime relative(Clock clock, RelativeTime time)
          relative converts this time to a relative time using the given clock.
 void set(HighResolutionTime time)
          set sets this time to the time specified by time.
 void set(long millis)
          set sets the milliseconds value of this object to millis.
 void set(long millis, int nanos)
          set sets the milliseconds and nanoseconds value of this object to millis and nanos.
static void waitForObject(Object target, HighResolutionTime time)
          waitForObject waits for the given object using a HighResolutionTime as timeout.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

absolute

public abstract AbsoluteTime absolute(Clock clock)
absolute converts this time to an absolute time relative to the given clock.

Parameters:
clock - The clock the result should be relative to.
Returns:
this or a new object allocated from the current memory area for the absolute time.

absolute

public abstract AbsoluteTime absolute(Clock clock,
                                      AbsoluteTime dest)
absolute converts this time to an absolute time relative to the given clock. Use a preallocated AbsoluteTime object if present.

Parameters:
clock - The clock the result should be relative to.
dest - The preallocated AbsoluteTime object to hold the result. May be null to indicate that a new object should be allocated.
Returns:
dest, if dest is not null, the newly allocated object otherwise.

compareTo

public int compareTo(HighResolutionTime time)
compareTo compares this to another HighResolutionTime object.

Parameters:
time - the time object this should be compared with.
Returns:
< 0 if this is before time, = 0 if that and time are equal, > 0 if this is after time.

compareTo

public int compareTo(Object object)
compareTo compares this to another object. If object is an instance of HighResolutionTime, then compare via compareTo. Otherwise, returns 0xDEADBEEF

Specified by:
compareTo in interface Comparable<Object>
Parameters:
object - the object this should be compared to.
Returns:
the comparison result.

equals

public boolean equals(HighResolutionTime time)
equals checks if this and time are equal.

Parameters:
time - another HighResulutionTime object.
Returns:
true iff this.compareTo(time)==0

equals

public boolean equals(Object object)
equals checks if this and object are equal.

Overrides:
equals in class Object
Parameters:
object - another object.
Returns:
true iff object is an instance of HighResolutionTime and is equal to this.

getClock

public Clock getClock()
getClock returns a reference to the clock associated with this.

ensure

   (Result != null);
 

Returns:
the clock associated with this
Since:
RTSJ V1.0.1

getMilliseconds

public final long getMilliseconds()
getMilliseconds returns the milliseconds part of this time object. The time represented by this is getMilliseconds()*1000000+ getNanosecondes() ns.

Returns:
the milliseconds

getNanoseconds

public final int getNanoseconds()
getNanoseconds returns the nanoseconds part of this time object.The time represented by this is getMilliseconds()*1000000+ getNanosecondes() ns.

Returns:
the nanoseconds.

hashCode

public int hashCode()
hashCode calculates a hashCode for this.

Overrides:
hashCode in class Object
Returns:
integer hashCode.

set

public void set(HighResolutionTime time)
set sets this time to the time specified by time. time must be of the same class as this.

Parameters:
time - another time object.
Throws:
IllegalArgumentException - iff time is an instance of a different class than this.

set

public void set(long millis)
set sets the milliseconds value of this object to millis.

ensure

   (getMilliseconds() == millis);
 

Parameters:
millis - the new value for the milliseconds.

set

public void set(long millis,
                int nanos)
set sets the milliseconds and nanoseconds value of this object to millis and nanos.

ensure

   (getMilliseconds() == millis,
    getNanoseconds() == nanos);
 

Parameters:
millis - the new value for the milliseconds.
nanos - the new value for the nanoseconds.

waitForObject

public static void waitForObject(Object target,
                                 HighResolutionTime time)
                          throws InterruptedException
waitForObject waits for the given object using a HighResolutionTime as timeout. This is equals to target.wait(), but it uses the higher accuracy of HighResolutionTime and it can handle AbsoluteTime and RelativeTime.

Parameters:
target - the target object to wait for.
time - The timeout given as AbsoluteTime or RelativeTime.
Throws:
InterruptedException - if another thread caused this thread to be interrupted during the wait.

relative

public abstract RelativeTime relative(Clock clock)
relative returns a new relative time object for this relative to the given clock.

Parameters:
clock - The clock the result should be relative to.
Returns:
a new RelativeTime object.

relative

public abstract RelativeTime relative(Clock clock,
                                      RelativeTime time)
relative converts this time to a relative time using the given clock. Use a preallocated RelativeTime object if present.

Parameters:
clock - The clock the result should be relative to.
time - The preallocated RelativeTime object to hold the result. May be null to indicate that a new object should be allocated.
Returns:
time, if time is not null, the newly allocated object otherwise.

clone

public Object clone()
produces a clone of this object.

Overrides:
clone in class Object
Returns:
a clone of this object

aicas logoJamaica 6.4 release 1

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