public NumberType getNumberType() throws IOException, JsonParseException { if (mNumTypesValid == NR_UNKNOWN) { parseNumericValue(NR_UNKNOWN); // will also check event type } if (_currToken == JsonToken.VALUE_NUMBER_INT) { if ((mNumTypesValid & NR_INT) != 0) { return NumberType.INT; } if ((mNumTypesValid & NR_LONG) != 0) { return NumberType.LONG; } return NumberType.BIG_INTEGER; } /* And then floating point types. Here optimal type * needs to be big decimal, to avoid losing any data? * However... using BD is slow, so let's allow returning * double as type if no explicit call has been made to access * data as BD? */ if ((mNumTypesValid & NR_BIGDECIMAL) != 0) { return NumberType.BIG_DECIMAL; } return NumberType.DOUBLE; }
public BigDecimal getDecimalValue() throws IOException, JsonParseException { if ((mNumTypesValid & NR_BIGDECIMAL) == 0) { if (mNumTypesValid == NR_UNKNOWN) { parseNumericValue(NR_BIGDECIMAL); } if ((mNumTypesValid & NR_BIGDECIMAL) == 0) { convertNumberToBigDecimal(); } } return mNumberBigDecimal; }
public int getIntValue() throws IOException, JsonParseException { if ((mNumTypesValid & NR_INT) == 0) { if (mNumTypesValid == NR_UNKNOWN) { // not parsed at all parseNumericValue(NR_INT); // will also check event type } if ((mNumTypesValid & NR_INT) == 0) { // wasn't an int natively? convertNumberToInt(); // let's make it so, if possible } } return mNumberInt; }
public double getDoubleValue() throws IOException, JsonParseException { if ((mNumTypesValid & NR_DOUBLE) == 0) { if (mNumTypesValid == NR_UNKNOWN) { parseNumericValue(NR_DOUBLE); } if ((mNumTypesValid & NR_DOUBLE) == 0) { convertNumberToDouble(); } } return mNumberDouble; }
public long getLongValue() throws IOException, JsonParseException { if ((mNumTypesValid & NR_LONG) == 0) { if (mNumTypesValid == NR_UNKNOWN) { parseNumericValue(NR_LONG); } if ((mNumTypesValid & NR_LONG) == 0) { convertNumberToLong(); } } return mNumberLong; }
parseNumericValue(NR_UNKNOWN); // will also check event type