|
|||||||||
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.IntegerInterval
public class IntegerInterval
A Range object which inspects a number to make sure it lies within a prescibed interval.
Field Summary |
---|
Fields inherited from interface maspack.util.Range |
---|
IllegalValue |
Constructor Summary | |
---|---|
IntegerInterval()
Creates a IntRange which accepts any integer value. |
|
IntegerInterval(IntegerInterval rng)
Creates a new IntRange which is a copy of an existing one. |
|
IntegerInterval(int lower,
int upper)
Creates a new IntRange that accepts any value in the closed interval [lower, upper]. |
|
IntegerInterval(java.lang.String str)
Creates a new IntRange from a specification string. |
Method Summary | |
---|---|
DoubleInterval |
clone()
|
void |
scan(ReaderTokenizer rtok,
java.lang.Object ref)
Scans this element from a ReaderTokenizer. |
void |
set(int lower,
int upper)
Sets this IntRange so that it accepts any value in the closed interval [lower, upper]. |
void |
set(NumericInterval rng)
Sets this IntRange from the value of an existing NumericInterval. |
void |
setLowerBound(int lower)
Sets the lower bound for the interval of this IntRange. |
void |
setUpperBound(int upper)
Sets the upper bound for the interval of this IntRange. |
java.lang.String |
toString()
|
java.lang.Object |
validate(int[] values,
boolean clip,
StringHolder errMsg)
Validates an array of integers by checking that its elements lie within this range interval. |
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 |
Constructor Detail |
---|
public IntegerInterval()
public IntegerInterval(int lower, int upper)
lower
- interval lower boundupper
- interval upper boundpublic IntegerInterval(IntegerInterval rng)
rng
- range to copypublic IntegerInterval(java.lang.String str) throws java.lang.IllegalArgumentException
scan
.
str
- specification string for this IntRange
java.lang.IllegalArgumentException
- if the string is not in the correct format.Method Detail |
---|
public void setLowerBound(int lower)
lower
- new lower interval boundpublic void setUpperBound(int upper)
upper
- new upper interval boundpublic void set(int lower, int upper)
lower
- interval lower boundupper
- interval upper boundpublic void set(NumericInterval rng)
rng
- numeric range to copypublic java.lang.String toString()
toString
in class java.lang.Object
public void scan(ReaderTokenizer rtok, java.lang.Object ref) throws java.io.IOException
[
' character;
,
' character;
]
' character;
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 java.lang.Object validate(int[] values, 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.
values
- array to validateclip
- if true, clip the array to the rangeerrMsg
- if non-null, is used to return an error message if one or more elements
are out of range
public 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 |