コード例 #1
0
 private final void _parseSlowIntValue(int expType, char[] buf, int offset, int len)
     throws IOException, JsonParseException {
   String numStr = _textBuffer.contentsAsString();
   try {
     // [JACKSON-230] Some long cases still...
     if (NumberInput.inLongRange(buf, offset, len, _numberNegative)) {
       // Probably faster to construct a String, call parse, than to use BigInteger
       _numberLong = Long.parseLong(numStr);
       _numTypesValid = NR_LONG;
     } else {
       // nope, need the heavy guns... (rare case)
       _numberBigInt = new BigInteger(numStr);
       _numTypesValid = NR_BIGINT;
     }
   } catch (NumberFormatException nex) {
     // Can this ever occur? Due to overflow, maybe?
     _wrapError("Malformed numeric value '" + numStr + "'", nex);
   }
 }
コード例 #2
0
 private final void _parseSlowFloatValue(int expType) throws IOException, JsonParseException {
   /* Nope: floating point. Here we need to be careful to get
    * optimal parsing strategy: choice is between accurate but
    * slow (BigDecimal) and lossy but fast (Double). For now
    * let's only use BD when explicitly requested -- it can
    * still be constructed correctly at any point since we do
    * retain textual representation
    */
   try {
     if (expType == NR_BIGDECIMAL) {
       _numberBigDecimal = _textBuffer.contentsAsDecimal();
       _numTypesValid = NR_BIGDECIMAL;
     } else {
       // Otherwise double has to do
       _numberDouble = _textBuffer.contentsAsDouble();
       _numTypesValid = NR_DOUBLE;
     }
   } catch (NumberFormatException nex) {
     // Can this ever occur? Due to overflow, maybe?
     _wrapError("Malformed numeric value '" + _textBuffer.contentsAsString() + "'", nex);
   }
 }