public abstract class NumericInterval extends RangeBase
IllegalValue
Constructor and Description |
---|
NumericInterval() |
Modifier and Type | Method and Description |
---|---|
boolean |
canClipToRange(double num)
Returns true if it is possible to clip a number to this range.
|
double |
clipToRange(double num)
Clips a number to lie within the interval specified by this NumericRange.
|
NumericInterval |
clone() |
boolean |
contains(NumericInterval rng)
Returns true if the NumericRange r is a subset of this range.
|
boolean |
epsilonEquals(NumericInterval rng,
double eps)
Returns true if a specified NumericRange is equal in value, within
a prescribed absolute tolerance, to this one.
|
boolean |
equals(NumericInterval rng)
Returns true if a specified NumericRange is equivalent in value to this
one.
|
boolean |
equals(java.lang.Object obj)
Returns true if a specified object is a NumericRange equivalent in value
to this one.
|
double |
getLowerBound()
Returns the lower bound for the interval of this NumericRange.
|
double |
getRange()
Returns the upper bound minus the lower bound of this NumericRange
|
double |
getUpperBound()
Returns the upper bound for the interval of this NumericRange.
|
void |
intersect(Range r)
Intersects the set of valid values of this Range with those of
another.
|
boolean |
isBounded()
Returns true if this range is bounded; i.e., neither the upper
nor the lower bounds are infinite.
|
boolean |
isClosed()
Returns true if this interval is closed, which is true if
both the lower and upper bounds are closed.
|
boolean |
isEmpty()
Returns true if this range is empty - i.e., if there are no valid
values.
|
boolean |
isLowerBoundClosed()
Returns true if the lower bound for the interval of this NumericRange is
closed.
|
boolean |
isTypeCompatible(java.lang.Object obj)
Returns true if a specified object is an instance of Number.
|
boolean |
isUpperBoundClosed()
Returns true if the upper bound for the interval of this NumericRange is
closed.
|
boolean |
isValid(java.lang.Object obj,
StringHolder errMsg)
Returns true if the specified object is valid for this Range,
and false otherwise.
|
double |
makeValid(double val) |
java.lang.Object |
makeValid(java.lang.Object obj)
Projects an object to lie within the range allowed by this Range, if
possible.
|
void |
merge(NumericInterval range)
Merges this NumericRange with another, updating the bounds for
this range to enclose both values.
|
void |
parse(java.lang.String str)
Sets the value of this NumericRange from a string.
|
void |
scale(double s) |
java.lang.Object |
validate(java.lang.Number value,
boolean clip,
StringHolder errMsg)
Validates a numeric object by checking that it lies within this range
interval.
|
java.lang.Object |
validate(Vector vec,
boolean clip,
StringHolder errMsg)
Validates a vector by checking that its elements lie within this range
interval.
|
java.lang.Object |
validate(Vectori vec,
boolean clip,
StringHolder errMsg)
Validates an integer vector by checking that its elements lie within this
range interval.
|
boolean |
withinRange(double num)
Returns true if the specified number lies within the interval specified by
this NumericRange.
|
boolean |
withinRange(java.lang.Number num)
Returns true if the value of a specified Number object lies within the
interval specified by this NumericRange.
|
isWritable, scan, setError, write
public boolean isEmpty()
public boolean contains(NumericInterval rng)
rng
- Range to checkpublic void intersect(Range r)
RangeBase
Range.isEmpty()
should subsequently return true
.public boolean isClosed()
public double getLowerBound()
public boolean isLowerBoundClosed()
public double getUpperBound()
public boolean isUpperBoundClosed()
public boolean isBounded()
public double getRange()
public boolean isValid(java.lang.Object obj, StringHolder errMsg)
RangeBase
errMsg
is not null
, then errMsg.value
should
be set to a message describing why the object is not valid.public double makeValid(double val)
public java.lang.Object makeValid(java.lang.Object obj)
obj
is already within the range, then
obj
should be returned unchanged. Otherwise, if it can be
projected to the range, then a new (projected) object should be
returned. Otherwise, if it cannot be projected, Range.IllegalValue
should be returned.
In particular, projectToRange(obj) != obj
should
be a valid indication that the obj
is not within range.
public boolean withinRange(java.lang.Number num)
num
- Number to be testedpublic boolean withinRange(double num)
num
- number to be testedpublic double clipToRange(double num)
num
- number to be clippedpublic boolean canClipToRange(double num)
public boolean isTypeCompatible(java.lang.Object obj)
obj
- object to testpublic void merge(NumericInterval range)
range
- range to merge with this onepublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- object to compare withpublic boolean equals(NumericInterval rng)
rng
- numeric range to compare withrng
is equivalent to this NumericRangepublic boolean epsilonEquals(NumericInterval rng, double eps)
rng
- numeric range to compare witheps
- numeric tolerance for comparisonrng
is equivalent to this NumericRangepublic void parse(java.lang.String str)
scan
.str
- string specifying the value of this NumericRangepublic java.lang.Object validate(java.lang.Number value, boolean clip, StringHolder errMsg)
clip
is true
), or the special value
Range.IllegalValue
. In
the latter two cases, an error message will also be returned if the
variable errMsg
is non-null.value
- numeric object to validateclip
- if true, clip the number to the range if possib;eerrMsg
- if non-null, is used to return an error message if the number is out of
rangepublic java.lang.Object validate(Vector vec, boolean clip, StringHolder errMsg)
clip
is true
), or the special value
Range.IllegalValue
. In
the latter two cases, an error message will also be returned if the
variable errMsg
is non-null.vec
- vector to validateclip
- if true, clip the vector to the range if possibleerrMsg
- if non-null, is used to return an error message if one or more elements
are out of rangepublic java.lang.Object validate(Vectori vec, boolean clip, StringHolder errMsg)
clip
is true
), or the special value Range.IllegalValue
. In the latter two cases, an error message will also
be returned if the variable errMsg
is non-null.vec
- vector to validateclip
- if true, clip the vector to the range if possibleerrMsg
- if non-null, is used to return an error message if one or more elements
are out of rangepublic NumericInterval clone()
public void scale(double s)