protected final void parseNumericValue(int i) throws JsonParseException { if (_currToken == null || !_currToken.isNumeric()) _reportError( (new StringBuilder()) .append("Current token (") .append(_currToken) .append(") not numeric, can not use numeric value accessors") .toString()); try { if (_currToken != JsonToken.VALUE_NUMBER_INT) break MISSING_BLOCK_LABEL_248; char ac[] = _textBuffer.getTextBuffer(); int j = _textBuffer.getTextOffset(); if (_numberNegative) j++; if (mIntLength <= 9) { int k = NumberInput.parseInt(ac, j, mIntLength); if (_numberNegative) k = -k; _numberInt = k; _numTypesValid = 1; break MISSING_BLOCK_LABEL_291; } if (mIntLength <= 18) { long l = NumberInput.parseLong(ac, j, mIntLength); if (_numberNegative) l = -l; _numberLong = l; _numTypesValid = 2; break MISSING_BLOCK_LABEL_291; } } catch (NumberFormatException numberformatexception) { _wrapError( (new StringBuilder()) .append("Malformed numeric value '") .append(_textBuffer.contentsAsString()) .append("'") .toString(), numberformatexception); break MISSING_BLOCK_LABEL_291; } _numberBigInt = new BigInteger(_textBuffer.contentsAsString()); _numTypesValid = 4; break MISSING_BLOCK_LABEL_291; if (i == 16) { _numberBigDecimal = _textBuffer.contentsAsDecimal(); _numTypesValid = 16; } else { _numberDouble = _textBuffer.contentsAsDouble(); _numTypesValid = 8; } }
@Override public double getValueAsDouble(double defaultValue) throws IOException, JsonParseException { if (_currToken != null) { switch (_currToken) { case VALUE_NUMBER_INT: case VALUE_NUMBER_FLOAT: return getDoubleValue(); case VALUE_TRUE: return 1; case VALUE_FALSE: case VALUE_NULL: return 0; case VALUE_STRING: return NumberInput.parseAsDouble(getText(), defaultValue); case VALUE_EMBEDDED_OBJECT: { Object value = this.getEmbeddedObject(); if (value instanceof Number) { return ((Number) value).doubleValue(); } } } } return defaultValue; }