@@ -71,9 +71,11 @@ public class JBBPBitInputStream extends FilterInputStream implements JBBPCountab
71
71
private long markedByteCounter ;
72
72
73
73
/**
74
- * Internal flag shows that read stopped for reach of array limiter.
74
+ * Internal flag shows that read stopped for whole stream array read limit reach.
75
+ *
76
+ * @since 2.1.0
75
77
*/
76
- private boolean arrayLimitDetected ;
78
+ private boolean detectedArrayLimit ;
77
79
78
80
/**
79
81
* Flag shows that read of array was stopped for array limiter restrictions.
@@ -82,8 +84,19 @@ public class JBBPBitInputStream extends FilterInputStream implements JBBPCountab
82
84
* @see JBBPArraySizeLimiter
83
85
* @since 2.1.0
84
86
*/
85
- public boolean isArrayLimitDetected () {
86
- return this .arrayLimitDetected ;
87
+ public boolean isDetectedArrayLimit () {
88
+ return this .detectedArrayLimit ;
89
+ }
90
+
91
+ /**
92
+ * Set value for array limit detected flag. It is important to set the flag for correct processing of parsing.
93
+ *
94
+ * @param value true or false.
95
+ * @see com.igormaznitsa.jbbp.JBBPParser
96
+ * @since 2.1.0
97
+ */
98
+ public void setDetectedArrayLimit (final boolean value ) {
99
+ this .detectedArrayLimit = value ;
87
100
}
88
101
89
102
/**
@@ -135,7 +148,7 @@ public boolean[] readBoolArray(final int items) throws IOException {
135
148
public boolean [] readBoolArray (final int items ,
136
149
final JBBPArraySizeLimiter arraySizeLimiter )
137
150
throws IOException {
138
- this .arrayLimitDetected = false ;
151
+ this .setDetectedArrayLimit ( false ) ;
139
152
int pos = 0 ;
140
153
byte [] buffer ;
141
154
if (items < 0 ) {
@@ -149,7 +162,7 @@ public boolean[] readBoolArray(final int items,
149
162
pos += read ;
150
163
151
164
if (isBreakReadWholeStream (pos , arraySizeLimiter )) {
152
- this .arrayLimitDetected = true ;
165
+ this .setDetectedArrayLimit ( true ) ;
153
166
final int limit = arraySizeLimiter .getArrayItemsLimit ();
154
167
if (limit < 0 ) {
155
168
pos = Math .min (pos , Math .abs (limit ));
@@ -346,7 +359,7 @@ private byte[] internalReadArray(
346
359
final JBBPArraySizeLimiter streamLimiter
347
360
) throws IOException {
348
361
final boolean readByteArray = bitNumber == null ;
349
- this .arrayLimitDetected = false ;
362
+ this .setDetectedArrayLimit ( false ) ;
350
363
int pos = 0 ;
351
364
if (items < 0 ) {
352
365
byte [] buffer = new byte [INITIAL_ARRAY_BUFFER_SIZE ];
@@ -363,7 +376,7 @@ private byte[] internalReadArray(
363
376
}
364
377
buffer [pos ++] = (byte ) next ;
365
378
if (isBreakReadWholeStream (pos , streamLimiter )) {
366
- this .arrayLimitDetected = true ;
379
+ this .setDetectedArrayLimit ( true ) ;
367
380
break ;
368
381
}
369
382
}
@@ -429,7 +442,7 @@ public short[] readShortArray(final int items, final JBBPByteOrder byteOrder) th
429
442
public short [] readShortArray (final int items , final JBBPByteOrder byteOrder ,
430
443
final JBBPArraySizeLimiter arraySizeLimiter )
431
444
throws IOException {
432
- this .arrayLimitDetected = false ;
445
+ this .setDetectedArrayLimit ( false ) ;
433
446
int pos = 0 ;
434
447
if (items < 0 ) {
435
448
short [] buffer = new short [INITIAL_ARRAY_BUFFER_SIZE ];
@@ -443,7 +456,7 @@ public short[] readShortArray(final int items, final JBBPByteOrder byteOrder,
443
456
}
444
457
buffer [pos ++] = (short ) next ;
445
458
if (isBreakReadWholeStream (pos , arraySizeLimiter )) {
446
- this .arrayLimitDetected = true ;
459
+ this .setDetectedArrayLimit ( true ) ;
447
460
break ;
448
461
}
449
462
}
@@ -500,7 +513,7 @@ public long[] readUIntArray(
500
513
final JBBPByteOrder byteOrder ,
501
514
final JBBPArraySizeLimiter arraySizeLimiter
502
515
) throws IOException {
503
- this .arrayLimitDetected = false ;
516
+ this .setDetectedArrayLimit ( false ) ;
504
517
int pos = 0 ;
505
518
if (items < 0 ) {
506
519
long [] buffer = new long [INITIAL_ARRAY_BUFFER_SIZE ];
@@ -514,7 +527,7 @@ public long[] readUIntArray(
514
527
}
515
528
buffer [pos ++] = next ;
516
529
if (isBreakReadWholeStream (pos , arraySizeLimiter )) {
517
- this .arrayLimitDetected = true ;
530
+ this .setDetectedArrayLimit ( true ) ;
518
531
break ;
519
532
}
520
533
}
@@ -569,7 +582,7 @@ public char[] readUShortArray(final int items, final JBBPByteOrder byteOrder) th
569
582
public char [] readUShortArray (final int items , final JBBPByteOrder byteOrder ,
570
583
final JBBPArraySizeLimiter arraySizeLimiter )
571
584
throws IOException {
572
- this .arrayLimitDetected = false ;
585
+ this .setDetectedArrayLimit ( false ) ;
573
586
int pos = 0 ;
574
587
if (items < 0 ) {
575
588
char [] buffer = new char [INITIAL_ARRAY_BUFFER_SIZE ];
@@ -583,7 +596,7 @@ public char[] readUShortArray(final int items, final JBBPByteOrder byteOrder,
583
596
}
584
597
buffer [pos ++] = (char ) next ;
585
598
if (isBreakReadWholeStream (pos , arraySizeLimiter )) {
586
- this .arrayLimitDetected = true ;
599
+ this .setDetectedArrayLimit ( true ) ;
587
600
break ;
588
601
}
589
602
}
@@ -635,7 +648,7 @@ public int[] readIntArray(final int items, final JBBPByteOrder byteOrder) throws
635
648
*/
636
649
public int [] readIntArray (final int items , final JBBPByteOrder byteOrder ,
637
650
final JBBPArraySizeLimiter arraySizeLimiter ) throws IOException {
638
- this .arrayLimitDetected = false ;
651
+ this .setDetectedArrayLimit ( false ) ;
639
652
int pos = 0 ;
640
653
if (items < 0 ) {
641
654
int [] buffer = new int [INITIAL_ARRAY_BUFFER_SIZE ];
@@ -649,7 +662,7 @@ public int[] readIntArray(final int items, final JBBPByteOrder byteOrder,
649
662
}
650
663
buffer [pos ++] = next ;
651
664
if (isBreakReadWholeStream (pos , arraySizeLimiter )) {
652
- this .arrayLimitDetected = true ;
665
+ this .setDetectedArrayLimit ( true ) ;
653
666
break ;
654
667
}
655
668
}
@@ -706,7 +719,7 @@ public float[] readFloatArray(
706
719
final JBBPByteOrder byteOrder ,
707
720
final JBBPArraySizeLimiter arraySizeLimiter
708
721
) throws IOException {
709
- this .arrayLimitDetected = false ;
722
+ this .setDetectedArrayLimit ( false ) ;
710
723
int pos = 0 ;
711
724
if (items < 0 ) {
712
725
float [] buffer = new float [INITIAL_ARRAY_BUFFER_SIZE ];
@@ -720,7 +733,7 @@ public float[] readFloatArray(
720
733
}
721
734
buffer [pos ++] = next ;
722
735
if (isBreakReadWholeStream (pos , arraySizeLimiter )) {
723
- this .arrayLimitDetected = true ;
736
+ this .setDetectedArrayLimit ( true ) ;
724
737
break ;
725
738
}
726
739
}
@@ -1072,7 +1085,7 @@ public long[] readLongArray(
1072
1085
final JBBPByteOrder byteOrder ,
1073
1086
final JBBPArraySizeLimiter arraySizeLimiter
1074
1087
) throws IOException {
1075
- this .arrayLimitDetected = false ;
1088
+ this .setDetectedArrayLimit ( false ) ;
1076
1089
int pos = 0 ;
1077
1090
if (items < 0 ) {
1078
1091
long [] buffer = new long [INITIAL_ARRAY_BUFFER_SIZE ];
@@ -1086,7 +1099,7 @@ public long[] readLongArray(
1086
1099
}
1087
1100
buffer [pos ++] = next ;
1088
1101
if (isBreakReadWholeStream (pos , arraySizeLimiter )) {
1089
- this .arrayLimitDetected = true ;
1102
+ this .setDetectedArrayLimit ( true ) ;
1090
1103
break ;
1091
1104
}
1092
1105
}
@@ -1205,7 +1218,7 @@ public double[] readDoubleArray(
1205
1218
final JBBPByteOrder byteOrder ,
1206
1219
final JBBPArraySizeLimiter arraySizeLimiter
1207
1220
) throws IOException {
1208
- this .arrayLimitDetected = false ;
1221
+ this .setDetectedArrayLimit ( false ) ;
1209
1222
int pos = 0 ;
1210
1223
if (items < 0 ) {
1211
1224
double [] buffer = new double [INITIAL_ARRAY_BUFFER_SIZE ];
@@ -1219,7 +1232,7 @@ public double[] readDoubleArray(
1219
1232
}
1220
1233
buffer [pos ++] = Double .longBitsToDouble (next );
1221
1234
if (isBreakReadWholeStream (pos , arraySizeLimiter )) {
1222
- this .arrayLimitDetected = true ;
1235
+ this .setDetectedArrayLimit ( true ) ;
1223
1236
break ;
1224
1237
}
1225
1238
}
@@ -1416,7 +1429,7 @@ public String[] readStringArray(
1416
1429
final JBBPByteOrder byteOrder ,
1417
1430
final JBBPArraySizeLimiter arraySizeLimiter
1418
1431
) throws IOException {
1419
- this .arrayLimitDetected = false ;
1432
+ this .setDetectedArrayLimit ( false ) ;
1420
1433
int pos = 0 ;
1421
1434
if (items < 0 ) {
1422
1435
String [] buffer = new String [INITIAL_ARRAY_BUFFER_SIZE ];
@@ -1430,7 +1443,7 @@ public String[] readStringArray(
1430
1443
}
1431
1444
buffer [pos ++] = next ;
1432
1445
if (isBreakReadWholeStream (pos , arraySizeLimiter )) {
1433
- this .arrayLimitDetected = true ;
1446
+ this .setDetectedArrayLimit ( true ) ;
1434
1447
break ;
1435
1448
}
1436
1449
}
0 commit comments