|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.realtime.HighResolutionTime
javax.realtime.RelativeTime
An object that represents a time interval millis/1E3 + nanos/1E9
seconds long. It generally is used to represent a time relative to
now. If the value of any of the millisecond or nanosecond fields is
negative the variable is set to negative value. Although logically
this may represent time before the epoch, invalid results may occur
if an instance of RelativeTime representing time before the epoch
is given as a parameter to the a method. For add and subtract
negative values behave just like they do in arithmetic.
Caution: This class is explicitly unsafe in multithreaded
situations when it is being changed. No synchronization is done. It
is assumed that users of this class who are mutating instances will
be doing their own synchronization at a higher level.
Constructor Summary | |
RelativeTime()
Equivalent to new . |
|
RelativeTime(Clock clock)
Equivalent to new . |
|
RelativeTime(long millis,
int nanos)
Construct a new RelativeTime object from the given
millisecond and nanosecond components and associated to the
default Clock . |
|
RelativeTime(long millis,
int nanos,
Clock clock)
Construct a new RelativeTime object from the given
millisecond and nanosecond components and associated to the
given Clock . |
|
RelativeTime(RelativeTime time)
Construct a new RelativeTime object from the given
RelativeTime and associated to the default Clock . |
|
RelativeTime(RelativeTime time,
Clock clock)
Construct a new RelativeTime object from the given
RelativeTime and associated to the given Clock . |
Method Summary | |
AbsoluteTime |
absolute(Clock clock)
Convert to absolute time (with respect to a given clock). |
AbsoluteTime |
absolute(Clock clock,
AbsoluteTime dest)
Convert to absolute time (with respect to a given clock). |
RelativeTime |
add(long millis,
int nanos)
Add a specific number of milli and nano seconds to this . |
RelativeTime |
add(long millis,
int nanos,
RelativeTime dest)
Add a specific number of milli and nano seconds to this. |
RelativeTime |
add(RelativeTime time)
Return this + time. |
RelativeTime |
add(RelativeTime time,
RelativeTime dest)
Return this + time. |
void |
addInterarrivalTo(AbsoluteTime timeAndDestination)
Deprecated. This method is deprecated in version 1.0.1(b) of the RTSJ. |
void |
decrement(RelativeTime time)
Deprecated. non-RTSJ method, will be removed in future |
RelativeTime |
getInterarrivalTime()
Deprecated. This method is deprecated in version 1.0.1(b) of the RTSJ. |
RelativeTime |
getInterarrivalTime(RelativeTime destination)
Deprecated. This method is deprecated in version 1.0.1(b) of the RTSJ. |
void |
increment(RelativeTime time)
Deprecated. non-RTSJ method, will be removed in future |
RelativeTime |
relative(Clock clock)
Convert to relative time (with respect to a given clock). |
RelativeTime |
relative(Clock clock,
RelativeTime dest)
Convert to relative time (with respect to a given clock). |
RelativeTime |
subtract(RelativeTime time)
Computes the difference (this - time). |
RelativeTime |
subtract(RelativeTime time,
RelativeTime dest)
Computes the difference (this - time). |
String |
toString()
Return a printable version of this time. |
Methods inherited from class javax.realtime.HighResolutionTime |
clone, compareTo, compareTo, equals, equals, getClock, getMilliseconds, getNanoseconds, hashCode, set, set, set, waitForObject |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public RelativeTime()
new RelativeTime
(0,0,Clock.getRealtimeClock()
)
.
public RelativeTime(Clock clock)
new RelativeTime
(0,0,clock)
.
clock
- the Clock
to which to associate this
RelativeTime
; if null, the default Clock
is usedpublic RelativeTime(long millis, int nanos)
RelativeTime
object from the given
millisecond and nanosecond components and associated to the
default Clock
.
millis
- a long
value specifing the
milliseconds componentnanos
- an int
value specifing the
nanoseconds componentpublic RelativeTime(long millis, int nanos, Clock clock)
RelativeTime
object from the given
millisecond and nanosecond components and associated to the
given Clock
.
millis
- a long
value specifing the
milliseconds componentnanos
- an int
value specifing the
nanoseconds componentclock
- the Clock
to which to associate this
RelativeTime
; if null, the default Clock
is usedpublic RelativeTime(RelativeTime time)
RelativeTime
object from the given
RelativeTime
and associated to the default Clock
.
time
- a RelativeTime
value from which the time
for this object will be taken
IllegalArgumentException
- if time
is
nullpublic RelativeTime(RelativeTime time, Clock clock)
RelativeTime
object from the given
RelativeTime
and associated to the given Clock
.
time
- a RelativeTime
value from which the time
for this object will be takenclock
- the Clock
to which to associate this
RelativeTime
; if null, the default Clock
is used
IllegalArgumentException
- if time
is
nullMethod Detail |
public AbsoluteTime absolute(Clock clock)
absolute
in class HighResolutionTime
clock
- the clock that will convert the time
this
(if already an
absolute time)public AbsoluteTime absolute(Clock clock, AbsoluteTime dest)
absolute
in class HighResolutionTime
clock
- the clock that will convert the timedest
- the destination object
public RelativeTime relative(Clock clock)
this
, since it is
already a relative time.
relative
in class HighResolutionTime
clock
- the clock that will convert the time
this
public RelativeTime relative(Clock clock, RelativeTime dest)
this
,
and returns dest.
relative
in class HighResolutionTime
clock
- the clock that will convert the timedest
- the destination object
public RelativeTime add(RelativeTime time)
time
- -the time to add to this.
IllegalArgumentException
- if the Clock
associated with this
and the Clock
associated with the time
parameter are different;
also thrown when time
is null
ArithmeticException
- if the result overflows during
addition or normalizationpublic RelativeTime add(RelativeTime time, RelativeTime dest)
time
- the time to add to this.dest
- where the result should be placed.
dest
is not null,
dest
is returned; otherwise a new RelativeTime
object is allocated to hold the result, and it is
returned
IllegalArgumentException
- if the Clock
associated with this
and the Clock
associated with the time
parameter are different;
also thrown when time
is null
ArithmeticException
- if the result overflows during
addition or normalizationpublic RelativeTime add(long millis, int nanos)
millis
- milli seconds to add.nanos
- nano seconds to add.
ArithmeticException
- if the result overflows during
addition or normalizationpublic RelativeTime add(long millis, int nanos, RelativeTime dest)
millis
- milliseconds to addnanos
- nanoseconds to adddest
- the destination in which to store the result
ArithmeticException
- if the result overflows during
addition or normalizationpublic RelativeTime subtract(RelativeTime time)
time
- relative time to subtract from this.
IllegalArgumentException
- if the Clock
associated with this
and the Clock
associated with the time
parameter are different;
also thrown when time
is null
ArithmeticException
- if the result overflows during
subtraction or normalizationpublic RelativeTime subtract(RelativeTime time, RelativeTime dest)
Note that this operation does not atomically change the
dest
parameter; the dest
object may
represent several intermediate time representations during the
execution of this method, and even if an exception is thrown,
the dest
object may have been udpated.
time
- relative time to subtract from this
dest
- the destination object that will hold the result
dest
is not null,
dest
is returned; otherwise a new RelativeTime
object is allocated to hold the result, and it is
returned
IllegalArgumentException
- if the Clock
associated with this
and the Clock
associated with the time
parameter are different;
also thrown when time
is null
ArithmeticException
- if the result overflows during
subtraction or normalizationpublic void increment(RelativeTime time)
add(time, this)
.
time
- the increment represented by a a RelativeTime
value
ArithmeticException
- if the result overflows during
increment or normalizationpublic void decrement(RelativeTime time)
subtract(time, this)
.
time
- the decrement represented by a a RelativeTime
value
ArithmeticException
- if the result overflows during
decrement or normalizationpublic String toString()
String
object converted from this
public void addInterarrivalTo(AbsoluteTime timeAndDestination)
this
to the given AbsoluteTime
.
timeAndDestination
- the given AbsoluteTime
; also,
used to store the resultpublic RelativeTime getInterarrivalTime()
this
. For an instance
of RationalTime
it is the interval divided by the
frequency. For a non-rational RelativeTime
, this
method returns a clone of this
.
public RelativeTime getInterarrivalTime(RelativeTime destination)
this
. For an instance
of RationalTime
it is the interval divided by the
frequency. For a non-rational RelativeTime
, this
method returns a clone of this
if
destination
is null, else it sets
destination
to this
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |