net.spy.util
Class Range<T extends java.lang.Comparable<T>>

java.lang.Object
  extended by net.spy.util.Range<T>
All Implemented Interfaces:
java.lang.Comparable<Range<T>>

public class Range<T extends java.lang.Comparable<T>>
extends java.lang.Object
implements java.lang.Comparable<Range<T>>

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(T lowObject, T highObject)
          Get an instance of Range.
 
Method Summary
 int compareTo(Range<T> r)
           
 boolean contains(T c)
          True if the given object lies within this range.
 boolean equals(java.lang.Object o)
          True if the given object is a Range object that represents the same range.
 java.lang.Comparable getHigh()
          Get the high object.
 int getHighMatch()
          Get the high match type.
 java.lang.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.
 java.lang.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(T lowObject,
             T 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 java.lang.Comparable getLow()
Get the low object.


getHigh

public java.lang.Comparable getHigh()
Get the high object.


toString

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

Overrides:
toString in class java.lang.Object

contains

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


compareTo

public int compareTo(Range<T> r)
Specified by:
compareTo in interface java.lang.Comparable<Range<T extends java.lang.Comparable<T>>>
See Also:
Comparable

equals

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

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Get a predictable hash code.

Overrides:
hashCode in class java.lang.Object
Returns:
the low object's hash code if it's available, else the high object's hash code


Copyright © 1995-2006 SPY Internetworking. All Rights Reserved.