public class NumericRange extends Pattern
Number
types, both integer and floating point ranges can be supported by this
one class.Modifier and Type | Field and Description |
---|---|
static int |
LOWER
Include the lower bound and not the upper bound of the numeric range in any comparisons.
|
static int |
LOWER_AND_UPPER
Include both lower and upper bounds of the numeric range in any comparisons.
|
static int |
NEITHER
Do not include the lower or upper bound of the numeric range in any comparisons.
|
static int |
UPPER
Include the upper bound and not the lower bound of the numeric range in any comparisons.
|
Constructor and Description |
---|
NumericRange(java.lang.Number original,
int compareBounds,
boolean tryUnknownAsLong)
Specifies the numeric range and how the boundaries are treated in a range
comparison.
|
NumericRange(java.lang.Number lower,
java.lang.Number upper,
int compareBounds)
Specifies the numeric range and how the boundaries are treated in a range
comparison.
|
NumericRange(java.lang.Number lower,
java.lang.Number upper,
int compareBounds,
java.lang.Object originalValue)
Specifies the numeric range and how the boundaries are treated in a range
comparison.
|
NumericRange(java.lang.Object originalObj,
int compareBounds,
boolean tryUnknownAsLong,
boolean isString)
Specifies the numeric range and how the boundaries are treated in a range
comparison.
|
NumericRange(java.lang.String original,
int compareBounds,
boolean tryUnknownAsLong)
Specifies the numeric range and how the boundaries are treated in a range
comparison.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
canConvert(java.lang.String text)
Returns
true if text can be converted into a number. |
boolean |
equals(java.lang.Object right)
Overloads the default
Object.equals to check the specific range that is being compared. |
int |
getCompareBounds()
Returns the flag that determines how the range boundaries are treated in a
range comparison.
|
java.lang.Number |
getLower()
Returns the lower boundary of the numeric range.
|
static java.lang.Number |
getNumber(java.lang.String text)
Returns a Number converted from text.
|
static java.lang.String |
getText(int compareBounds)
Returns a text image for the
compareBounds attribute. |
java.lang.Number |
getUpper()
Returns the upper boundary of the numeric range.
|
int |
hashCode()
Overloads the
java.lang.Object core specification to return a data-specific
hash value rather than the default instance-specific hash code. |
boolean |
isValidRange()
Returns
true if the current values denote an invalid range. |
static boolean |
isValidRange(java.lang.Number lower,
java.lang.Number upper,
int compareBounds)
Returns
true if the specified values denote an invalid range. |
void |
setCompareBounds(int compareBounds)
Defines how the range boundaries are treated in a range comparison.
|
void |
setLower(java.lang.Number lower)
Sets the lower boundary of the numeric range.
|
void |
setUpper(java.lang.Number upper)
Sets the upper boundary of the numeric range.
|
java.lang.String |
toString()
Creates a string of the value that this class represents.
|
getOriginalValue, setOriginalValue
public static final int LOWER_AND_UPPER
public static final int LOWER
public static final int UPPER
public static final int NEITHER
public NumericRange(java.lang.Number lower, java.lang.Number upper, int compareBounds, java.lang.Object originalValue)
LOWER_AND_UPPER
,
LOWER
,
UPPER
,
NEITHER
public NumericRange(java.lang.Number lower, java.lang.Number upper, int compareBounds)
LOWER_AND_UPPER
,
LOWER
,
UPPER
,
NEITHER
public NumericRange(java.lang.String original, int compareBounds, boolean tryUnknownAsLong)
LOWER_AND_UPPER
,
LOWER
,
UPPER
,
NEITHER
public NumericRange(java.lang.Number original, int compareBounds, boolean tryUnknownAsLong)
LOWER_AND_UPPER
,
LOWER
,
UPPER
,
NEITHER
public NumericRange(java.lang.Object originalObj, int compareBounds, boolean tryUnknownAsLong, boolean isString)
LOWER_AND_UPPER
,
LOWER
,
UPPER
,
NEITHER
public java.lang.Number getLower()
public void setLower(java.lang.Number lower)
public java.lang.Number getUpper()
public void setUpper(java.lang.Number upper)
public int getCompareBounds()
LOWER_AND_UPPER
,
LOWER
,
UPPER
,
NEITHER
public void setCompareBounds(int compareBounds)
LOWER_AND_UPPER
,
LOWER
,
UPPER
,
NEITHER
public boolean isValidRange()
true
if the current values denote an invalid range.public static boolean isValidRange(java.lang.Number lower, java.lang.Number upper, int compareBounds)
true
if the specified values denote an invalid range.public static java.lang.String getText(int compareBounds)
compareBounds
attribute.LOWER_AND_UPPER
,
LOWER
,
UPPER
,
NEITHER
,
getCompareBounds()
,
setCompareBounds(int)
public boolean equals(java.lang.Object right)
Object.equals
to check the specific range that is being compared.equals
in class java.lang.Object
public int hashCode()
java.lang.Object
core specification to return a data-specific
hash value rather than the default instance-specific hash code.hashCode
in class java.lang.Object
public static java.lang.Number getNumber(java.lang.String text)
public static boolean canConvert(java.lang.String text)
true
if text can be converted into a number.public java.lang.String toString()
toString
in class java.lang.Object