public class RelativeTime extends HighResolutionTime
Jamaica Real-Time Specification for Java class RelativeTime.
An instance of this class represents an interval of time measured by a Clock. The interval is given as a tuple of milliseconds and nanoseconds. The set of intervals that can be represented by this class ranges from -263ms - 999,999ns to 263ms - 1ns (more than 292 billion years back and into the future).
Constructor and Description |
---|
RelativeTime()
Constructor to create the empty interval bound to the default
RealtimeClock.
|
RelativeTime(Clock clock)
Constructor to create the empty interval bound to the provided
clock.
|
RelativeTime(long ms,
int ns)
Constructor to create an interval using the provided interval
that is bound to the default RealtimeClock.
|
RelativeTime(long ms,
int ns,
Clock clock)
Constructor to create an interval using the provided interval
that is bound to the default RealtimeClock.
|
RelativeTime(RelativeTime time)
Constructor to create a new RelativeTime object that represents
the same interval as the given RelativeTime and that has the same
clock association.
|
RelativeTime(RelativeTime time,
Clock clock)
Constructor to create a new RelativeTime object that represents
the same interval as the given RelativeTime and that has the same
clock association or the clock association provided as a non-null
clock parameter.
|
Modifier and Type | Method and Description |
---|---|
AbsoluteTime |
absolute(Clock clock)
absolute creates a new instance of absolute time for the point in
time given by the current time of the given clock.
|
AbsoluteTime |
absolute(Clock clock,
AbsoluteTime destination)
absolute converts this relative time into an instance of absolute
time for the point in time given by the current time of the given
clock.
|
RelativeTime |
add(long millis,
int nanos)
add adds time given in milliseconds and nanoseconds to this
relative time.
|
RelativeTime |
add(long millis,
int nanos,
RelativeTime dest)
add adds time given in milliseconds and nanoseconds to this
relative time.
|
RelativeTime |
add(RelativeTime time)
add adds interval given as an instance of RelativeTime to this
relative time.
|
RelativeTime |
add(RelativeTime time,
RelativeTime dest)
add adds interval given as an instance of RelativeTime to this
relative time.
|
void |
addInterarrivalTo(AbsoluteTime destination)
Deprecated.
RTSJ V1.0.1 this method is only required to support
the deprecated RationalTime.
|
int |
compareToZero()
compareTo compares this to zero.
|
RelativeTime |
getInterarrivalTime()
Deprecated.
RTSJ V1.0.1 this method is only required to support
the deprecated RationalTime.
|
RelativeTime |
getInterarrivalTime(RelativeTime dest)
Deprecated.
RTSJ V1.0.1 this method is only required to support
the deprecated RationalTime.
|
RelativeTime |
negate()
Multiply the current time by -1.
|
RelativeTime |
negate(RelativeTime destination)
Multiply the current time by -1.
|
RelativeTime |
relative(Clock clock)
relative returns a new instance of this interval with the given
clock association.
|
RelativeTime |
relative(Clock clock,
RelativeTime destination)
relative returns a copy of this interval with the given clock
association.
|
RelativeTime |
scale(int factor)
multiply the current time by an integral scaling factor.
|
RelativeTime |
scale(int factor,
RelativeTime destination)
Multiply the current time by an integral factor.
|
RelativeTime |
subtract(RelativeTime time)
substract substracts interval given as an instance of
RelativeTime from this relative time.
|
RelativeTime |
subtract(RelativeTime time,
RelativeTime dest)
Subtracts time from this.
|
java.lang.String |
toString()
toString returns this interval as a string of the form "(<milli>
ms, <nano> ns)".
|
clone, compareTo, equals, equals, getClock, getMilliseconds, getNanoseconds, hashCode, set, set, set, waitForObject
public RelativeTime()
This constructor is equivalent to RelativeTime(0, 0).
public RelativeTime(long ms, int ns)
Constructor to create an interval using the provided interval that is bound to the default RealtimeClock.
This constructor is equivalent to RelativeTime(ms, ns, null).
ms
- the milliseconds part of the intervalns
- the nanoseconds part of the interval.java.lang.IllegalArgumentException
- if normalization of millis and
nanos caused an overflow.public RelativeTime(RelativeTime time)
time
- the original RelativeTime.
+ @throws IllegalArgumentException if time is null.public RelativeTime(Clock clock)
This constructor is equivalent to RelativeTime(0, 0, clock).
clock
- the clock to be associated with this time,
null to use Clock.getRealtimeClock().public RelativeTime(long ms, int ns, Clock clock)
ms
- the milliseconds part of the intervalns
- the nanoseconds part of the interval.clock
- the clock to be associated with this time,
null to use Clock.getRealtimeClock().java.lang.IllegalArgumentException
- if normalization of millis and
nanos caused an overflow.public RelativeTime(RelativeTime time, Clock clock)
time
- the original RelativeTime.clock
- the clock association. May be null to use
time.getClock().java.lang.IllegalArgumentException
- if time is null.public AbsoluteTime absolute(Clock clock, AbsoluteTime destination)
absolute
in class HighResolutionTime
clock
- The clock, null to use Clock.getRealtimeClock().destination
- the destination absolute time object.java.lang.ArithmeticException
- if the resulting absolute time could
not be represented by an instance of AbsoluteTime.public AbsoluteTime absolute(Clock clock)
absolute
in class HighResolutionTime
clock
- The clock, null to use Clock.getRealtimeClock().java.lang.ArithmeticException
- if the resulting absolute time could
not be represented by an instance of AbsoluteTime.public RelativeTime relative(Clock clock)
relative
in class HighResolutionTime
clock
- The clock, null to use Clock.getRealtimeClock().public RelativeTime relative(Clock clock, RelativeTime destination)
relative
in class HighResolutionTime
clock
- The clock, null to use Clock.getRealtimeClock().destination
- the destination relative time object.public RelativeTime add(long millis, int nanos)
millis
- the milliseconds part of the interval to be added.nanos
- the nanoseconds part of the interval to be added.java.lang.ArithmeticException
- if the addition or normalization
results in an overflow.public int compareToZero()
public RelativeTime negate(RelativeTime destination)
scale(int, RelativeTime)
, where scale is given as -1; however
it is much faster.destination
- the destination relative time object.java.lang.ArithmeticException
- when the negation results in an overflow.public RelativeTime negate()
scale(int)
, where scale is given as -1; however
it is much faster.java.lang.ArithmeticException
- when the negation results in an overflow.public RelativeTime scale(int factor, RelativeTime destination)
factor
- by which to scale this time.destination
- the destination relative time object.java.lang.ArithmeticException
- when the scaling results in an overflow.public RelativeTime scale(int factor)
factor
- by which to scale this time.java.lang.ArithmeticException
- when the scaling results in an overflow.public RelativeTime add(long millis, int nanos, RelativeTime dest)
millis
- the milliseconds part of the interval to be added.nanos
- the nanoseconds part of the interval to be added.dest
- The preallocated RelativeTime object to hold the
result. May be null to indicate that a new object should be
allocated.java.lang.ArithmeticException
- if the addition or normalization
results in an overflow.public RelativeTime add(RelativeTime time)
time
- the time to be added.java.lang.ArithmeticException
- if the addition or normalization
results in an overflow.java.lang.IllegalArgumentException
- if time is null or
time.getClock() != getClock().public RelativeTime add(RelativeTime time, RelativeTime dest)
time
- the time to be added.dest
- The preallocated RelativeTime object to hold the
result. May be null to indicate that a new object should be
allocated.java.lang.ArithmeticException
- if the addition or normalization
results in an overflow.java.lang.IllegalArgumentException
- if time is null or
time.getClock() != getClock().public void addInterarrivalTo(AbsoluteTime destination) throws java.lang.NullPointerException
destination
- java.lang.NullPointerException
public RelativeTime getInterarrivalTime()
public RelativeTime getInterarrivalTime(RelativeTime dest)
dest
- The preallocated RelativeTime object to hold the
result. May be null to indicate that a new object should be
allocated.public RelativeTime subtract(RelativeTime time)
time
- the time to be added.java.lang.ArithmeticException
- if the subsctraction or normalization
results in an overflow.public RelativeTime subtract(RelativeTime time, RelativeTime dest)
time
- the time to be subtracted.dest
- The preallocated RelativeTime object to hold the
result. May be null to indicate that a new object should be
allocated.java.lang.ArithmeticException
- if the subtraction or normalization
results in an overflow.java.lang.IllegalArgumentException
- if time is null or
time.getClock() != getClock().public java.lang.String toString()
toString
in class java.lang.Object
aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2017 aicas GmbH. All Rights Reserved.