Skip to content

Commit 83005ad

Browse files
authored
make more use of NumberInput (#3458)
1 parent 3cd0b8c commit 83005ad

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/main/java/com/fasterxml/jackson/databind/deser/std/NumberDeserializers.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.util.HashSet;
77

88
import com.fasterxml.jackson.core.*;
9-
import com.fasterxml.jackson.core.io.BigDecimalParser;
109
import com.fasterxml.jackson.core.io.NumberInput;
1110
import com.fasterxml.jackson.databind.*;
1211
import com.fasterxml.jackson.databind.annotation.JacksonStdImpl;
@@ -829,14 +828,14 @@ public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOEx
829828
try {
830829
if (!_isIntNumber(text)) {
831830
if (ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
832-
return BigDecimalParser.parse(text);
831+
return NumberInput.parseBigDecimal(text);
833832
}
834833
return Double.valueOf(text);
835834
}
836835
if (ctxt.isEnabled(DeserializationFeature.USE_BIG_INTEGER_FOR_INTS)) {
837836
return new BigInteger(text);
838837
}
839-
long value = Long.parseLong(text);
838+
long value = NumberInput.parseLong(text);
840839
if (!ctxt.isEnabled(DeserializationFeature.USE_LONG_FOR_INTS)) {
841840
if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) {
842841
return Integer.valueOf((int) value);
@@ -1006,7 +1005,7 @@ public BigDecimal deserialize(JsonParser p, DeserializationContext ctxt)
10061005
return getNullValue(ctxt);
10071006
}
10081007
try {
1009-
return BigDecimalParser.parse(text);
1008+
return NumberInput.parseBigDecimal(text);
10101009
} catch (IllegalArgumentException iae) { }
10111010
return (BigDecimal) ctxt.handleWeirdStringValue(_valueClass, text,
10121011
"not a valid representation");

src/main/java/com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,11 @@ protected Object _parse(String key, DeserializationContext ctxt) throws Exceptio
251251
*/
252252

253253
protected int _parseInt(String key) throws IllegalArgumentException {
254-
return Integer.parseInt(key);
254+
return NumberInput.parseInt(key);
255255
}
256256

257257
protected long _parseLong(String key) throws IllegalArgumentException {
258-
return Long.parseLong(key);
258+
return NumberInput.parseLong(key);
259259
}
260260

261261
protected double _parseDouble(String key) throws IllegalArgumentException {

src/main/java/com/fasterxml/jackson/databind/util/TokenBuffer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import com.fasterxml.jackson.core.*;
99
import com.fasterxml.jackson.core.base.ParserMinimalBase;
10+
import com.fasterxml.jackson.core.io.NumberInput;
1011
import com.fasterxml.jackson.core.json.JsonWriteContext;
1112
import com.fasterxml.jackson.core.util.ByteArrayBuilder;
1213
import com.fasterxml.jackson.core.util.JacksonFeatureSet;
@@ -1844,9 +1845,9 @@ public final Number getNumberValue() throws IOException {
18441845
if (value instanceof String) {
18451846
String str = (String) value;
18461847
if (str.indexOf('.') >= 0) {
1847-
return Double.parseDouble(str);
1848+
return NumberInput.parseDouble(str);
18481849
}
1849-
return Long.parseLong(str);
1850+
return NumberInput.parseLong(str);
18501851
}
18511852
if (value == null) {
18521853
return null;

0 commit comments

Comments
 (0)