public class DateRangeSet extends Object
Constructor and Description |
---|
DateRangeSet(DateRange cs)
Constructs a new DateRangeSet with the initial set containing
only the specified DateRange
|
Modifier and Type | Method and Description |
---|---|
boolean |
inRange(Date val)
Consider a set of ranges A, B added as a union
(logical or) and ranges C and D added as an
intersection (logical and).
|
void |
intersection(DateRange r)
Adds the specified range as an intersection to the existing
ranges (for purposes of
inRange(char) method). |
static void |
main(String[] args) |
String |
toString() |
void |
union(DateRange r)
Adds this specified range as a union to the existing set of
ranges (for purposes of
inRange(char) method). |
public DateRangeSet(DateRange cs)
cs
- the initial DateRangepublic void union(DateRange r)
inRange(char)
method).
Overlapping ranges are ok.cs
- a DateRange to unite withIllegalArgumentException
- if the specified range was nullpublic void intersection(DateRange r)
inRange(char)
method).
Overlapping ranges are ok.r
- the range to addpublic boolean inRange(Date val)
(A.inRange(c) || B.inRange(c) || ...) && C.inRange(c) && D.inRange(c) && ...This can be generalized to an arbitrary number of sub ranges. If intersection or union ranges don't exist, then they are not considered in the above expression. Note, the interaction may be subtle if any of the ranges (A, B, C...etc) are individually negated because in that case the inRange method for that negated range would return true if the specified character was not in that range.