| java.lang.Object javax.media.jai.util.Range
Range | public class Range implements Serializable(Code) | | A class to represent ranges of values. A range is defined to contain
all the values between the minimum and maximum values, where
the minimum/maximum value can be considered either included or excluded
from the range.
This example creates a range of Integer s whose minimum
value is 1 and the maximum value is 5. The range is inclusive at both
ends:
Range intRange = new Range(Integer.class, new Integer(1), new Integer(5));
A Range can be unbounded at either or both of its ends.
An unbounded end is specified by passing null for the value of that end.
A Range unbounded at both of its ends represents a range of
all possible values for the Class of elements in that
Range . The isMinIncluded() method will always
return true for a Range unbounded on the minimum side and
correspondingly the isMaxIncluded() method will always
return true for a Range unbounded on the maximum side.
An empty range is defined as a Range whose minimum value
is greater than it's maximum value if the ends are included, or as a
Range whose minimum value is greater than or equal to it's
maximum value, if the minimum or the maximum value is excluded.
since: JAI 1.1 |
Constructor Summary | |
public | Range(Class elementClass, Comparable minValue, Comparable maxValue) Constructs a Range object given the Class
of the elements in the Range , the minimum value and
the maximum value. | public | Range(Class elementClass, Comparable minValue, boolean isMinIncluded, Comparable maxValue, boolean isMaxIncluded) Constructs a Range object given the Class
of the elements in the Range , the minimum value and
the maximum value. |
Method Summary | |
public boolean | contains(Comparable value) Returns true if the specified value is within this Range ,
i.e. | public boolean | contains(Range range) Returns true if the supplied Range is fully contained
within this Range . | public boolean | equals(Object other) Returns true if this Range and the given
Range both have elements of the same Class ,
their minimum and maximum values are the same, and their isMinIncluded()
and isMaxIncluded() methods return the same values. | public Class | getElementClass() Returns the Class of the elements of this Range . | public Comparable | getMaxValue() Returns the maximum value of this Range . | public Comparable | getMinValue() Returns the minimum value of this Range . | public int | hashCode() Compute a hash code value for this Range object. | public Range | intersect(Range range) Returns the intersection of this Range with the
given Range . | public boolean | intersects(Range range) Returns true if this Range intersects the
given Range . | public boolean | isEmpty() Returns true if this Range is empty, i.e. | public boolean | isMaxIncluded() Returns true if the maximum value is included within this
Range . | public boolean | isMinIncluded() Returns true if the minimum value is included within this
Range . | public Range[] | subtract(Range range) Returns the Range of values that are in this
Range but not in the given Range . | public String | toString() Returns a String representation of this Range . | public Range | union(Range range) Returns the union of this Range with the given
Range . |
Range | public Range(Class elementClass, Comparable minValue, Comparable maxValue)(Code) | | Constructs a Range object given the Class
of the elements in the Range , the minimum value and
the maximum value. The minimum and the maximum value are considered
inclusive.
An unbounded range can be specified by passing in a null for
either of the two values, in which case the Range is
unbounded on one side, or for both, in which case the
Range represents an all inclusive set.
Parameters: elementClass - The Class of the Range elements. Parameters: minValue - The lowest value included in the Range . Parameters: maxValue - The highest value included in the Range . throws: IllegalArgumentException - if minValue and maxValue are both null,and elementClass is not one of the subclasses of Comparable . throws: IllegalArgumentException - if minValue is not the same Class as elementClass. throws: IllegalArgumentException - if maxValue is not the same Class as elementClass. |
Range | public Range(Class elementClass, Comparable minValue, boolean isMinIncluded, Comparable maxValue, boolean isMaxIncluded)(Code) | | Constructs a Range object given the Class
of the elements in the Range , the minimum value and
the maximum value. Whether the minimum value and the maximum value
are considered inclusive is specified via the
isMinIncluded and isMaxIncluded variables.
An unbounded range can be specified by passing in a null for
either of the two values, in which case the Range is
unbounded at one end, or for both, in which case the
Range represents an all inclusive set. If null is passed
in for either variable, the boolean variables have
no effect.
Parameters: elementClass - The Class of the Range elements. Parameters: minValue - The lowest value for the Range . Parameters: isMinIncluded - A boolean that defines whether the minimum value isincluded in the Range . Parameters: maxValue - The highest value for the Range . Parameters: isMaxIncluded - A boolean that defines whether the maximum value isincluded in the Range . throws: IllegalArgumentException - if minValue and maxValue are both null,and elementClass is not one of thesubclasses of Comparable . throws: IllegalArgumentException - if minValue is not the same Class as elementClass. throws: IllegalArgumentException - if maxValue is not the same Class as elementClass. |
contains | public boolean contains(Comparable value)(Code) | | Returns true if the specified value is within this Range ,
i.e. is either equal to or greater than the minimum value of this
Range and is either lesser than or equal to the maximum
value of this Range .
Parameters: value - The value to be checked for being within this Range . throws: IllegalArgumentException - if the Class of the valueparameter is not the same as the elementClass of this Range . |
contains | public boolean contains(Range range)(Code) | | Returns true if the supplied Range is fully contained
within this Range . Fully contained is defined as having
the minimum and maximum values of the fully contained range lie
within the range of values of the containing Range .
throws: IllegalArgumentException - if the Class of theelements of the given Range is not the same as the Class of the elements of this Range . throws: IllegalArgumentException - if the given Range is null |
equals | public boolean equals(Object other)(Code) | | Returns true if this Range and the given
Range both have elements of the same Class ,
their minimum and maximum values are the same, and their isMinIncluded()
and isMaxIncluded() methods return the same values.
If this Range and the given Range are both
empty and the Class of their elements is the same, they
will be found to be equal and true will be returned.
|
getElementClass | public Class getElementClass()(Code) | | Returns the Class of the elements of this Range .
|
getMaxValue | public Comparable getMaxValue()(Code) | | Returns the maximum value of this Range .
Returns null if the Range is unbounded at this end.
|
getMinValue | public Comparable getMinValue()(Code) | | Returns the minimum value of this Range .
Returns null if the Range is unbounded at this end.
|
hashCode | public int hashCode()(Code) | | Compute a hash code value for this Range object.
a hash code value for this Range object. |
intersects | public boolean intersects(Range range)(Code) | | Returns true if this Range intersects the
given Range .
throws: IllegalArgumentException - if the Class of theelements of the given Range is not the same as the Class of the elements of this Range . throws: IllegalArgumentException - if the given Range is null |
isEmpty | public boolean isEmpty()(Code) | | Returns true if this Range is empty, i.e. if the minimum
value is greater than the maximum value, if both are included, or if
the minimum value is greater than equal to the maximum value if either
the minimum or maximum value is excluded.
|
isMaxIncluded | public boolean isMaxIncluded()(Code) | | Returns true if the maximum value is included within this
Range . If the range is unbounded at this end, this
method will return true.
|
isMinIncluded | public boolean isMinIncluded()(Code) | | Returns true if the minimum value is included within this
Range . If the range is unbounded at this end, this
method will return true.
|
subtract | public Range[] subtract(Range range)(Code) | | Returns the Range of values that are in this
Range but not in the given Range . If
the subtraction results in two disjoint Range s, they
will be returned as two elements of a Range array,
otherwise the resultant Range will be returned as the
first element of a one element array.
When this Range and the given Range are
both unbounded at both the ends (i.e both the Range s
are all inclusive), this method will return null as the first
element of one element array, as a result of the subtraction.
When this Range is completely contained in the
given Range , an empty Range is returned.
throws: IllegalArgumentException - if the Class of theelements of the given Range is not the same as the Class of the elements of this Range . |
toString | public String toString()(Code) | | Returns a String representation of this Range .
|
union | public Range union(Range range)(Code) | | Returns the union of this Range with the given
Range . If this Range and the given
Range are disjoint, the Range returned
as a result of the union will have a minimum value set to the
minimum of the two disjoint range's minimum values, and the maximum
set to the maximum of the two disjoint range's maximum values, thus
including the disjoint range within it.
throws: IllegalArgumentException - if the Class of theelements of the given Range is not the same as the Class of the elements of this Range . throws: IllegalArgumentException - if the given Range is null |
|
|