work on #3 - catch IOOBE

This commit is contained in:
Enrique Zamudio
2012-12-26 16:02:38 -06:00
parent 778501b2d6
commit 2e5911f261
7 changed files with 63 additions and 31 deletions
@@ -57,10 +57,15 @@ public class NumericParseInfo extends AlphaNumericFieldParseInfo {
//Use a BigInteger
char[] digits = new char[length];
int start = 0;
for (int i = pos; i < pos + (length / 2) + (length % 2); i++) {
digits[start++] = (char)(((buf[i] & 0xf0) >> 4) + 48);
digits[start++] = (char)((buf[i] & 0x0f) + 48);
}
try {
for (int i = pos; i < pos + (length / 2) + (length % 2); i++) {
digits[start++] = (char)(((buf[i] & 0xf0) >> 4) + 48);
digits[start++] = (char)((buf[i] & 0x0f) + 48);
}
} catch (IndexOutOfBoundsException ex) {
throw new ParseException(String.format("Insufficient data for bin %s field of length %d, pos %d",
type, length, pos), pos);
}
return new IsoValue<Number>(IsoType.NUMERIC, new BigInteger(new String(digits)), length, null);
}
}