/** * Specialized convenience method that will decode a 64-bit int, * of at most 18 digits (and possible leading minus sign). * * @param neg Whether contents start with a minus sign * * @since 2.9 */ public long contentsAsLong(boolean neg) { if ((_inputStart >= 0) && (_inputBuffer != null)) { if (neg) { return -NumberInput.parseLong(_inputBuffer, _inputStart+1, _inputLen-1); } return NumberInput.parseLong(_inputBuffer, _inputStart, _inputLen); } if (neg) { return -NumberInput.parseLong(_currentSegment, 1, _currentSize-1); } return NumberInput.parseLong(_currentSegment, 0, _currentSize); }
/** * Specialized convenience method that will decode a 64-bit int, * of at most 18 digits (and possible leading minus sign). * * @param neg Whether contents start with a minus sign * * @since 2.9 */ public long contentsAsLong(boolean neg) { if ((_inputStart >= 0) && (_inputBuffer != null)) { if (neg) { return -NumberInput.parseLong(_inputBuffer, _inputStart+1, _inputLen-1); } return NumberInput.parseLong(_inputBuffer, _inputStart, _inputLen); } if (neg) { return -NumberInput.parseLong(_currentSegment, 1, _currentSize-1); } return NumberInput.parseLong(_currentSegment, 0, _currentSize); }
private Date _parseDateFromLong(String longStr, ParsePosition pos) throws ParseException { long ts; try { ts = NumberInput.parseLong(longStr); } catch (NumberFormatException e) { throw new ParseException(String.format( "Timestamp value %s out of 64-bit value range", longStr), pos.getErrorIndex()); } return new Date(ts); }
private final static int _parseIndex(String str) { final int len = str.length(); // [core#133]: beware of super long indexes; assume we never // have arrays over 2 billion entries so ints are fine. if (len == 0 || len > 10) { return -1; } // [core#176]: no leading zeroes allowed char c = str.charAt(0); if (c <= '0') { return (len == 1 && c == '0') ? 0 : -1; } if (c > '9') { return -1; } for (int i = 1; i < len; ++i) { c = str.charAt(i); if (c > '9' || c < '0') { return -1; } } if (len == 10) { long l = NumberInput.parseLong(str); if (l > Integer.MAX_VALUE) { return -1; } } return NumberInput.parseInt(str); }
/** * @since 2.9 */ protected final long _parseLongPrimitive(DeserializationContext ctxt, String text) throws IOException { try { return NumberInput.parseLong(text); } catch (IllegalArgumentException iae) { } { Number v = (Number) ctxt.handleWeirdStringValue(_valueClass, text, "not a valid long value"); return _nonNullNumber(v).longValue(); } }
private final static int _parseIndex(String str) { final int len = str.length(); // [core#133]: beware of super long indexes; assume we never // have arrays over 2 billion entries so ints are fine. if (len == 0 || len > 10) { return -1; } // [core#176]: no leading zeroes allowed char c = str.charAt(0); if (c <= '0') { return (len == 1 && c == '0') ? 0 : -1; } if (c > '9') { return -1; } for (int i = 1; i < len; ++i) { c = str.charAt(i); if (c > '9' || c < '0') { return -1; } } if (len == 10) { long l = NumberInput.parseLong(str); if (l > Integer.MAX_VALUE) { return -1; } } return NumberInput.parseInt(str); }
return Long.valueOf(NumberInput.parseLong(text)); } catch (IllegalArgumentException iae) { } return (Long) ctxt.handleWeirdStringValue(_valueClass, text,
/** * Specialized convenience method that will decode a 64-bit int, * of at most 18 digits (and possible leading minus sign). * * @param neg Whether contents start with a minus sign * * @since 2.9 */ public long contentsAsLong(boolean neg) { if ((_inputStart >= 0) && (_inputBuffer != null)) { if (neg) { return -NumberInput.parseLong(_inputBuffer, _inputStart+1, _inputLen-1); } return NumberInput.parseLong(_inputBuffer, _inputStart, _inputLen); } if (neg) { return -NumberInput.parseLong(_currentSegment, 1, _currentSize-1); } return NumberInput.parseLong(_currentSegment, 0, _currentSize); }
private Date _parseDateFromLong(String longStr, ParsePosition pos) throws ParseException { long ts; try { ts = NumberInput.parseLong(longStr); } catch (NumberFormatException e) { throw new ParseException(String.format( "Timestamp value %s out of 64-bit value range", longStr), pos.getErrorIndex()); } return new Date(ts); }
private final static int _parseIndex(String str) { final int len = str.length(); // [core#133]: beware of super long indexes; assume we never // have arrays over 2 billion entries so ints are fine. if (len == 0 || len > 10) { return -1; } // [core#176]: no leading zeroes allowed char c = str.charAt(0); if (c <= '0') { return (len == 1 && c == '0') ? 0 : -1; } if (c > '9') { return -1; } for (int i = 1; i < len; ++i) { c = str.charAt(i); if (c > '9' || c < '0') { return -1; } } if (len == 10) { long l = NumberInput.parseLong(str); if (l > Integer.MAX_VALUE) { return -1; } } return NumberInput.parseInt(str); }
/** * @since 2.9 */ protected final long _parseLongPrimitive(DeserializationContext ctxt, String text) throws IOException { try { return NumberInput.parseLong(text); } catch (IllegalArgumentException iae) { } { Number v = (Number) ctxt.handleWeirdStringValue(_valueClass, text, "not a valid long value"); return _nonNullNumber(v).longValue(); } }
private final static int _parseIndex(String str) { final int len = str.length(); // [core#133]: beware of super long indexes; assume we never // have arrays over 2 billion entries so ints are fine. if (len == 0 || len > 10) { return -1; } // [core#176]: no leading zeroes allowed char c = str.charAt(0); if (c <= '0') { return (len == 1 && c == '0') ? 0 : -1; } if (c > '9') { return -1; } for (int i = 1; i < len; ++i) { c = str.charAt(i); if (c > '9' || c < '0') { return -1; } } if (len == 10) { long l = NumberInput.parseLong(str); if (l > Integer.MAX_VALUE) { return -1; } } return NumberInput.parseInt(str); }
private final static int _parseIndex(String str) { final int len = str.length(); // [core#133]: beware of super long indexes; assume we never // have arrays over 2 billion entries so ints are fine. if (len == 0 || len > 10) { return -1; } // [core#176]: no leading zeroes allowed char c = str.charAt(0); if (c <= '0') { return (len == 1 && c == '0') ? 0 : -1; } if (c > '9') { return -1; } for (int i = 1; i < len; ++i) { c = str.charAt(i); if (c > '9' || c < '0') { return -1; } } if (len == 10) { long l = NumberInput.parseLong(str); if (l > Integer.MAX_VALUE) { return -1; } } return NumberInput.parseInt(str); }
private final static int _parseIndex(String str) { final int len = str.length(); // [core#133]: beware of super long indexes; assume we never // have arrays over 2 billion entries so ints are fine. if (len == 0 || len > 10) { return -1; } // [core#176]: no leading zeroes allowed char c = str.charAt(0); if (c <= '0') { return (len == 1 && c == '0') ? 0 : -1; } if (c > '9') { return -1; } for (int i = 1; i < len; ++i) { c = str.charAt(i); if (c > '9' || c < '0') { return -1; } } if (len == 10) { long l = NumberInput.parseLong(str); if (l > Integer.MAX_VALUE) { return -1; } } return NumberInput.parseInt(str); }
protected final long _parseLongPrimitive(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonToken t = jp.getCurrentToken(); if (t == JsonToken.VALUE_NUMBER_INT || t == JsonToken.VALUE_NUMBER_FLOAT) { return jp.getLongValue(); } if (t == JsonToken.VALUE_STRING) { String text = jp.getText().trim(); if (text.length() == 0) { return 0L; } try { return NumberInput.parseLong(text); } catch (IllegalArgumentException iae) { } throw ctxt.weirdStringException(_valueClass, "not a valid long value"); } if (t == JsonToken.VALUE_NULL) { return 0L; } throw ctxt.mappingException(_valueClass, t); }
protected final long _parseLongPrimitive(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonToken t = jp.getCurrentToken(); if (t == JsonToken.VALUE_NUMBER_INT || t == JsonToken.VALUE_NUMBER_FLOAT) { return jp.getLongValue(); } if (t == JsonToken.VALUE_STRING) { String text = jp.getText().trim(); if (text.length() == 0) { return 0L; } try { return NumberInput.parseLong(text); } catch (IllegalArgumentException iae) { } throw ctxt.weirdStringException(text, _valueClass, "not a valid long value"); } if (t == JsonToken.VALUE_NULL) { return 0L; } throw ctxt.mappingException(_valueClass, t); }
protected final Long _parseLong(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonToken t = jp.getCurrentToken(); // it should be ok to coerce (although may fail, too) if (t == JsonToken.VALUE_NUMBER_INT || t == JsonToken.VALUE_NUMBER_FLOAT) { return jp.getLongValue(); } // let's allow Strings to be converted too if (t == JsonToken.VALUE_STRING) { // !!! 05-Jan-2009, tatu: Should we try to limit value space, JDK is too lenient? String text = jp.getText().trim(); if (text.length() == 0) { return (Long) getEmptyValue(); } try { return Long.valueOf(NumberInput.parseLong(text)); } catch (IllegalArgumentException iae) { } throw ctxt.weirdStringException(_valueClass, "not a valid Long value"); } if (t == JsonToken.VALUE_NULL) { return (Long) getNullValue(); } // Otherwise, no can do: throw ctxt.mappingException(_valueClass, t); }
protected final Long _parseLong(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonToken t = jp.getCurrentToken(); // it should be ok to coerce (although may fail, too) if (t == JsonToken.VALUE_NUMBER_INT || t == JsonToken.VALUE_NUMBER_FLOAT) { return jp.getLongValue(); } // let's allow Strings to be converted too if (t == JsonToken.VALUE_STRING) { // !!! 05-Jan-2009, tatu: Should we try to limit value space, JDK is too lenient? String text = jp.getText().trim(); if (text.length() == 0) { return (Long) getEmptyValue(); } try { return Long.valueOf(NumberInput.parseLong(text)); } catch (IllegalArgumentException iae) { } throw ctxt.weirdStringException(text, _valueClass, "not a valid Long value"); } if (t == JsonToken.VALUE_NULL) { return (Long) getNullValue(); } // Otherwise, no can do: throw ctxt.mappingException(_valueClass, t); }
return NumberInput.parseLong(text); } catch (IllegalArgumentException iae) { } throw ctxt.weirdStringException(text, _valueClass, "not a valid long value");
return NumberInput.parseLong(text); } catch (IllegalArgumentException iae) { } throw ctxt.weirdStringException(text, _valueClass, "not a valid long value");