net.spy.util
Class Range

java.lang.Object
  extended bynet.spy.util.Range
All Implemented Interfaces:
Comparable

public class Range
extends Object
implements Comparable

A range of Comparable objects.


Field Summary
static int EXCLUSIVE
          Match type for exclusive matches.
static int INCLUSIVE
          Match type for inclusive matches.
 
Constructor Summary
Range(Comparable lowObject, Comparable highObject)
          Get an instance of Range.
 
Method Summary
 int compareTo(Object o)
           
 boolean contains(Comparable c)
          True if the given object lies within this range.
 boolean equals(Object o)
          True if the given object is a Range object that represents the same range.
 Comparable getHigh()
          Get the high object.
 int getHighMatch()
          Get the high match type.
 Comparable getLow()
          Get the low object.
 int getLowMatch()
          Get the low match type.
 int hashCode()
          Get a predictable hash code.
 void setHighMatch(int hm)
          Set the high match type.
 void setLowMatch(int lm)
          Set the low match type.
 String toString()
          Describe this object in Set notation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

INCLUSIVE

public static final int INCLUSIVE
Match type for inclusive matches.

See Also:
Constant Field Values

EXCLUSIVE

public static final int EXCLUSIVE
Match type for exclusive matches.

See Also:
Constant Field Values
Constructor Detail

Range

public Range(Comparable lowObject,
             Comparable highObject)
Get an instance of Range.

Method Detail

getLowMatch

public int getLowMatch()
Get the low match type.


setLowMatch

public void setLowMatch(int lm)
Set the low match type.

Parameters:
lm - either INCLUSIVE or EXCLUSIVE

getHighMatch

public int getHighMatch()
Get the high match type.


setHighMatch

public void setHighMatch(int hm)
Set the high match type.

Parameters:
hm - either INCLUSIVE or EXCLUSIVE

getLow

public Comparable getLow()
Get the low object.


getHigh

public Comparable getHigh()
Get the high object.


toString

public String toString()
Describe this object in Set notation.


contains

public boolean contains(Comparable c)
True if the given object lies within this range.


compareTo

public int compareTo(Object o)
Specified by:
compareTo in interface Comparable
See Also:
Comparable

equals

public boolean equals(Object o)
True if the given object is a Range object that represents the same range.


hashCode

public int hashCode()
Get a predictable hash code.

Returns:
the low object's hash code if it's available, else the high object's hash code