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.


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(java.lang.Object o)
          True if the given object is a Range object that represents the same range.
 java.lang.Comparable<T> getHigh()
          Get the high object.
 Range.MatchType getHighMatch()
          Get the high match type.
 java.lang.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.
 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
 

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 java.lang.Comparable<T> getLow()
Get the low object.


getHigh

public java.lang.Comparable<T> 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-2007 SPY Internetworking. All Rights Reserved.