public class Real_Range extends Object implements Cloneable
The range of values is characterized by minimum and maximum values that identify the inclusive limits of the range. Single-valued and open-ended ranges are defined. An appropriate String representation is provided.
Modifier and Type | Field and Description |
---|---|
static String |
ID |
protected double |
Maximum
The range maximum value.
|
protected double |
Minimum
The range minimum value.
|
Constructor and Description |
---|
Real_Range()
Constructs a default Real_Range.
|
Real_Range(double value)
Constructs a single-valued Real_Range.
|
Real_Range(double minimum,
double maximum)
Constructs a Real_Range from limiting values.
|
Real_Range(Integer_Range range)
Constructs a Real_Range from an Integer_Range.
|
Real_Range(Real_Range range)
Constructs a Real_Range as a copy of another Real_Range.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Clones this Real_Range.
|
double |
Distance()
Gets the distance between the range limits.
|
boolean |
equals(Real_Range range)
Compares two Real_Ranges for equality.
|
int |
hashCode()
Gets a hash code for this Real_Range.
|
boolean |
Is_Open_Ended()
Tests if the Real_Range is open-ended.
|
boolean |
Is_Single_Valued()
Tests if the range is for a single value.
|
double |
Maximum()
Gets the maximum limit value.
|
Real_Range |
Maximum(double maximum)
Sets the maximum range value.
|
double |
Minimum()
Gets the minimum range value.
|
Real_Range |
Minimum(double minimum)
Sets the minimum range value.
|
Real_Range |
Range(double minimum,
double maximum)
Sets the Range minimum and maximum.
|
Real_Range |
Range(Integer_Range range)
Sets the range from an Integer_Range.
|
Real_Range |
Range(Real_Range range)
Sets the range from another Real_Range.
|
String |
toString()
Provides a String representation of the Real_Range.
|
Real_Range |
Value(double value)
Sets the range to a single value.
|
public static final String ID
protected double Minimum
protected double Maximum
public Real_Range()
The range values are initialized to zero.
public Real_Range(double minimum, double maximum)
Note: If the minimum is greater than the maximum then it is used as the maximum and the maximum used as the minimum.
minimum
- The minimum inclusive value of the range.maximum
- The maximum inclusive value of the range.Range(double, double)
public Real_Range(double value)
value
- The value of the range.Value(double)
public Real_Range(Real_Range range)
range
- The Real_Range to be copied. If null a default Real_Range
is constructed.Range(Real_Range)
public Real_Range(Integer_Range range)
range
- The Integer_Range to be copied. If null a default
Real_Range is constructed.Range(Integer_Range)
public Object clone()
public Real_Range Range(double minimum, double maximum)
Note: If the minimum is greater than the maximum then it is used as the maximum and the maximum used as the minimum.
minimum
- The minimum inclusive value of the range.maximum
- The maximum inclusive value of the range.Minimum(double)
,
Maximum(double)
public Real_Range Range(Real_Range range)
N.B.: The values of the source range are copied without checking.
range
- The Real_Range to be copied. If null nothing is done.public Real_Range Range(Integer_Range range)
Long.MIN_VALUE and Long.MAX_VALUE from the Integer_Range are reset to Double.MIN_VALUE and Double.MAX_VALUE respectively.
range
- The Integer_Range limits.Minimum(double)
,
Maximum(double)
public double Minimum()
public Real_Range Minimum(double minimum)
If the new minimum value is greater than the current maximum
value, the maximum is reset to the new minimum.
minimum
- The minimum range value.public double Maximum()
public Real_Range Maximum(double maximum)
If the new maximum rage value is less than the current minimum
value, the minimum is reset to the new maximum.
maximum
- The maximum range value.public boolean Is_Open_Ended()
minimum
is
Double.MIN_VALUE
or the maximum
is
Double.MAX_VALUE
.public double Distance()
open-ended
.public boolean Is_Single_Valued()
For a single valued range the minimum
and
maximum
values are identical.
public Real_Range Value(double value)
Both the minimum and maximum are set to the value.
value
- The single value for the range.Minimum(double)
,
Maximum(double)
public boolean equals(Real_Range range)
public int hashCode()
The result is the upper 16 bits of the hash code of the range minimum as a Double concatenated with the upper 16 bits of the hash code of the range maximum as a Double. That is, the hash code is the value of the expression:
(new Double (Minimum ()).hashCode () & 0xFFFF0000) | (new Double (Maximum ()).hashCode () >>> 16)
public String toString()
The format of the Integer_Range representation is:
minimum-maximum
If the minimum and maximum are identical then only a single value is represented.
If the minimum is not Double.MIN_VALUE
or the maximum is Double.MAX_VALUE
then the minimum value is represented. Then a dash
('-') delimiter is provided regardless of whether the minimum is
represented or not. If the maximum is not Double.MAX_VALUE
then it is included in the representation after the '-' delimiter.
Note that a range may be open-ended at its minimum or maximum, but
in all cases at least one limit value will be represented with the
minimum value being used if both both limits are open-ended.