|
TopoWeb Commons API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.topoweb.util.Range
Encapsulates a semi-open range of comparable objects. This class introduces
the abstraction that a null
compares greater than any other
object.
Once an instance is created, other objects can be inspected to
see whether they are contained by the range using the
instance's contains(Object)
method.
Constructor Summary | |
Range(java.lang.Object lo,
java.lang.Object hi,
java.util.Comparator comparator)
Creates a new instance with the specified bounds and
comparator . |
Method Summary | |
boolean |
contains(java.lang.Object obj)
Tests whether this instance contains the given object. |
java.util.Comparator |
getComparator()
Returns this instance's comparator or null , if the range
is defined by the natural ordering of the bounds of
this instance. |
java.lang.Object |
getHi()
Returns the exclusive upper bound for this range. |
java.lang.Object |
getLo()
Returns the inclusive lower bound for this range. |
int |
outcode(java.lang.Object obj)
Returns an outcode indicating the ordering of the given object relative to this instance. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Range(java.lang.Object lo, java.lang.Object hi, java.util.Comparator comparator) throws java.lang.ClassCastException, java.lang.IllegalArgumentException
comparator
. The value null
represents the largest
possible comparable object. If the comparator
is
null
, then the parameters lo
and hi
are taken to implement java.lang.Comparable
(unless
hi
is null
) and the natural ordering of the
bounds are used to define the range.
lo
- the inclusive lower bound for this rangehi
- the exclusive upper bound for this range, or
null
to indicate the highest
possible upper boundcomparator
- the comparator defining the ordering, or
null
to indicate the natural
ordering
java.lang.IllegalArgumentException
- if lo
is null
;
if lo
<= hi
(with
the value null
taking on the
highest possible value
java.lang.ClassCastException
- if either lo
or a non-null
hi
do not implement the
java.lang.Comparable
interface;
if thrown by either the comparator
, or by lo.compareTo(hi)
throws this exceptionMethod Detail |
public final boolean contains(java.lang.Object obj)
obj
- the object inspected
true
if the instance contains
obj
; false
, o.w.public final int outcode(java.lang.Object obj) throws java.lang.ClassCastException
obj
- the object inspected
obj
is to the left of
this range; 0, if obj
is inside
(contained) by this range; 1, o.w.
java.lang.ClassCastException
public final java.lang.Object getLo()
null
.
public final java.lang.Object getHi()
null
represents the largest possible bound.
public final java.util.Comparator getComparator()
null
, if the range
is defined by the natural ordering of the bounds of
this instance.
null
if naturally ordered.
|
TopoWeb Commons API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |