org.geotoolkit.util
Class DateRange

Object
  extended by Range
      extended by Range<Date>
          extended by DateRange
All Implemented Interfaces:
Serializable, Formattable, CheckedContainer

@Immutable
public class DateRange
extends Range<Date>

A range of dates. The elements in this range are Date objects. Consequently the precision of DateRange objects is milliseconds.

Since:
2.5
Version:
3.20
Author:
Martin Desruisseaux (Geomatys)
See Also:
RangeFormat, Serialized Form
Module:
utility/geotk-utility (download)    View source code for this class

Constructor Summary
DateRange(Date startTime, boolean isMinIncluded, Date endTime, boolean isMaxIncluded)
          Creates a new date range for the given dates.
DateRange(Date startTime, Date endTime)
          Creates a new date range for the given dates.
DateRange(MeasurementRange<?> range, Date origin)
          Creates a date range from the specified measurement range.
 
Method Summary
 Date getMaxValue()
          Returns the end time.
 Date getMinValue()
          Returns the start time.
 DateRange intersect(Range<?> range)
          Returns the intersection between this range and the provided range.
 DateRange[] subtract(Range<?> range)
          Returns the range of values that are in this range but not in the given range.
 DateRange union(Range<?> range)
          Returns the union of this range with the given range.
 
Methods inherited from class Range
contains, contains, equals, getElementType, hashCode, intersects, isMaxIncluded, isMinIncluded, toString
 
Methods inherited from class Range
contains, formatTo, intersect, intersects, isEmpty, subtract, union
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DateRange

public DateRange(Date startTime,
                 Date endTime)
Creates a new date range for the given dates. Start time and end time are inclusive.

Parameters:
startTime - The start time (inclusive), or null if none.
endTime - The end time (inclusive), or null if none.

DateRange

public DateRange(Date startTime,
                 boolean isMinIncluded,
                 Date endTime,
                 boolean isMaxIncluded)
Creates a new date range for the given dates.

Parameters:
startTime - The start time, or null if none.
isMinIncluded - true if the start time is inclusive.
endTime - The end time, or null if none.
isMaxIncluded - true if the end time is inclusive.

DateRange

public DateRange(MeasurementRange<?> range,
                 Date origin)
          throws ConversionException
Creates a date range from the specified measurement range. Units are converted as needed.

Parameters:
range - The range to convert.
origin - The date to use as the origin.
Throws:
ConversionException - if the given range doesn't have a unit compatible with milliseconds.
Method Detail

getMinValue

public Date getMinValue()
Returns the start time.

Overrides:
getMinValue in class Range<Date>
Returns:
The minimal value.
See Also:
Range.getMinValue()

getMaxValue

public Date getMaxValue()
Returns the end time.

Overrides:
getMaxValue in class Range<Date>
Returns:
The maximal value.
See Also:
Range.getMaxValue()

union

public DateRange union(Range<?> range)
                throws IllegalArgumentException
Returns the union of this range with the given range.

Overrides:
union in class Range<Date>
Parameters:
range - The range to add to this range.
Returns:
The union of this range with the given range.
Throws:
IllegalArgumentException - is the given range can not be converted to a valid type through widening conversion, or if the units of measurement are not convertible.
Since:
3.20
See Also:
Range.union(javax.media.jai.util.Range)

intersect

public DateRange intersect(Range<?> range)
                    throws IllegalArgumentException
Returns the intersection between this range and the provided range.

Overrides:
intersect in class Range<Date>
Parameters:
range - The range to intersect.
Returns:
The intersection of this range with the provided range.
Throws:
IllegalArgumentException - is the given range can not be converted to a valid type through widening conversion, or if the units of measurement are not convertible.
Since:
3.20
See Also:
Range.intersect(javax.media.jai.util.Range)

subtract

public DateRange[] subtract(Range<?> range)
                     throws IllegalArgumentException
Returns the range of values that are in this range but not in the given range. This method returns an array of length 0, 1 or 2:

Overrides:
subtract in class Range<Date>
Parameters:
range - The range to subtract.
Returns:
This range without the given range.
Throws:
IllegalArgumentException - is the given range can not be converted to a valid type through widening conversion, or if the units of measurement are not convertible.
Since:
3.20
See Also:
Range.subtract(javax.media.jai.util.Range)


Copyright © 2009-2013 Geotoolkit.org. All Rights Reserved.