org.geotoolkit.util
Class Range<T extends Comparable<? super T>>

Object
  extended by Range
      extended by Range<T>
Type Parameters:
T - The type of range elements, typically Date or some subclass of Number.
All Implemented Interfaces:
Serializable, Formattable, CheckedContainer
Direct Known Subclasses:
DateRange, NumberRange

Deprecated. Moved to Apache SIS Range.

@Immutable
@Deprecated
public class Range<T extends Comparable<? super T>>
extends Range
implements CheckedContainer<T>, Serializable

A range between a minimum and maximum comparable. The minimum/maximum may be included, excluded or unbounded. The later case is indicated by null values on one or both ends.

This class is a method compatible replacement for the Java Advanced Imaging Range class with the following differences:

The exact element class doesn't need to be known at compile time. Widening conversions are allowed as needed (subclasses like NumberRange do that). This class is weakly parameterized in order to allow this flexibility. If any constructor or method is invoked with an argument value of illegal class, then an IllegalArgumentException is thrown. The ClassCastException is thrown only in case of bug in the Range class or subclasses implementation.

The string representation of a Range is defined in a locale-insensitive way. In order to format a range using the current locale, or for parsing a range, use RangeFormat.

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

Constructor Summary
Range(Class<T> elementClass, T value)
          Deprecated. Creates a new range bounded by a single inclusive value.
Range(Class<T> elementClass, T minValue, boolean isMinIncluded, T maxValue, boolean isMaxIncluded)
          Deprecated. Creates a new range bounded by the given values.
Range(Class<T> elementClass, T minValue, T maxValue)
          Deprecated. Creates a new range bounded by the given inclusive values.
 
Method Summary
 boolean contains(Comparable value)
          Deprecated. Returns true if this range contains the given value.
 boolean contains(Range<?> range)
          Deprecated. Returns true if the supplied range is fully contained within this range.
 boolean equals(Object object)
          Deprecated. Compares this range with the given object for equality.
 Class<T> getElementType()
          Deprecated. Returns the class of elements in this range.
 T getMaxValue()
          Deprecated. Returns the maximal value, or null if unbounded.
 T getMinValue()
          Deprecated. Returns the minimal value, or null if unbounded.
 int hashCode()
          Deprecated. Returns a hash code value for this range.
 Range<?> intersect(Range<?> range)
          Deprecated. Returns the intersection between this range and the provided range.
 boolean intersects(Range<?> range)
          Deprecated. Returns true if this range intersects the given range.
 boolean isMaxIncluded()
          Deprecated. Indicates if getMaxValue() is included in the range.
 boolean isMinIncluded()
          Deprecated. Indicates if getMinValue() is included in the range.
 Range<?>[] subtract(Range<?> range)
          Deprecated. Returns the range of values that are in this range but not in the given range.
 String toString()
          Deprecated. Returns a string representation of this range.
 Range<?> union(Range<?> range)
          Deprecated. Returns the union of this range with the given range.
 
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

Range

public Range(Class<T> elementClass,
             T value)
Deprecated. 
Creates a new range bounded by a single inclusive value. The minimum and maximum values are set to the given one.

Parameters:
elementClass - The class of the range elements.
value - The minimal and maximum value (inclusive), or null for an unbounded range.

Range

public Range(Class<T> elementClass,
             T minValue,
             T maxValue)
Deprecated. 
Creates a new range bounded by the given inclusive values.

Parameters:
elementClass - The class of the range elements.
minValue - The minimal value (inclusive), or null if none.
maxValue - The maximal value (inclusive), or null if none.

Range

public Range(Class<T> elementClass,
             T minValue,
             boolean isMinIncluded,
             T maxValue,
             boolean isMaxIncluded)
Deprecated. 
Creates a new range bounded by the given values.

Parameters:
elementClass - The class of the range elements.
minValue - The minimal value, or null if none.
isMinIncluded - true if the minimal value is inclusive, or false if exclusive.
maxValue - The maximal value, or null if none.
isMaxIncluded - true if the maximal value is inclusive, or false if exclusive.
Method Detail

getElementType

public Class<T> getElementType()
Deprecated. 
Returns the class of elements in this range. The element class extends Comparable.

Specified by:
getElementType in interface CheckedContainer
Overrides:
getElementType in class Range
Returns:
The class of elements in this range.
Since:
3.20 (derived from 2.5)
See Also:
Range.getElementClass()

getMinValue

public T getMinValue()
Deprecated. 
Returns the minimal value, or null if unbounded. If isMinIncluded is true, then the value is considered included in the set. Otherwise it is considered excluded.

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

isMinIncluded

public boolean isMinIncluded()
Deprecated. 
Indicates if getMinValue() is included in the range.

Overrides:
isMinIncluded in class Range
Returns:
true if the minimal value is inclusive.
See Also:
Range.isMinIncluded

getMaxValue

public T getMaxValue()
Deprecated. 
Returns the maximal value, or null if unbounded. If isMaxIncluded is true, then the value is considered included in the set. Otherwise it is considered excluded.

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

isMaxIncluded

public boolean isMaxIncluded()
Deprecated. 
Indicates if getMaxValue() is included in the range.

Overrides:
isMaxIncluded in class Range
Returns:
true if the maximal value is inclusive.
See Also:
Range.isMaxIncluded

contains

public boolean contains(Comparable value)
                 throws IllegalArgumentException
Deprecated. 
Returns true if this range contains the given value. A range never contains the null value. This is consistent with the class javadoc stating that null minimum or maximum values are exclusive.

Overrides:
contains in class Range
Parameters:
value - The value to check for inclusion in this range.
Returns:
true if the given value is included in this range.
Throws:
IllegalArgumentException - is the given value can not be converted to a valid type through widening conversion.

contains

public boolean contains(Range<?> range)
                 throws IllegalArgumentException
Deprecated. 
Returns true if the supplied range is fully contained within this range.

Parameters:
range - The range to check for inclusion in this range.
Returns:
true if the given range is included in this 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.

intersects

public boolean intersects(Range<?> range)
                   throws IllegalArgumentException
Deprecated. 
Returns true if this range intersects the given range.

Parameters:
range - The range to check for intersection with this range.
Returns:
true if the given range intersects this 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.
See Also:
Range.intersects(javax.media.jai.util.Range)

intersect

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

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.
See Also:
Range.intersect(javax.media.jai.util.Range)

subtract

public Range<?>[] subtract(Range<?> range)
                    throws IllegalArgumentException
Deprecated. 
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:

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.
See Also:
Range.subtract(javax.media.jai.util.Range)

union

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

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.
See Also:
Range.union(javax.media.jai.util.Range)

equals

public boolean equals(Object object)
Deprecated. 
Compares this range with the given object for equality.

Overrides:
equals in class Range
Parameters:
object - The object to compare with this range for equality.
Returns:
true if the given object is equal to this range.

hashCode

public int hashCode()
Deprecated. 
Returns a hash code value for this range.

Overrides:
hashCode in class Range

toString

public String toString()
Deprecated. 
Returns a string representation of this range. The string representation is defined as below:

If this range is a MeasurementRange, then the unit of measurement is appended to the above string representation.

Overrides:
toString in class Range
See Also:
RangeFormat


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