public class DateRange extends Object
org.apache.cassandra.db.marshal.DateRangeType,
corresponding to the Apache Solr type
DateRangeField.
A date range can be either single-bounded, in which case it represents
a unique instant (e.g. "2001-01-01"), or
double-bounded,
in which case it represents an interval of time (e.g. "[2001-01-01 TO 2002]").
Date range bounds are always inclusive;
they must be either valid dates,
or the special value UNBOUNDED, represented
by a "*", e.g. "[2001 TO *]".
DateRange instances can be more easily created with the
parse(String) method.
DateRange instances are immutable and thread-safe.| Modifier and Type | Class and Description |
|---|---|
static class |
DateRange.DateRangeBound
A date range bound.
|
| Constructor and Description |
|---|
DateRange(DateRange.DateRangeBound singleBound)
Creates a "single bounded"
DateRange instance, i.e., a date range whose upper and lower
bounds are identical. |
DateRange(DateRange.DateRangeBound lowerBound,
DateRange.DateRangeBound upperBound)
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
DateRange.DateRangeBound |
getLowerBound()
Returns the lower
bound of this range (inclusive). |
DateRange.DateRangeBound |
getUpperBound()
Returns the upper
bound of this range (inclusive). |
int |
hashCode() |
boolean |
isSingleBounded()
Returns
true if this DateRange is
a single-bounded range,
and false if it is a
double-bounded range. |
static DateRange |
parse(String source)
Parses the given string as a
DateRange. |
String |
toString()
Returns the string representation of this range, in a format compatible with
Apache Solr DateRageField syntax
|
public DateRange(DateRange.DateRangeBound singleBound)
DateRange instance, i.e., a date range whose upper and lower
bounds are identical.singleBound - the single bound of this range; must not be null.public DateRange(DateRange.DateRangeBound lowerBound, DateRange.DateRangeBound upperBound)
lowerBound - the lower bound of this range (inclusive); must not be null.upperBound - the upper bound of this range (inclusive); must not be null.IllegalArgumentException - if lowerBound is null, if upperBound is null,
or if both lowerBound and upperBound are not unbounded and
lowerBound is greater than upperBound.public static DateRange parse(String source) throws ParseException
DateRange.
The given input must be compliant with Apache Solr type
DateRangeField syntax;
it can either be a single-bounded range,
or a double-bounded range.source - The string to parse.DateRange object.ParseException - if the given string could not be parsed into a valid DateRange.DateRange.DateRangeBound.parseLowerBound(String),
DateRange.DateRangeBound.parseUpperBound(String)public DateRange.DateRangeBound getLowerBound()
bound of this range (inclusive).bound of this range (inclusive).public DateRange.DateRangeBound getUpperBound()
bound of this range (inclusive).
This method returns null for single-bounded ranges
created via DateRange(DateRangeBound).bound of this range (inclusive).public boolean isSingleBounded()
true if this DateRange is
a single-bounded range,
and false if it is a
double-bounded range.true if this DateRange is a
single-bounded range, false otherwise.public String toString()
toString in class ObjectDateRange.DateRangeBound.toString()Copyright © 2012–2018. All rights reserved.