public JsonNumber.NumberType getNumberType() { if (currentEvent != Event.VALUE_NUMBER) { throw new IllegalStateException( "JsonParser#getNumberType() is valid only " + "VALUE_NUMBER parser state. " + "But current parser state is " + currentEvent); } BigDecimal bigDecimal = new BigDecimal(tokenizer.getValue()); return bigDecimal.scale() == 0 ? JsonNumber.NumberType.INTEGER : JsonNumber.NumberType.DECIMAL; }
@Override public BigDecimal getBigDecimalValue() { if (currentEvent != Event.VALUE_NUMBER) { throw new IllegalStateException( "JsonParser#getNumberType() is valid only " + "VALUE_NUMBER parser state. " + "But current parser state is " + currentEvent); } return new BigDecimal(tokenizer.getValue()); }
public String getString() { if (currentEvent == Event.KEY_NAME || currentEvent == Event.VALUE_STRING || currentEvent == Event.VALUE_NUMBER) { return tokenizer.getValue(); } throw new IllegalStateException( "JsonParser#getString() is valid only " + "KEY_NAME, VALUE_STRING, VALUE_NUMBER parser states. " + "But current parser state is " + currentEvent); }