org.geotools.util
Class NumberRange

java.lang.Object
  extended byjavax.media.jai.util.Range
      extended byorg.geotools.util.NumberRange
All Implemented Interfaces:
java.io.Serializable

public class NumberRange
extends javax.media.jai.util.Range

A range of numbers. Union and intersection are computed as usual, except that widening conversions will be applied as needed.

Version:
$Id: NumberRange.java 13063 2005-04-12 05:34:22Z desruisseaux $
Author:
Martin Desruisseaux
See Also:
Serialized Form

Constructor Summary
NumberRange(byte minimum, boolean isMinIncluded, byte maximum, boolean isMaxIncluded)
          Construct a range of byte values.
NumberRange(byte minimum, byte maximum)
          Construct an inclusive range of byte values.
NumberRange(java.lang.Class classe, java.lang.Number minimum, boolean isMinIncluded, java.lang.Number maximum, boolean isMaxIncluded)
          Construct a range of Number objects.
NumberRange(java.lang.Class classe, java.lang.Number minimum, java.lang.Number maximum)
          Construct an inclusive range of Number objects.
NumberRange(double minimum, boolean isMinIncluded, double maximum, boolean isMaxIncluded)
          Construct a range of double values.
NumberRange(double minimum, double maximum)
          Construct an inclusive range of double values.
NumberRange(float minimum, boolean isMinIncluded, float maximum, boolean isMaxIncluded)
          Construct a range of float values.
NumberRange(float minimum, float maximum)
          Construct an inclusive range of float values.
NumberRange(int minimum, boolean isMinIncluded, int maximum, boolean isMaxIncluded)
          Construct a range of int values.
NumberRange(int minimum, int maximum)
          Construct an inclusive range of int values.
NumberRange(long minimum, boolean isMinIncluded, long maximum, boolean isMaxIncluded)
          Construct a range of long values.
NumberRange(long minimum, long maximum)
          Construct an inclusive range of long values.
NumberRange(short minimum, boolean isMinIncluded, short maximum, boolean isMaxIncluded)
          Construct a range of short values.
NumberRange(short minimum, short maximum)
          Construct an inclusive range of short values.
 
Method Summary
 NumberRange castTo(java.lang.Class type)
          Cast this range to the specified type.
 boolean contains(java.lang.Comparable value)
          Returns true if the specified value is within this range.
 boolean contains(java.lang.Number value)
          Returns true if the specified value is within this range.
 boolean contains(javax.media.jai.util.Range range)
          Returns true if the supplied range is fully contained within this range.
 double getMaximum()
          Returns the maximum value as a double.
 double getMaximum(boolean inclusive)
          Returns the maximum value with the specified inclusive or exclusive state.
 double getMinimum()
          Returns the minimum value as a double.
 double getMinimum(boolean inclusive)
          Returns the minimum value with the specified inclusive or exclusive state.
 javax.media.jai.util.Range intersect(javax.media.jai.util.Range range)
          Returns the intersection of this range with the given range.
 boolean intersects(javax.media.jai.util.Range range)
          Returns true if this range intersects the given range.
 javax.media.jai.util.Range[] subtract(javax.media.jai.util.Range range)
          Returns the range of values that are in this range but not in the given range.
 javax.media.jai.util.Range union(javax.media.jai.util.Range range)
          Returns the union of this range with the given range.
static NumberRange wrap(javax.media.jai.util.Range range)
          Wrap the specified Range in a NumberRange object.
 
Methods inherited from class javax.media.jai.util.Range
equals, getElementClass, getMaxValue, getMinValue, hashCode, isEmpty, isMaxIncluded, isMinIncluded, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NumberRange

public NumberRange(byte minimum,
                   byte maximum)
Construct an inclusive range of byte values.

Parameters:
minimum - The minimum value, inclusive.
maximum - The maximum value, inclusive.

NumberRange

public NumberRange(byte minimum,
                   boolean isMinIncluded,
                   byte maximum,
                   boolean isMaxIncluded)
Construct a range of byte values.

Parameters:
minimum - The minimum value.
isMinIncluded - Defines whether the minimum value is included in the Range.
maximum - The maximum value.
isMaxIncluded - Defines whether the maximum value is included in the Range.

NumberRange

public NumberRange(short minimum,
                   short maximum)
Construct an inclusive range of short values.

Parameters:
minimum - The minimum value, inclusive.
maximum - The maximum value, inclusive.

NumberRange

public NumberRange(short minimum,
                   boolean isMinIncluded,
                   short maximum,
                   boolean isMaxIncluded)
Construct a range of short values.

Parameters:
minimum - The minimum value.
isMinIncluded - Defines whether the minimum value is included in the Range.
maximum - The maximum value.
isMaxIncluded - Defines whether the maximum value is included in the Range.

NumberRange

public NumberRange(int minimum,
                   int maximum)
Construct an inclusive range of int values.

Parameters:
minimum - The minimum value, inclusive.
maximum - The maximum value, inclusive.

NumberRange

public NumberRange(int minimum,
                   boolean isMinIncluded,
                   int maximum,
                   boolean isMaxIncluded)
Construct a range of int values.

Parameters:
minimum - The minimum value.
isMinIncluded - Defines whether the minimum value is included in the Range.
maximum - The maximum value.
isMaxIncluded - Defines whether the maximum value is included in the Range.

NumberRange

public NumberRange(long minimum,
                   long maximum)
Construct an inclusive range of long values.

Parameters:
minimum - The minimum value, inclusive.
maximum - The maximum value, inclusive.

NumberRange

public NumberRange(long minimum,
                   boolean isMinIncluded,
                   long maximum,
                   boolean isMaxIncluded)
Construct a range of long values.

Parameters:
minimum - The minimum value.
isMinIncluded - Defines whether the minimum value is included in the Range.
maximum - The maximum value.
isMaxIncluded - Defines whether the maximum value is included in the Range.

NumberRange

public NumberRange(float minimum,
                   float maximum)
Construct an inclusive range of float values.

Parameters:
minimum - The minimum value, inclusive.
maximum - The maximum value, inclusive.

NumberRange

public NumberRange(float minimum,
                   boolean isMinIncluded,
                   float maximum,
                   boolean isMaxIncluded)
Construct a range of float values.

Parameters:
minimum - The minimum value.
isMinIncluded - Defines whether the minimum value is included in the Range.
maximum - The maximum value.
isMaxIncluded - Defines whether the maximum value is included in the Range.

NumberRange

public NumberRange(double minimum,
                   double maximum)
Construct an inclusive range of double values.

Parameters:
minimum - The minimum value, inclusive.
maximum - The maximum value, inclusive.

NumberRange

public NumberRange(double minimum,
                   boolean isMinIncluded,
                   double maximum,
                   boolean isMaxIncluded)
Construct a range of double values.

Parameters:
minimum - The minimum value.
isMinIncluded - Defines whether the minimum value is included in the Range.
maximum - The maximum value.
isMaxIncluded - Defines whether the maximum value is included in the Range.

NumberRange

public NumberRange(java.lang.Class classe,
                   java.lang.Number minimum,
                   java.lang.Number maximum)
Construct an inclusive range of Number objects.

Parameters:
classe - The element class, usually one of Byte, Short, Integer, Long, Float or Double.
minimum - The minimum value, inclusive.
maximum - The maximum value, inclusive.

NumberRange

public NumberRange(java.lang.Class classe,
                   java.lang.Number minimum,
                   boolean isMinIncluded,
                   java.lang.Number maximum,
                   boolean isMaxIncluded)
Construct a range of Number objects.

Parameters:
classe - The element class, usually one of Byte, Short, Integer, Long, Float or Double.
minimum - The minimum value.
isMinIncluded - Defines whether the minimum value is included in the Range.
maximum - The maximum value.
isMaxIncluded - Defines whether the maximum value is included in the Range.
Method Detail

wrap

public static NumberRange wrap(javax.media.jai.util.Range range)
Wrap the specified Range in a NumberRange object. If the specified range is already an instance of NumberRange, then it is returned unchanged.

Parameters:
range - The range to wrap
Returns:
The same range than range as a NumberRange object.

castTo

public NumberRange castTo(java.lang.Class type)
Cast this range to the specified type.

Parameters:
type - The class to cast to. Must be one of Byte, Short, Integer, Long, Float or Double.
Returns:
The casted range, or this if this range already uses the specified type.

contains

public boolean contains(java.lang.Comparable value)
Returns true if the specified value is within this range.


contains

public boolean contains(java.lang.Number value)
Returns true if the specified value is within this range.


contains

public boolean contains(javax.media.jai.util.Range range)
Returns true if the supplied range is fully contained within this range.


intersects

public boolean intersects(javax.media.jai.util.Range range)
Returns true if this range intersects the given range.


union

public javax.media.jai.util.Range union(javax.media.jai.util.Range range)
Returns the union of this range with the given range. Widening conversions will be applied as needed.

To Do:
The return type will be changed to NumberRange when J2SE 1.5 will be available. We should then search for NumberRange.warp(...) in all client classes; some 'warp' may no longer be needed.

intersect

public javax.media.jai.util.Range intersect(javax.media.jai.util.Range range)
Returns the intersection of this range with the given range. Widening conversions will be applied as needed.

To Do:
The return type will be changed to NumberRange when J2SE 1.5 will be available. We should then search for NumberRange.warp(...) in all client classes; some 'warp' may no longer be needed.

subtract

public javax.media.jai.util.Range[] subtract(javax.media.jai.util.Range range)
Returns the range of values that are in this range but not in the given range.


getMinimum

public double getMinimum()
Returns the minimum value as a double. If this range is unbounded, then Double.NEGATIVE_INFINITY is returned.


getMinimum

public double getMinimum(boolean inclusive)
Returns the minimum value with the specified inclusive or exclusive state. If this range is unbounded, then Double.NEGATIVE_INFINITY is returned.

Parameters:
inclusive - true for the minimum value inclusive, or false for the minimum value exclusive.
Returns:
The minimum value, inclusive or exclusive as requested.

getMaximum

public double getMaximum()
Returns the maximum value as a double. If this range is unbounded, then Double.POSITIVE_INFINITY is returned.


getMaximum

public double getMaximum(boolean inclusive)
Returns the maximum value with the specified inclusive or exclusive state. If this range is unbounded, then Double.POSITIVE_INFINITY is returned.

Parameters:
inclusive - true for the maximum value inclusive, or false for the maximum value exclusive.
Returns:
The maximum value, inclusive or exclusive as requested.


Copyright © GeoTools. All Rights Reserved.