Skip to content

Commit ca29447

Browse files
committed
Merge branch '2.12'
2 parents 42dfa08 + be5af88 commit ca29447

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

src/main/java/com/fasterxml/jackson/core/StreamReadCapability.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,30 @@ public enum StreamReadCapability
2424
* Capability may be used for allowing secondary mapping of such duplicates
2525
* in case of using Tree Model (see {@link TreeNode}), or "untyped" databinding
2626
* (mapping content as generic {@link java.lang.Object}).
27-
*
2827
*<p>
29-
* Capability is typically {@code false}, hence default.
28+
* Capability is currently only enabled for XML format backend.
3029
*/
3130
DUPLICATE_PROPERTIES(false),
3231

32+
/**
33+
* Capability that indicates that data format may in some cases expose Scalar values
34+
* (whether typed or untyped) as Object values. There are additional access methods
35+
* at databind level: this capability may be used to decide whether to attempt to
36+
* use such methods especially in potentially ambiguous cases.
37+
*<p>
38+
* Capability is currently only enabled for XML format backend.
39+
*/
40+
SCALARS_AS_OBJECTS(false),
41+
42+
/**
43+
* Capability that indicates that data format only exposed "untyped" scalars: that is,
44+
* instead of Number, Boolean and String types all scalar values are reported as
45+
* text ({@link JsonToken#VALUE_STRING})
46+
* unless some sort of coercion is implied by caller.
47+
*<p>
48+
* This capability is true for many textual formats like CSV, Properties and XML.
49+
*/
50+
UNTYPED_SCALARS(false),
3351
;
3452

3553
/**
@@ -50,5 +68,4 @@ private StreamReadCapability(boolean defaultState) {
5068
public boolean enabledIn(int flags) { return (flags & _mask) != 0; }
5169
@Override
5270
public int getMask() { return _mask; }
53-
5471
}

src/test/java/com/fasterxml/jackson/core/json/JsonReadFeaturesTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ private void _testDefaultSettings(JsonParser p) throws Exception {
6161

6262
// [core#619]:
6363
assertFalse(p.getReadCapabilities().isEnabled(StreamReadCapability.DUPLICATE_PROPERTIES));
64+
assertFalse(p.getReadCapabilities().isEnabled(StreamReadCapability.SCALARS_AS_OBJECTS));
65+
assertFalse(p.getReadCapabilities().isEnabled(StreamReadCapability.UNTYPED_SCALARS));
6466

6567
p.close();
6668
}

src/test/java/com/fasterxml/jackson/core/read/NumberParsingTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,16 +269,22 @@ public void testLongParsing() throws Exception
269269
public void testLongBoundsChecks() throws Exception
270270
{
271271
String minLong = String.valueOf(Long.MIN_VALUE).substring(1);
272+
String belowMinLong = BigInteger.valueOf(Long.MIN_VALUE).subtract(BigInteger.ONE)
273+
.toString().substring(1);
272274
String maxLong = String.valueOf(Long.MAX_VALUE);
275+
String aboveMaxLong = BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.ONE).toString();
273276
final String VALUE_491 = "1323372036854775807"; // is within range (JACKSON-491)
274277
final String OVERFLOW = "9999999999999999999"; // and this one is clearly out
275278

276279
assertTrue(NumberInput.inLongRange(minLong, true));
277280
assertTrue(NumberInput.inLongRange(maxLong, false));
278281
assertTrue(NumberInput.inLongRange(VALUE_491, true));
279282
assertTrue(NumberInput.inLongRange(VALUE_491, false));
283+
280284
assertFalse(NumberInput.inLongRange(OVERFLOW, false));
281285
assertFalse(NumberInput.inLongRange(OVERFLOW, true));
286+
assertFalse(NumberInput.inLongRange(belowMinLong, true));
287+
assertFalse(NumberInput.inLongRange(aboveMaxLong, false));
282288

283289
char[] cbuf = minLong.toCharArray();
284290
assertTrue(NumberInput.inLongRange(cbuf, 0, cbuf.length, true));
@@ -287,9 +293,13 @@ public void testLongBoundsChecks() throws Exception
287293
cbuf = VALUE_491.toCharArray();
288294
assertTrue(NumberInput.inLongRange(cbuf, 0, cbuf.length, true));
289295
assertTrue(NumberInput.inLongRange(cbuf, 0, cbuf.length, false));
296+
290297
cbuf = OVERFLOW.toCharArray();
291298
assertFalse(NumberInput.inLongRange(cbuf, 0, cbuf.length, true));
292299
assertFalse(NumberInput.inLongRange(cbuf, 0, cbuf.length, false));
300+
301+
cbuf = aboveMaxLong.toCharArray();
302+
assertFalse(NumberInput.inLongRange(cbuf, 0, cbuf.length, false));
293303
}
294304

295305
/*

0 commit comments

Comments
 (0)