|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.media.jai.util.Range
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.
Constructor Summary | |
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. |
|
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. |
Method Summary | |
boolean |
contains(Comparable value)
Returns true if the specified value is within this Range ,
i.e. |
boolean |
contains(Range range)
Returns true if the supplied Range is fully contained
within this Range . |
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. |
Class |
getElementClass()
Returns the Class of the elements of this Range . |
Comparable |
getMaxValue()
Returns the maximum value of this Range . |
Comparable |
getMinValue()
Returns the minimum value of this Range . |
int |
hashCode()
Compute a hash code value for this Range object. |
Range |
intersect(Range range)
Returns the intersection of this Range with the
given Range . |
boolean |
intersects(Range range)
Returns true if this Range intersects the
given Range . |
boolean |
isEmpty()
Returns true if this Range is empty, i.e. |
boolean |
isMaxIncluded()
Returns true if the maximum value is included within this Range . |
boolean |
isMinIncluded()
Returns true if the minimum value is included within this Range . |
Range[] |
subtract(Range range)
Returns the Range of values that are in this
Range but not in the given Range . |
String |
toString()
Returns a String representation of this Range . |
Range |
union(Range range)
Returns the union of this Range with the given
Range . |
Methods inherited from class java.lang.Object |
clone,
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public Range(Class elementClass, Comparable minValue, Comparable maxValue)
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.
elementClass
- The Class
of the Range
elements.minValue
- The lowest value included in the Range
.maxValue
- The highest value included in the Range
.Comparable
.Class
as elementClass.Class
as elementClass.public Range(Class elementClass, Comparable minValue, boolean isMinIncluded, Comparable maxValue, boolean isMaxIncluded)
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.
elementClass
- The Class
of the Range
elements.minValue
- The lowest value for the Range
.isMinIncluded
- A boolean that defines whether the minimum value is
included in the Range
.maxValue
- The highest value for the Range
.isMaxIncluded
- A boolean that defines whether the maximum value is
included in the Range
.Comparable
.Class
as elementClass.Class
as elementClass.Method Detail |
public boolean isMinIncluded()
Range
. If the range is unbounded at this end, this
method will return true.public boolean isMaxIncluded()
Range
. If the range is unbounded at this end, this
method will return true.public Class getElementClass()
Class
of the elements of this Range
.public Comparable getMinValue()
Range
.
Returns null if the Range
is unbounded at this end.public Comparable getMaxValue()
Range
.
Returns null if the Range
is unbounded at this end.public boolean contains(Comparable value)
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
.value
- The value to be checked for being within this
Range
.Class
of the value
parameter is not the same as the elementClass of this Range
.public boolean contains(Range range)
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
.Class
of the
elements of the given Range
is not the same as the
Class
of the elements of this Range
.Range
is nullpublic boolean intersects(Range range)
Range
intersects the
given Range
.Class
of the
elements of the given Range
is not the same as the
Class
of the elements of this Range
.Range
is nullpublic Range union(Range range)
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.Class
of the
elements of the given Range
is not the same as the
Class
of the elements of this Range
.Range
is nullpublic Range intersect(Range range)
Range
with the
given Range
.Class
of the
elements of the given Range
is not the same as the
Class
of the elements of this Range
.Range
is nullpublic Range[] subtract(Range range)
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.Class
of the
elements of the given Range
is not the same as the
Class
of the elements of this Range
.public int hashCode()
Range
object.Range
object.public boolean equals(Object other)
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.public boolean isEmpty()
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.public String toString()
String
representation of this Range
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |