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.


Method Summary
abstract  AbsoluteTime absolute(Clock clock)
          Convert this time to an absolute time, relative to some clock.
abstract  AbsoluteTime absolute(Clock clock, AbsoluteTime dest)
          Convert this time to an absolute time, relative to some clock.
 int compareTo(HighResolutionTime time)
          Compares this HighResolutionTime with the specified HighResolutionTime.
 int compareTo(java.lang.Object object)
          For the Comparable interface.
 boolean equals(HighResolutionTime time)
          Returns true if the argument object has the same values as this.
 boolean equals(java.lang.Object object)
          Returns true if the argument is a HighResolutionTime reference and has the same values as this.
 long getMilliseconds()
          Returns the milliseconds component of this.
 int getNanoseconds()
          Returns nanoseconds component of this.
 int hashCode()
           
abstract  RelativeTime relative(Clock clock)
          Change the association of this from the currently associated clock to the given clock.
abstract  RelativeTime relative(Clock clock, HighResolutionTime time)
          Convert the given instance of HighResolutionTime to an instance of RelativeTime relative to the given instance of Clock.
 void set(HighResolutionTime time)
          Changes the time represented by the argument to some time between the invocation of the method and the return of the method.
 void set(long millis)
          Sets the millisecond component of this to the given argument.
 void set(long millis, int nanos)
          Sets the millisecond and nanosecond components of this.
static void waitForObject(java.lang.Object target, HighResolutionTime time)
          Behaves exactly like target.wait() but with the enhancement that it waits with a precision of HighResolutionTime
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

absolute

public abstract AbsoluteTime absolute(Clock clock)
Convert this time to an absolute time, relative to some clock. Convenient for situations where you really need an absolute time. Allocates a destination object if necessary. See the derived class comments for more specific information.
Parameters:
clock - This clock is used to convert this time into absolute time.

absolute

public abstract AbsoluteTime absolute(Clock clock,
                                      AbsoluteTime dest)
Convert this time to an absolute time, relative to some clock. Convenient for situations where you really need an absolute time. Allocates a destination object if necessary. See the derived class comments for more specific information.
Parameters:
clock - This clock is used to convert this time into absolute time.
dest - If null, a new object is created and returned as result, else dest is returned.

compareTo

public int compareTo(HighResolutionTime time)
Compares this HighResolutionTime with the specified HighResolutionTime.
Parameters:
time - compares with this time.

compareTo

public int compareTo(java.lang.Object object)
For the Comparable interface.
Specified by:
compareTo in interface java.lang.Comparable

equals

public boolean equals(HighResolutionTime time)
Returns true if the argument object has the same values as this.
Parameters:
time - Values are compared to this.

equals

public boolean equals(java.lang.Object object)
Returns true if the argument is a HighResolutionTime reference and has the same values as this.
Overrides:
equals in class java.lang.Object
Parameters:
object - Values are 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 nanoseconds component of this.

hashCode

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

set

public void set(HighResolutionTime time)
Changes the time represented by the argument to some time between the invocation of the method and the return of the method.
Parameters:
time - The HighResolutionTime which will be set to represent the current time.

set

public void set(long millis)
Sets the millisecond component of this to the given argument.
Parameters:
millis - This value will be the value of the millisecond component of this at the completion of the call. If millis is negative the millisecond value of this is set to negative value. Although logically this may represent time before the epoch, invalid results may occur if a HighResolutionTime representing time before the epoch is given as a parameter to the methods.

set

public void set(long millis,
                int nanos)
Sets the millisecond and nanosecond components of this.
Parameters:
millis - Value to set millisecond part of this. If millis is negative the millisecond value of this is set to negative value. Although logically this may represent time before the epoch, invalid results may occur if a HighResolutionTime representing time before the epoch is given as a parameter to the methods.
nanos - Value to set nanosecond part of this. If nanos is negative the millisecond value of this is set to negative value. Although logically this may represent time before the epoch, invalid results may occur if a HighResolutionTime representing time before the epoch is given as a parameter to the methods.

waitForObject

public static void waitForObject(java.lang.Object target,
                                 HighResolutionTime time)
                          throws java.lang.InterruptedException
Behaves exactly like target.wait() but with the enhancement 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 indefinitely.
Throws:
java.lang.InterruptedException - If another threads interrupts this thread while its waiting.
See Also:
Object.wait(long), Object.wait(long), Object.wait(long,int)

relative

public abstract RelativeTime relative(Clock clock)
Change the association of this from the currently associated clock to the given clock.

relative

public abstract RelativeTime relative(Clock clock,
                                      HighResolutionTime time)
Convert the given instance of HighResolutionTime to an instance of RelativeTime relative to the given instance of Clock.