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

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

public class Range<T extends Comparable<T>>
extends Object
implements Comparable<Range<T>>

A range of Comparable objects.


Nested Class Summary
static class Range.MatchType
           
 
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(Object o)
          True if the given object is a Range object that represents the same range.
 Comparable<T> getHigh()
          Get the high object.
 Range.MatchType getHighMatch()
          Get the high match type.
 Comparable<T> getLow()
          Get the low object.
 Range.MatchType getLowMatch()
          Get the low match type.
 int hashCode()
          Get a predictable hash code.
 void setHighMatch(Range.MatchType hm)
          Set the high match type.
 void setLowMatch(Range.MatchType 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
 

Constructor Detail

Range

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

Method Detail

getLowMatch

public Range.MatchType getLowMatch()
Get the low match type.


setLowMatch

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

Parameters:
lm - either INCLUSIVE or EXCLUSIVE

getHighMatch

public Range.MatchType getHighMatch()
Get the high match type.


setHighMatch

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

Parameters:
hm - either INCLUSIVE or EXCLUSIVE

getLow

public Comparable<T> getLow()
Get the low object.


getHigh

public Comparable<T> getHigh()
Get the high object.


toString

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

Overrides:
toString in class 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 Comparable<Range<T extends Comparable<T>>>
See Also:
Comparable

equals

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

Overrides:
equals in class Object

hashCode

public int hashCode()
Get a predictable hash code.

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


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