STATE_FLOAT state = STATE_FLOAT.BEGIN;
// read the float character by character
int nChar = isr.read();
do {
if (nChar == -1) {
throw new Error(
Error.PACKAGE.ALGORITHM,
ErrorCodes.INPUT_TERMINATED_EARLY,
isr.toString(),
null,
null);
}
char c = (char) nChar;
/**
* Parse float using FSM
* BEGIN -> DIGITS_BEFORE_DECIMAL
* DIGITS_BEFORE_DECIMAL -> DIGITS_BEFORE_DECIMAL ||
* DIGITS_AFTER_DECIMAL ||
* EXPONENT_BEGIN
* DIGITS_AFTER_DECIMAL -> DIGITS_AFTER_DECIMAL ||
* EXPONENT_BEGIN
* EXPONENT_BEGIN -> EXPONENT
*/
switch (state) {
case BEGIN:
if (c == '+' || c == '-' || Character.isDigit(c)) {
szFloat += c;
state = STATE_FLOAT.DIGITS_BEFORE_DECIMAL;
nChar = isr.read();
} else {
// illegal empty string
throw new Error(
Error.PACKAGE.ALGORITHM,
ErrorCodes.PARSE_ERROR,
isr.toString(),
null,
null);