org.apache.commons.lang.math
public abstract class Range extends Object
Range represents a range of numbers of the same type.
Specific subclasses hold the range values as different types. Each subclass should be immutable and {@link java.io.Serializable Serializable} if possible.
Since: 2.0
Version: $Id: Range.java 161243 2005-04-14 04:30:28Z ggregory $
| Constructor Summary | |
|---|---|
| Range() Constructs a new range. | |
| Method Summary | |
|---|---|
| boolean | containsDouble(Number value) Tests whether the specified
This implementation forwards to the {@link #containsDouble(double)} method. |
| boolean | containsDouble(double value) Tests whether the specified This implementation uses the {@link #getMinimumDouble()} and {@link #getMaximumDouble()} methods and should be good for most uses. |
| boolean | containsFloat(Number value) Tests whether the specified
This implementation forwards to the {@link #containsFloat(float)} method. |
| boolean | containsFloat(float value) Tests whether the specified This implementation uses the {@link #getMinimumFloat()} and {@link #getMaximumFloat()} methods and should be good for most uses. |
| boolean | containsInteger(Number value) Tests whether the specified
This implementation forwards to the {@link #containsInteger(int)} method. |
| boolean | containsInteger(int value) Tests whether the specified This implementation uses the {@link #getMinimumInteger()} and {@link #getMaximumInteger()} methods and should be good for most uses. |
| boolean | containsLong(Number value) Tests whether the specified
This implementation forwards to the {@link #containsLong(long)} method. |
| boolean | containsLong(long value) Tests whether the specified This implementation uses the {@link #getMinimumLong()} and {@link #getMaximumLong()} methods and should be good for most uses. |
| abstract boolean | containsNumber(Number number) Tests whether the specified The exact comparison implementation varies by subclass. |
| boolean | containsRange(Range range) Tests whether the specified range occurs entirely within this range. The exact comparison implementation varies by subclass. |
| boolean | equals(Object obj) Compares this range to another object to test if they are equal. . |
| double | getMaximumDouble() Gets the maximum number in this range as a This implementation uses the {@link #getMaximumNumber()} method. |
| float | getMaximumFloat() Gets the maximum number in this range as a This implementation uses the {@link #getMaximumNumber()} method. |
| int | getMaximumInteger() Gets the maximum number in this range as a This implementation uses the {@link #getMaximumNumber()} method. |
| long | getMaximumLong() Gets the maximum number in this range as a This implementation uses the {@link #getMaximumNumber()} method. |
| abstract Number | getMaximumNumber() Gets the maximum number in this range. |
| double | getMinimumDouble() Gets the minimum number in this range as a This implementation uses the {@link #getMinimumNumber()} method. |
| float | getMinimumFloat() Gets the minimum number in this range as a This implementation uses the {@link #getMinimumNumber()} method. |
| int | getMinimumInteger() Gets the minimum number in this range as a This implementation uses the {@link #getMinimumNumber()} method. |
| long | getMinimumLong() Gets the minimum number in this range as a This implementation uses the {@link #getMinimumNumber()} method. |
| abstract Number | getMinimumNumber() Gets the minimum number in this range. |
| int | hashCode() Gets a hashCode for the range. This implementation uses the {@link #getMinimumNumber()} and {@link #getMaximumNumber()} methods. |
| boolean | overlapsRange(Range range) Tests whether the specified range overlaps with this range. The exact comparison implementation varies by subclass. |
| String | toString() Gets the range as a The format of the String is 'Range[min,max]'. This implementation uses the {@link #getMinimumNumber()} and {@link #getMaximumNumber()} methods. |
Constructs a new range.
Tests whether the specified Number occurs within
this range using double comparison..
null is handled and returns false.
This implementation forwards to the {@link #containsDouble(double)} method.
Parameters: value the double to test, may be null
Returns: true if the specified number occurs within this
range by double comparison
Tests whether the specified double occurs within
this range using double comparison.
This implementation uses the {@link #getMinimumDouble()} and {@link #getMaximumDouble()} methods and should be good for most uses.
Parameters: value the double to test
Returns: true if the specified number occurs within this
range by double comparison
Tests whether the specified Number occurs within
this range using float comparison.
null is handled and returns false.
This implementation forwards to the {@link #containsFloat(float)} method.
Parameters: value the float to test, may be null
Returns: true if the specified number occurs within this
range by float comparison
Tests whether the specified float occurs within
this range using float comparison.
This implementation uses the {@link #getMinimumFloat()} and {@link #getMaximumFloat()} methods and should be good for most uses.
Parameters: value the float to test
Returns: true if the specified number occurs within this
range by float comparison
Tests whether the specified Number occurs within
this range using int comparison..
null is handled and returns false.
This implementation forwards to the {@link #containsInteger(int)} method.
Parameters: value the integer to test, may be null
Returns: true if the specified number occurs within this
range by int comparison
Tests whether the specified int occurs within
this range using int comparison.
This implementation uses the {@link #getMinimumInteger()} and {@link #getMaximumInteger()} methods and should be good for most uses.
Parameters: value the int to test
Returns: true if the specified number occurs within this
range by int comparison
Tests whether the specified Number occurs within
this range using long comparison..
null is handled and returns false.
This implementation forwards to the {@link #containsLong(long)} method.
Parameters: value the long to test, may be null
Returns: true if the specified number occurs within this
range by long comparison
Tests whether the specified long occurs within
this range using long comparison.
This implementation uses the {@link #getMinimumLong()} and {@link #getMaximumLong()} methods and should be good for most uses.
Parameters: value the long to test
Returns: true if the specified number occurs within this
range by long comparison
Tests whether the specified Number occurs within
this range.
The exact comparison implementation varies by subclass. It is
intended that an int specific subclass will compare using
int comparison.
null is handled and returns false.
Parameters: number the number to test, may be null
Returns: true if the specified number occurs within this range
Throws: IllegalArgumentException if the Number cannot be compared
Tests whether the specified range occurs entirely within this range.
The exact comparison implementation varies by subclass. It is
intended that an int specific subclass will compare using
int comparison.
null is handled and returns false.
This implementation uses the {@link #containsNumber(Number)} method. Subclasses may be able to optimise this.
Parameters: range the range to test, may be null
Returns: true if the specified range occurs entirely within
this range; otherwise, false
Throws: IllegalArgumentException if the Range cannot be compared
Compares this range to another object to test if they are equal.
.To be equal, the class, minimum and maximum must be equal.
This implementation uses the {@link #getMinimumNumber()} and {@link #getMaximumNumber()} methods. Subclasses may be able to optimise this.
Parameters: obj the reference object with which to compare
Returns: true if this object is equal
Gets the maximum number in this range as a double.
This implementation uses the {@link #getMaximumNumber()} method. Subclasses may be able to optimise this.
Returns: the maximum number in this range
Gets the maximum number in this range as a float.
This implementation uses the {@link #getMaximumNumber()} method. Subclasses may be able to optimise this.
Returns: the maximum number in this range
Gets the maximum number in this range as a int.
This implementation uses the {@link #getMaximumNumber()} method. Subclasses may be able to optimise this.
Returns: the maximum number in this range
Gets the maximum number in this range as a long.
This implementation uses the {@link #getMaximumNumber()} method. Subclasses may be able to optimise this.
Returns: the maximum number in this range
Gets the maximum number in this range.
Returns: the maximum number in this range
Gets the minimum number in this range as a double.
This implementation uses the {@link #getMinimumNumber()} method. Subclasses may be able to optimise this.
Returns: the minimum number in this range
Gets the minimum number in this range as a float.
This implementation uses the {@link #getMinimumNumber()} method. Subclasses may be able to optimise this.
Returns: the minimum number in this range
Gets the minimum number in this range as a int.
This implementation uses the {@link #getMinimumNumber()} method. Subclasses may be able to optimise this.
Returns: the minimum number in this range
Gets the minimum number in this range as a long.
This implementation uses the {@link #getMinimumNumber()} method. Subclasses may be able to optimise this.
Returns: the minimum number in this range
Gets the minimum number in this range.
Returns: the minimum number in this range
Gets a hashCode for the range.
This implementation uses the {@link #getMinimumNumber()} and {@link #getMaximumNumber()} methods. Subclasses may be able to optimise this.
Returns: a hash code value for this object
Tests whether the specified range overlaps with this range.
The exact comparison implementation varies by subclass. It is
intended that an int specific subclass will compare using
int comparison.
null is handled and returns false.
This implementation uses the {@link #containsNumber(Number)} and {@link #containsRange(Range)} methods. Subclasses may be able to optimise this.
Parameters: range the range to test, may be null
Returns: true if the specified range overlaps with this
range; otherwise, false
Throws: IllegalArgumentException if the Range cannot be compared
Gets the range as a String.
The format of the String is 'Range[min,max]'.
This implementation uses the {@link #getMinimumNumber()} and {@link #getMaximumNumber()} methods. Subclasses may be able to optimise this.
Returns: the String representation of this range