main
Class Range

java.lang.Object
  extended by main.Range
All Implemented Interfaces:
java.lang.Comparable<Range>

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

The Range class attributes an object to a range of values. It provides methods for setting and getting the lower and upper bounds of the range and the object associated with the range.


Field Summary
static int ELSE
          Indicates a range corresponding to weights that neither fit in a standard range nor are invalid.
private  double high
           
static int INVALID
          Indicates a range corresponding to invalid weights, such as fields with missing data.
private  double low
           
static int STANDARD
          Indicates a standard range with a lower boundary and an upper boundary.
private  int type
           
private  java.lang.Object value
           
 
Constructor Summary
Range(double low, double high, java.lang.Object value)
          Creates a new standard range initialized with the arguments.
Range(int type, java.lang.Object value)
          Creates a range corresponding to invalid weights or weights that do not fit in a standard range.
 
Method Summary
 int compareTo(Range range)
          Compares this instance of Range with the specified instance.
 double getHigh()
          Gets the upper boundary of the range.
 double getLow()
          Gets the lower boundary of the range.
 int getType()
          Gets the type of range that this Range represents.
 java.lang.Object getValue()
          Gets the object associated with this range.
 boolean includesWeight(java.lang.Double weight)
          Determines whether this range encompasses the weight specified by the argument.
 java.lang.String toString()
          Returns a representation of of this Range.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STANDARD

public static final int STANDARD
Indicates a standard range with a lower boundary and an upper boundary.

See Also:
Constant Field Values

INVALID

public static final int INVALID
Indicates a range corresponding to invalid weights, such as fields with missing data.

See Also:
Constant Field Values

ELSE

public static final int ELSE
Indicates a range corresponding to weights that neither fit in a standard range nor are invalid.

See Also:
Constant Field Values

type

private int type

low

private double low

high

private double high

value

private java.lang.Object value
Constructor Detail

Range

public Range(double low,
             double high,
             java.lang.Object value)
Creates a new standard range initialized with the arguments.

Parameters:
low - a double representing the lower bound
high - a double representing the upper bound
value - an Object associated with the range

Range

public Range(int type,
             java.lang.Object value)
Creates a range corresponding to invalid weights or weights that do not fit in a standard range.

Parameters:
type - the type of range
value - an Object associated with the range
Method Detail

getType

public int getType()
Gets the type of range that this Range represents.

Returns:
the type of range

includesWeight

public boolean includesWeight(java.lang.Double weight)
Determines whether this range encompasses the weight specified by the argument.

Parameters:
weight - a Double representing the weight
Returns:
true if this range encompasses the weight, false otherwise

getLow

public double getLow()
Gets the lower boundary of the range.

Returns:
lower boundary

getHigh

public double getHigh()
Gets the upper boundary of the range.

Returns:
upper boundary

getValue

public java.lang.Object getValue()
Gets the object associated with this range.

Returns:
the associated object

compareTo

public int compareTo(Range range)
Compares this instance of Range with the specified instance. Returns a negative integer if this instance comes first in a natural ordering, a positive integer if the specified instance comes first in a natural ordering, or zero if they're equal. Note: this class has a natural ordering that is inconsistent with equals.

Specified by:
compareTo in interface java.lang.Comparable<Range>
Parameters:
range - another instance of Range
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

toString

public java.lang.String toString()
Returns a representation of of this Range. This is for debugging purposes.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this Range