javax.realtime
Class HighResolutionTime

java.lang.Object
  |
  +--javax.realtime.HighResolutionTime
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
AbsoluteTime, RelativeTime

public abstract class HighResolutionTime
extends java.lang.Object
implements java.lang.Comparable

Class HighResolutiontime is the base class for AbsoluteTime, RelativeTime, RationalTime.


Field Summary
protected static javax.realtime.Clock defaultClock
           
private  long millis
           
private  int nanos
           
 
Constructor Summary
HighResolutionTime()
           
 
Method Summary
abstract  javax.realtime.AbsoluteTime absolute(javax.realtime.Clock clock)
          Convert the time of this to an absolute time, relative to the given instance of Clock.
abstract  javax.realtime.AbsoluteTime absolute(javax.realtime.Clock c, javax.realtime.AbsoluteTime dest)
          Convert the time of this to an absolute time, relative to the given instance of Clock.
 int compareTo(javax.realtime.HighResolutionTime b)
          Compares this HighResolutionTime with the specified HighResolutionTime.
 int compareTo(java.lang.Object b)
          Compares this HighResolutionTime with the specified HighResolutionTime.
 boolean equals(javax.realtime.HighResolutionTime b)
          Returns true if the argument object has the same values as this.
 boolean equals(java.lang.Object b)
          Returns true if the argument object has the same values as this.
 long getMilliseconds()
          Returns the milliseconds component of this.
 int getNanoseconds()
          Returns the nanoseconds component of this.
 int hashCode()
           
abstract  javax.realtime.RelativeTime relative(javax.realtime.Clock clock)
          Convert the time of this to a relative time, with respect to the given instance of Clock.
abstract  javax.realtime.RelativeTime relative(javax.realtime.Clock clock, javax.realtime.HighResolutionTime time)
          Convert the time of this to a relative time, with respect to the given instance of Clock.
 void set(javax.realtime.HighResolutionTime t)
          Change the value represented by this to that of the given time.
 void set(long millisecs)
          Sets the millisecond component of this to the given argument.
 void set(long millisecs, int nanosecs)
          Sets the millisecond and nanosecond compenonets of this.
 long time()
          Returns millis * 1000000 + nanos.
static void waitForObject(java.lang.Object target, javax.realtime.HighResolutionTime time)
          Behaves exactly like target.wait() but with the enhacement that it waits with a precision of HighResolutionTime.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

millis

private long millis

nanos

private int nanos

defaultClock

protected static javax.realtime.Clock defaultClock
Constructor Detail

HighResolutionTime

public HighResolutionTime()
Method Detail

absolute

public abstract javax.realtime.AbsoluteTime absolute(javax.realtime.Clock clock)
Convert the time of this to an absolute time, relative to the given instance of Clock. Convenient for situations where you really need an absolute time. Aloocates a destination object if necessary.

Parameters:
clock - An instance of Clock is used to convert the time of this into absolute time.

absolute

public abstract javax.realtime.AbsoluteTime absolute(javax.realtime.Clock c,
                                                     javax.realtime.AbsoluteTime dest)
Convert the time of this to an absolute time, relative to the given instance of Clock. Convenient for situations where you really need an absolute time. Aloocates a destination object if necessary.

Parameters:
dest - If null, a new object is created and returned as result, else dest is returned.

compareTo

public int compareTo(javax.realtime.HighResolutionTime b)
Compares this HighResolutionTime with the specified HighResolutionTime.


compareTo

public int compareTo(java.lang.Object b)
Compares this HighResolutionTime with the specified HighResolutionTime.

Specified by:
compareTo in interface java.lang.Comparable

equals

public boolean equals(javax.realtime.HighResolutionTime b)
Returns true if the argument object has the same values as this.


equals

public boolean equals(java.lang.Object b)
Returns true if the argument object has the same values as this.

Overrides:
equals in class java.lang.Object
Parameters:
b - Value compared to this.

getMilliseconds

public final long getMilliseconds()
Returns the milliseconds component of this.

Returns:
The milliseconds component of the time past the epoch represented by this.

getNanoseconds

public final int getNanoseconds()
Returns the nanoseconds component of this.


hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

relative

public abstract javax.realtime.RelativeTime relative(javax.realtime.Clock clock)
Convert the time of this to a relative time, with respect to the given instance of Clock. Convenient for situations where you really need a relative time. Allocates a destination object if necessary.

Parameters:
clock - An instance of Clock is used to convert the time of this into realtive time.

relative

public abstract javax.realtime.RelativeTime relative(javax.realtime.Clock clock,
                                                     javax.realtime.HighResolutionTime time)
Convert the time of this to a relative time, with respect to the given instance of Clock. Convenient for situations where you really need a relative time. Allocates a destination object if necessary.

Parameters:
clock - An instance of Clock is used to convert the time of this into realtive time.
time - If null, a new object is created and returned as result, else time is returned.

set

public void set(javax.realtime.HighResolutionTime t)
Change the value represented by this to that of the given time. If the type of this and the type of the given time are not the same this method will throw IllegalArgumentException.

Parameters:
t - The new value for this.

set

public void set(long millisecs)
Sets the millisecond component of this to the given argument.


set

public void set(long millisecs,
                int nanosecs)
Sets the millisecond and nanosecond compenonets of this.


waitForObject

public static void waitForObject(java.lang.Object target,
                                 javax.realtime.HighResolutionTime time)
                          throws java.lang.InterruptedException
Behaves exactly like target.wait() but with the enhacement that it waits with a precision of HighResolutionTime.

Parameters:
target - The object on which to wait. The current thread must have a lock on the object.
time - The time for which to wait. If this is RelativeTime(0, 0) then wait indefinetly.
Throws:
java.lang.InterruptedException - If another thread interrupts this thread while it is waiting.

time

public long time()
Returns millis * 1000000 + nanos.