public final class AbsoluteDateInterval extends ComparableInterval<AbsoluteDate>
This class implements an interval based on the AbsoluteDate class,
using the ComparableInterval class.
This implementation enforces that AbsoluteDate.PAST_INFINITE
and
AbsoluteDate.FUTURE_INFINITE
cannot be closed boundaries.
final AbsoluteDate lowEnd = new AbsoluteDate();
final AbsoluteDate upEnd = new AbsoluteDate(lowEnd, 4578.14);
final IntervalEndpointType lowInt = IntervalEndpointType.CLOSED;
final IntervalEndpointType upInt = IntervalEndpointType.OPEN;
final AbsoluteDateInterval dateInterval = new AbsoluteDateInterval(lowInt, lowEnd, upEnd, upInt);
Constructor and Description |
---|
AbsoluteDateInterval(AbsoluteDate lowerData,
AbsoluteDate upperData)
Builds a new
AbsoluteDateInterval with closed endpoints. |
AbsoluteDateInterval(ComparableInterval<AbsoluteDate> interval)
|
AbsoluteDateInterval(ComparableInterval<Double> interval,
AbsoluteDate referenceDate)
|
AbsoluteDateInterval(IntervalEndpointType lowerEndpointIn,
AbsoluteDate lowerDataIn,
AbsoluteDate upperDataIn,
IntervalEndpointType upperEndpointIn)
Builds a new
AbsoluteDateInterval . |
Modifier and Type | Method and Description |
---|---|
int |
compareDurationTo(AbsoluteDateInterval interval)
Checks if the duration of the interval is longer, shorter or equal to the duration of
another interval.
|
double |
durationFrom(AbsoluteDateInterval interval)
Computes the duration in seconds between the two intervals.
|
AbsoluteDateInterval |
extendTo(AbsoluteDate epoch)
Returns the interval after extending it so that it includes (closed endpoint) or is
connected (open endpoint) to the specified value.
|
double |
getDuration()
Computes the interval duration (its length) in seconds.
|
AbsoluteDateInterval |
getIntersectionWith(AbsoluteDateInterval interval)
Returns the intersection with another interval.
|
AbsoluteDateInterval |
mergeTo(AbsoluteDateInterval interval)
Returns this interval merged with another interval (if they can be merged).
|
AbsoluteDateInterval |
scale(double scalingFactor)
Returns the interval scaled by a given factor with respect to its midpoint.
|
AbsoluteDateInterval |
scale(double scalingFactor,
AbsoluteDate epoch)
Returns the interval scaled by a given factor with respect to the specified epoch.
|
AbsoluteDateInterval |
shift(double shift)
Returns the interval with its lower an upper bounds shifted by the specified value.
|
AbsoluteDateInterval |
shift(double lowerShift,
double upperShift)
Returns the interval with its lower an upper bounds shifted by the specified values.
|
String |
toString(AbsoluteDate date)
Returns a String representing the durations between the interval's bounds and a specified
date.
|
compareLowerEndTo, compareTo, compareUpperEndTo, contains, equals, getIntersectionWith, hashCode, includes, isConnectedTo, mergeTo, overlaps
getLowerData, getLowerEndpoint, getUpperData, getUpperEndpoint, toString
public AbsoluteDateInterval(AbsoluteDate lowerData, AbsoluteDate upperData)
AbsoluteDateInterval
with closed endpoints.lowerData
- the lower end AbsoluteDateupperData
- the upper end AbsoluteDateMathIllegalArgumentException
- when the interval is invalid (unchecked exception).GenericInterval
and ComparableInterval
checks, the infinite date boundaries also have to be opened.ComparableInterval
,
GenericInterval
,
AbsoluteDate
public AbsoluteDateInterval(IntervalEndpointType lowerEndpointIn, AbsoluteDate lowerDataIn, AbsoluteDate upperDataIn, IntervalEndpointType upperEndpointIn)
AbsoluteDateInterval
.lowerDataIn
- lower end AbsoluteDateupperDataIn
- upper end AbsoluteDatelowerEndpointIn
- lower end boundary typeupperEndpointIn
- upper end boundary typeMathIllegalArgumentException
- when the interval is invalid (unchecked exception).GenericInterval
and ComparableInterval
checks, the infinite date boundaries also have to be opened.ComparableInterval
,
GenericInterval
,
AbsoluteDate
public AbsoluteDateInterval(ComparableInterval<AbsoluteDate> interval)
interval
- the intervalMathIllegalArgumentException
- when the interval is invalid (unchecked exception).GenericInterval
and ComparableInterval
checks, the infinite date boundaries also have to be opened.ComparableInterval
,
GenericInterval
,
AbsoluteDate
public AbsoluteDateInterval(ComparableInterval<Double> interval, AbsoluteDate referenceDate)
AbsoluteDateInterval
from a ComparableInterval
<Double
>
and a reference AbsoluteDate
.
The bounds of the interval returned are computed by shifting the reference date by the lower and upper data of the interval provided.
interval
- the intervalreferenceDate
- the reference dateMathIllegalArgumentException
- when the interval is invalid (unchecked exception).GenericInterval
and ComparableInterval
checks, the infinite date boundaries also have to be opened.ComparableInterval
,
GenericInterval
,
AbsoluteDate
public double getDuration()
The duration is the number of seconds physically elapsed between the lower and the upper
endpoint, as computed by AbsoluteDate.durationFrom()
.
This means the duration is measured in a linear time scale (TAI time scale).
AbsoluteDate.durationFrom(AbsoluteDate)
public double durationFrom(AbsoluteDateInterval interval)
The duration between two intervals is the duration between the end of the earlier interval
and the beginning of the later. If the intervals overlap, this duration is 0.
The sign of the result is positive if the given interval comes earlier.
interval
- the given intervalAbsoluteDate.durationFrom(AbsoluteDate)
public int compareDurationTo(AbsoluteDateInterval interval)
It returns a positive integer if the duration is longer, a negative integer if the duration
is shorter and zero if the durations of the two intervals are identical.
The method checks also the lower and upper end points of the intervals, considering that an
interval with an open end point is shorter than an interval with the same duration and a
closed end point.
interval
- other intervalpublic AbsoluteDateInterval mergeTo(AbsoluteDateInterval interval)
To be merged, the two intervals must overlap or be connected. If that is not the case, the
method returns null
.
interval
- the interval to be mergedpublic AbsoluteDateInterval getIntersectionWith(AbsoluteDateInterval interval)
If the intervals do not overlap, the method returns null.
interval
- the interval to be intersectedpublic AbsoluteDateInterval shift(double shift)
shift
- the shift applied to the lower and the upper bounds (in seconds)public AbsoluteDateInterval shift(double lowerShift, double upperShift)
lowerShift
- the shift applied to the lower bound (in seconds)upperShift
- the shift applied to the upper bound (in seconds)public AbsoluteDateInterval scale(double scalingFactor)
scalingFactor
- the scaling factorpublic AbsoluteDateInterval scale(double scalingFactor, AbsoluteDate epoch)
scalingFactor
- the scaling factorepoch
- the epoch of referencepublic AbsoluteDateInterval extendTo(AbsoluteDate epoch)
extendTo
in class ComparableInterval<AbsoluteDate>
epoch
- the target valuepublic String toString(AbsoluteDate date)
date
- the reference dateCopyright © 2019 CNES. All Rights Reserved.