T - is the type of high resolution time.public abstract class HighResolutionTime<T extends HighResolutionTime<T>>
extends java.lang.Object
implements java.lang.Comparable<T>, java.lang.Cloneable
HighResolutionTime is the base class for AbsoluteTime
and RelativeTime. It can be used to express time with nanosecond
resolution. This class is never used directly; it is abstract and has no
public constructor. Instead, one of its subclasses AbsoluteTime or
RelativeTime should be used. When an API is defined that has a
HighResolutionTime as a parameter, it can take either an absolute or
a relative time and will do something appropriate.
Caution: This class is explicitly unsafe for multithreading when being changed. Code that mutates instances of this class should synchronize at a higher level.
| Modifier and Type | Method and Description |
|---|---|
abstract AbsoluteTime |
absolute(Chronograph chronograph)
absolute converts this time to an absolute time relative to the
given chronograph.
|
abstract AbsoluteTime |
absolute(Chronograph chronograph,
AbsoluteTime dest)
absolute converts this time to an absolute time relative to the
given chronograph.
|
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.
|
java.lang.Object |
clone()
produces a clone of this object.
|
int |
compareTo(T time)
Compares
this HighResolutionTime with the specified
HighResolutionTime time. |
boolean |
equals(java.lang.Object object)
equals checks if this and object are equal.
|
boolean |
equals(T time)
equals checks if this and time are equal.
|
Chronograph |
getChronograph()
getChronograph returns a reference to the chronograph associated with this.
|
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(Chronograph chronograph)
relative returns a new relative time object for this relative to
the given chronograph.
|
abstract RelativeTime |
relative(Chronograph chronograph,
RelativeTime time)
relative converts this time to a relative time using the given
chronograph.
|
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.
|
T |
set(Chronograph chronograph,
long millis,
int nanos)
Sets the all components of
this. |
T |
set(long millis)
Sets the millisecond component of
this to the given argument, and
the nanosecond component of this to 0. |
T |
set(long millis,
int nanos)
Sets the millisecond and nanosecond components of
this. |
T |
set(T time)
Changes the value represented by
this to that of the given
time. |
static boolean |
waitForObject(java.lang.Object target,
HighResolutionTime<?> time)
waitForObject waits for the given object using a
HighResolutionTime as timeout.
|
public abstract AbsoluteTime absolute(Chronograph chronograph)
chronograph - The chronograph the result should be relative to.public abstract AbsoluteTime absolute(Clock clock)
clock - The clock the result should be relative to.public abstract AbsoluteTime absolute(Chronograph chronograph, AbsoluteTime dest)
chronograph - The chronograph 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.public abstract AbsoluteTime absolute(Clock clock, AbsoluteTime dest)
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.public int compareTo(T time)
this HighResolutionTime with the specified
HighResolutionTime time.compareTo in interface java.lang.Comparable<T extends HighResolutionTime<T>>time - To be compared with the time of this.time.StaticIllegalArgumentException - when the time
parameter is not associated with the same chronograph as
this, or when the time parameter is null.java.lang.ClassCastException - when the time parameter is not of
the same class as this.public boolean equals(T time)
time - another HighResulutionTime object.public boolean equals(java.lang.Object object)
equals in class java.lang.Objectobject - another object.public Chronograph getChronograph()
ensure
(Result != null);
public Clock getClock()
ensure
(Result != null);
public final long getMilliseconds()
public final int getNanoseconds()
public int hashCode()
hashCode in class java.lang.Objectpublic T set(T time)
this to that of the given
time. The Chronograph associated with this is set
to be the Chronograph associated with the time parameter.time - The new value of thisthisjava.lang.ClassCastException - when the type of this and the
type of the parameter time are
not the same.StaticIllegalArgumentException - when the parameter time
is null.public T set(long millis)
this to the given argument, and
the nanosecond component of this to 0. This method is equivalent to
set(millis, 0).millis - This value shall be the value of the millisecond component of
this at the completion of the call.thispublic T set(long millis, int nanos)
this. The setting
is subject to parameter normalization. When after normalization the time is
negative then the time represented by this is set to a negative
value, but note that negative times are not supported everywhere. For
instance, a negative relative time is an invalid value for a periodic
thread's period.millis - The desired value for the millisecond component of this at the completion of the call. The actual value is the
result of parameter normalization.nanos - The desired value for the nanosecond component of this at the completion of the call. The actual value is thethisStaticIllegalArgumentException - when there is an overflow in the
millisecond component while normalizing.
result of parameter normalization.public T set(Chronograph chronograph, long millis, int nanos) throws StaticIllegalArgumentException
this.
The setting is subject to parameter normalization.
When after normalization the time is negative, the time represented by
this is set to a negative value, but note, negative
times are not supported everywhere. For instance, a negative relative
time is an invalid value for a periodic thread's period.chronograph - The time reference for the other components of
this set during the call call.millis - The desired value for the millisecond component of
this at the completion of the call.
The actual value is the result of parameter normalization.nanos - The desired value for the nanosecond component of
this at the completion of the call.
The actual value is the result of parameter normalization.thisStaticIllegalArgumentException - when there is an overflow in the
millisecond component while normalizing.public static boolean waitForObject(java.lang.Object target,
HighResolutionTime<?> time)
throws java.lang.InterruptedException
target - the target object to wait for.time - The timeout given as AbsoluteTime or RelativeTime.true when the notify was received before the
timeout; false otherwise.java.lang.InterruptedException - when another thread caused this
thread to be interrupted during the wait.public abstract RelativeTime relative(Chronograph chronograph)
chronograph - The chronograph the result should be relative to.public abstract RelativeTime relative(Clock clock)
clock - The clock the result should be relative to.public abstract RelativeTime relative(Chronograph chronograph, RelativeTime time)
chronograph - The chronograph 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.public abstract RelativeTime relative(Clock clock, RelativeTime time)
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.public java.lang.Object clone()
clone in class java.lang.Objectaicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2024 aicas GmbH. All Rights Reserved.