|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmaspack.util.RangeBase
maspack.util.NumericInterval
maspack.util.DoubleInterval
public class DoubleInterval
A Range object which inspects a number to make sure it lies within a prescibed interval.
Field Summary | |
---|---|
static DoubleInterval |
NonNegative
|
static DoubleInterval |
Positive
|
Fields inherited from interface maspack.util.Range |
---|
IllegalValue |
Constructor Summary | |
---|---|
DoubleInterval()
Creates a DoubleRange which accepts any double value. |
|
DoubleInterval(double lower,
double upper)
Creates a new DoubleRange that accepts any value in the closed interval [lower, upper]. |
|
DoubleInterval(NumericInterval rng)
Creates a new DoubleRange which is a copy of an existing NumericRange one. |
|
DoubleInterval(java.lang.String str)
Creates a new DoubleRange from a specification string. |
Method Summary | |
---|---|
DoubleInterval |
clone()
|
void |
scan(ReaderTokenizer rtok,
java.lang.Object ref)
Scans this element from a ReaderTokenizer. |
void |
set(double lower,
double upper)
Sets this DoubleRange so that it accepts any value in the closed interval [lower, upper]. |
void |
set(double lower,
double upper,
java.lang.String closure)
Sets this DoubleRange so that it accepts any value within a specified interval. |
void |
set(NumericInterval rng)
Sets this DoubleRange to the value of any NumericRange. |
void |
setLowerBound(double lower)
Sets the lower bound for the interval of this DoubleRange. |
void |
setLowerBoundClosed(boolean closed)
Sets the lower bound for the interval of this DoubleRange to be closed or open. |
void |
setUpperBound(double upper)
Sets the upper bound for the interval of this DoubleRange. |
void |
setUpperBoundClosed(boolean closed)
Sets the upper bound for the interval of this DoubleRange to be closed or open. |
java.lang.String |
toString()
|
void |
write(java.io.PrintWriter pw,
NumberFormat fmt,
java.lang.Object ref)
Writes a text description of this element to a PrintWriter. |
Methods inherited from class maspack.util.NumericInterval |
---|
canClipToRange, clipToRange, contains, equals, equals, getLowerBound, getRange, getUpperBound, intersect, isBounded, isClosed, isEmpty, isLowerBoundClosed, isTypeCompatible, isUpperBoundClosed, isValid, makeValid, makeValid, merge, parse, validate, validate, withinRange, withinRange |
Methods inherited from class maspack.util.RangeBase |
---|
isWritable, setError |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static DoubleInterval Positive
public static DoubleInterval NonNegative
Constructor Detail |
---|
public DoubleInterval()
public DoubleInterval(double lower, double upper)
lower
- interval lower boundupper
- interval upper boundpublic DoubleInterval(NumericInterval rng)
rng
- range to copypublic DoubleInterval(java.lang.String str) throws java.lang.IllegalArgumentException
scan
.
str
- specification string for this DoubleRange
java.lang.IllegalArgumentException
- if the string is not in the correct format.Method Detail |
---|
public void setLowerBound(double lower)
lower
- new lower interval boundpublic void setLowerBoundClosed(boolean closed)
closed
- if true, sets the lower interval bound to be closedpublic void setUpperBound(double upper)
upper
- new upper interval boundpublic void setUpperBoundClosed(boolean closed)
closed
- if true, sets the upper interval bound to be closedpublic void set(double lower, double upper)
lower
- interval lower boundupper
- interval upper boundpublic void set(NumericInterval rng)
rng
- numeric range to copypublic void set(double lower, double upper, java.lang.String closure)
lower
- interval lower boundupper
- interval upper boundclosure
- specifies whether the lower and upper bounds are open or closed
java.lang.IllegalArgumentException
- if the closure specification string is not one of "[]", "[)", "(]", or
"()".public java.lang.String toString()
toString
in class java.lang.Object
public void scan(ReaderTokenizer rtok, java.lang.Object ref) throws java.io.IOException
[
' or '(
' character, depending
on whether the lower bound is closed or open;
,
' character
]
' or ')
' character, depending
on whether the upper bound is closed or open;
scan
in interface Scannable
scan
in class RangeBase
rtok
- Tokenizer from which to scan the elementref
- reference object (not used, may be null)
java.io.IOException
- if an I/O or formatting error occuredpublic void write(java.io.PrintWriter pw, NumberFormat fmt, java.lang.Object ref) throws java.io.IOException
scan
and complete
enough to allow full reconstruction of the element.
write
in interface Scannable
write
in class RangeBase
pw
- stream for writing the elementfmt
- numeric formating informationref
- optional reference object which can be used for producing references to
other objects
java.io.IOException
- if an I/O error occuredpublic DoubleInterval clone()
clone
in interface Clonable
clone
in class NumericInterval
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |