public class Range extends Object implements Iterable<TimeIndex>
TimeDomain
. A range can be empty.
When not empty, both ends of the interval are well-defined. Open intervals
and semi-open intervals are not supported.
A Range is an immutable object.
Modifier and Type | Class and Description |
---|---|
class |
Range.RangeIterator
RangeIterator is a
Iterator return TimeIndex objects. |
Constructor and Description |
---|
Range(Range range)
Construct a range as a copy of the argument.
|
Range(TimeDomain domain)
Construct an empty range.
|
Range(TimeDomain domain,
long first,
long last)
Construct a range with bounds specified with numerical time indexes,.
|
Range(TimeDomain domain,
String firstDate,
String lastDate,
Adjustment adjust)
Construct a range with bounds specified as date strings.
|
Range(TimeIndex first,
TimeIndex last)
Construct a range with bounds specified as times.
|
Modifier and Type | Method and Description |
---|---|
Range |
convert(TimeDomain domain,
Adjustment adjust)
Convert the range to the domain specified.
|
boolean |
equals(Object obj) |
TimeIndex |
getFirst()
Return the lower bound as a time or null when the range is empty.
|
long |
getFirstIndex()
Return the lower bound as a numerical time index.
|
TimeIndex |
getLast()
r
Return the upper bound as a time o null when the range is empty.
|
long |
getLastIndex()
Return the upper bound as a numerical time index.
|
long |
getSize()
Return the range size.
|
int |
getSizeAsInt()
Get the size of the range as an integer and check for overflow.
|
TimeDomain |
getTimeDomain()
Return the time domain.
|
int |
hashCode() |
Range |
intersection(Range range)
Return a new range which is the intersection with the argument.
|
boolean |
isEmpty()
Return true if the range is empty, else false.
|
boolean |
isInRange(long index)
Return true if the numerical time index is within range.
|
boolean |
isInRange(Range range)
Return true if another range is within range.
|
boolean |
isInRange(TimeIndex time)
Return true if the time is within range.
|
Iterator<TimeIndex> |
iterator() |
String |
toString() |
Range |
union(Range range)
Return a new range which is the union with the argument.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public Range(TimeDomain domain)
domain
- a non null domainpublic Range(Range range)
range
- a non-null rangepublic Range(TimeDomain domain, long first, long last)
domain
- a non-null domainfirst
- the lower boundlast
- the upper boundT2Exception
public Range(TimeIndex first, TimeIndex last) throws T2Exception
first
- a non-null lower boundlast
- a non-null upper boundT2Exception
public Range(TimeDomain domain, String firstDate, String lastDate, Adjustment adjust) throws T2Exception
Specifying a first bound past the second results in an empty range.
domain
- a non-null domainfirstDate
- a non-null lower boundlastDate
- a non-null upper boundadjust
- a non-null adjustment modeT2Exception
public Range convert(TimeDomain domain, Adjustment adjust) throws T2Exception
If the domain is the same, returns this range, else a new range is created.
domain
- a non-null domainadjust
- a non-null adjustment modeT2Exception
public long getFirstIndex()
public long getLastIndex()
public int getSizeAsInt() throws T2Exception
T2Exception
public long getSize()
public TimeDomain getTimeDomain()
public boolean isEmpty()
public boolean isInRange(long index)
index
- a numerical time indexpublic boolean isInRange(TimeIndex time) throws T2Exception
time
- a non-null timeT2Exception
public boolean isInRange(Range range) throws T2Exception
range
- a non-null rangeT2Exception
public TimeIndex getFirst()
public TimeIndex getLast()
public Range union(Range range) throws T2Exception
range
- a non-null rangeT2Exception
public Range intersection(Range range) throws T2Exception
range
- a non-null rangeT2Exception
Copyright © 2017. All rights reserved.