|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface NumberConstraint
A number constraint is used by scanners to read numbers under conditions, such as limiting the number of total digits to read, or accepting negative numbers, forcing a number to be an integer, etc.
| Nested Class Summary | |
|---|---|
static class |
NumberConstraint.NumberClassConstraint
Base class for checking constraints on number types. |
static class |
NumberConstraint.Type
A constraint on numbers : after parsing the number, it will be of the type given. |
| Field Summary | |
|---|---|
static NumberConstraint |
BYTE_CONSTRAINT
A constraint for parsing bytes. |
static NumberConstraint |
DECIMAL_CONSTRAINT
A constraint for parsing decimal. |
static NumberConstraint |
DOUBLE_CONSTRAINT
A constraint for parsing a double. |
static NumberConstraint |
FLOAT_CONSTRAINT
A constraint for parsing a float. |
static NumberConstraint |
INT_CONSTRAINT
A constraint for parsing integers. |
static NumberConstraint |
INTEGER_CONSTRAINT
A constraint for parsing integers. |
static NumberConstraint |
LONG_CONSTRAINT
A constraint for parsing longs. |
static String |
MAX_BYTE
|
static String |
MAX_INTEGER
|
static String |
MAX_LONG
|
static String |
MAX_SHORT
|
static String |
MIN_BYTE
|
static String |
MIN_INTEGER
|
static String |
MIN_LONG
|
static String |
MIN_SHORT
|
static NumberConstraint |
NO_CONSTRAINT
When there is no constraint, there is no stop condition (that always return true). |
static NumberConstraint |
SHORT_CONSTRAINT
A constraint for parsing shorts. |
| Method Summary | |
|---|---|
Class |
getNumberType()
Enforce a number to be of a specific type. |
boolean |
stopCondition(StringBuffer buf,
int sourceIndex,
int dotIndex,
int exponentIndex,
Scanner scanner)
Evaluate the stop condition from the given parameters. |
| Field Detail |
|---|
static final NumberConstraint NO_CONSTRAINT
A number under no constraint is parsed until a character is unexpected in the input sequence.
static final NumberConstraint BYTE_CONSTRAINT
Byte.MAX_VALUE,
Byte.MIN_VALUEstatic final NumberConstraint SHORT_CONSTRAINT
Short.MAX_VALUE,
Short.MIN_VALUEstatic final NumberConstraint INT_CONSTRAINT
Integer.MAX_VALUE,
Integer.MIN_VALUEstatic final NumberConstraint INTEGER_CONSTRAINT
BigIntegerstatic final NumberConstraint LONG_CONSTRAINT
Long.MAX_VALUE,
Long.MIN_VALUEstatic final NumberConstraint DECIMAL_CONSTRAINT
BigDecimalstatic final NumberConstraint DOUBLE_CONSTRAINT
Doublestatic final NumberConstraint FLOAT_CONSTRAINT
Floatstatic final String MIN_BYTE
static final String MAX_BYTE
static final String MIN_SHORT
static final String MAX_SHORT
static final String MIN_INTEGER
static final String MAX_INTEGER
static final String MIN_LONG
static final String MAX_LONG
| Method Detail |
|---|
boolean stopCondition(StringBuffer buf,
int sourceIndex,
int dotIndex,
int exponentIndex,
Scanner scanner)
throws IOException
This condition is evaluated by the scanner to check if it has to append characters to the current buffer.
buf - The buffer that receive the input characters
so far. It can be used by this method to evaluate
the stop condition.
For example if negative numbers are not allowed, the
first character of the buffer can't be "-".sourceIndex - The number of characters read so far ;
might be useful in certain stop conditions.dotIndex - The index where the dot character was
encountered, or -1 if not found so far.exponentIndex - The index where the exponent character
was encountered, or -1 if not found so far.scanner - The scanner that reads the input.
According to the parsing strategy, if the sequence
of characters involved in the stop condition (if any)
don't have to be consumed, the relevant methods of
the scanner should be involved.
true to indicate that the current scan
must stop, false if more characters have
to be read.
IOException - When the scanner cause an error.Class getNumberType()
null
if the type have to be the more suitable.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||