public class IntegerInterval extends NumericInterval
IllegalValue
Constructor and Description |
---|
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(NumericInterval rng)
Creates a new IntegerRange which is a copy of an existing NumericRange one.
|
IntegerInterval(java.lang.String str)
Creates a new IntRange from a specification string.
|
Modifier and Type | Method and Description |
---|---|
IntegerInterval |
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() |
void |
updateBounds(int val)
Adjusts the upper or lower bounds of this interval such that it contains
val . |
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.
|
canClipToRange, clipToRange, contains, epsilonEquals, equals, equals, getLowerBound, getRange, getUpperBound, intersect, isBounded, isClosed, isEmpty, isLowerBoundClosed, isTypeCompatible, isUpperBoundClosed, isValid, makeValid, makeValid, merge, parse, scale, validate, validate, validate, withinRange, withinRange
isWritable, setError
public IntegerInterval()
public IntegerInterval(int lower, int upper)
lower
- interval lower boundupper
- interval upper boundpublic IntegerInterval(IntegerInterval rng)
rng
- range to copypublic IntegerInterval(NumericInterval rng)
rng
- range to copypublic IntegerInterval(java.lang.String str) throws java.lang.IllegalArgumentException
scan
.str
- specification string for this IntRangejava.lang.IllegalArgumentException
- if the string is not in the correct format.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 void updateBounds(int val)
val
.val
- value to be contained by the intervalpublic 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;
public 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 objectsjava.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 rangepublic IntegerInterval clone()
clone
in interface Clonable
clone
in class NumericInterval