@@ -58,6 +58,11 @@ public class TokenBuffer
58
58
*/
59
59
protected int _generatorFeatures ;
60
60
61
+ /**
62
+ * @since 2.15
63
+ */
64
+ protected StreamReadConstraints _streamReadConstraints = StreamReadConstraints .defaults ();
65
+
61
66
protected boolean _closed ;
62
67
63
68
/**
@@ -170,6 +175,7 @@ public TokenBuffer(JsonParser p) {
170
175
public TokenBuffer (JsonParser p , DeserializationContext ctxt )
171
176
{
172
177
_objectCodec = p .getCodec ();
178
+ _streamReadConstraints = p .streamReadConstraints ();
173
179
_parentContext = p .getParsingContext ();
174
180
_generatorFeatures = DEFAULT_GENERATOR_FEATURES ;
175
181
_writeContext = JsonWriteContext .createRootContext (null );
@@ -273,16 +279,26 @@ public JsonParser asParserOnFirstToken() throws IOException {
273
279
*/
274
280
public JsonParser asParser (ObjectCodec codec )
275
281
{
276
- return new Parser (_first , codec , _hasNativeTypeIds , _hasNativeObjectIds , _parentContext );
282
+ return new Parser (_first , codec , _hasNativeTypeIds , _hasNativeObjectIds , _parentContext , _streamReadConstraints );
283
+ }
284
+
285
+ /**
286
+ * @param streamReadConstraints constraints for streaming reads
287
+ * @since v2.15
288
+ */
289
+ public JsonParser asParser (StreamReadConstraints streamReadConstraints )
290
+ {
291
+ return new Parser (_first , _objectCodec , _hasNativeTypeIds , _hasNativeObjectIds , _parentContext , streamReadConstraints );
277
292
}
278
293
279
294
/**
280
295
* @param src Parser to use for accessing source information
281
- * like location, configured codec
296
+ * like location, configured codec, streamReadConstraints
282
297
*/
283
298
public JsonParser asParser (JsonParser src )
284
299
{
285
- Parser p = new Parser (_first , src .getCodec (), _hasNativeTypeIds , _hasNativeObjectIds , _parentContext );
300
+ Parser p = new Parser (_first , src .getCodec (), _hasNativeTypeIds , _hasNativeObjectIds ,
301
+ _parentContext , src .streamReadConstraints ());
286
302
p .setLocation (src .getTokenLocation ());
287
303
return p ;
288
304
}
@@ -1441,6 +1457,11 @@ protected final static class Parser
1441
1457
1442
1458
protected ObjectCodec _codec ;
1443
1459
1460
+ /**
1461
+ * @since 2.15
1462
+ */
1463
+ protected StreamReadConstraints _streamReadConstraints ;
1464
+
1444
1465
/**
1445
1466
* @since 2.3
1446
1467
*/
@@ -1493,10 +1514,18 @@ public Parser(Segment firstSeg, ObjectCodec codec,
1493
1514
{
1494
1515
this (firstSeg , codec , hasNativeTypeIds , hasNativeObjectIds , null );
1495
1516
}
1496
-
1517
+
1518
+ @ Deprecated // since 2.15
1519
+ public Parser (Segment firstSeg , ObjectCodec codec ,
1520
+ boolean hasNativeTypeIds , boolean hasNativeObjectIds ,
1521
+ JsonStreamContext parentContext )
1522
+ {
1523
+ this (firstSeg , codec , hasNativeTypeIds , hasNativeObjectIds , parentContext , StreamReadConstraints .defaults ());
1524
+ }
1525
+
1497
1526
public Parser (Segment firstSeg , ObjectCodec codec ,
1498
1527
boolean hasNativeTypeIds , boolean hasNativeObjectIds ,
1499
- JsonStreamContext parentContext )
1528
+ JsonStreamContext parentContext , StreamReadConstraints streamReadConstraints )
1500
1529
{
1501
1530
// 25-Jun-2022, tatu: Ideally would pass parser flags along (as
1502
1531
// per [databund#3528]) but for now make sure not to clear the flags
@@ -1505,6 +1534,7 @@ public Parser(Segment firstSeg, ObjectCodec codec,
1505
1534
_segment = firstSeg ;
1506
1535
_segmentPtr = -1 ; // not yet read
1507
1536
_codec = codec ;
1537
+ _streamReadConstraints = streamReadConstraints ;
1508
1538
_parsingContext = TokenBufferReadContext .createRootContext (parentContext );
1509
1539
_hasNativeTypeIds = hasNativeTypeIds ;
1510
1540
_hasNativeObjectIds = hasNativeObjectIds ;
@@ -1541,11 +1571,9 @@ public JacksonFeatureSet<StreamReadCapability> getReadCapabilities() {
1541
1571
return DEFAULT_READ_CAPABILITIES ;
1542
1572
}
1543
1573
1544
- // 03-Dec-2022, tatu: Not 100% sure what to do here; could probably instead
1545
- // pass from somewhere?
1546
1574
@ Override
1547
1575
public StreamReadConstraints streamReadConstraints () {
1548
- return StreamReadConstraints . defaults () ;
1576
+ return _streamReadConstraints ;
1549
1577
}
1550
1578
1551
1579
/*
0 commit comments