@@ -96,7 +96,7 @@ enum UnknownNumberParsing {
96
96
final int maxNumberDigits ;
97
97
private final int maxStringBuffer ;
98
98
99
- public JParser (
99
+ public JParser (
100
100
final char [] tmp ,
101
101
final byte [] buffer ,
102
102
final int length ,
@@ -125,7 +125,7 @@ public JParser(
125
125
* It will release reference to provided byte[] or InputStream input
126
126
*/
127
127
@ Override
128
- public void close () {
128
+ public final void close () {
129
129
buffer = originalBuffer ;
130
130
bufferLenWithExtraSpace = originalBufferLenWithExtraSpace ;
131
131
last = ' ' ;
@@ -137,7 +137,7 @@ public void close() {
137
137
}
138
138
139
139
@ Override
140
- public JParser process (final InputStream newStream ) {
140
+ public final JParser process (final InputStream newStream ) {
141
141
nameStack .clear ();
142
142
currentPosition = 0 ;
143
143
currentIndex = 0 ;
@@ -152,7 +152,7 @@ public JParser process(final InputStream newStream) {
152
152
}
153
153
154
154
@ Override
155
- public JParser process (final byte [] newBuffer , final int newLength ) {
155
+ public final JParser process (final byte [] newBuffer , final int newLength ) {
156
156
if (newBuffer != null ) {
157
157
buffer = newBuffer ;
158
158
bufferLenWithExtraSpace = buffer .length - 38 ; // maximum padding is for uuid
@@ -171,12 +171,12 @@ public JParser process(final byte[] newBuffer, final int newLength) {
171
171
/**
172
172
* Valid length of the input buffer.
173
173
*/
174
- int length () {
174
+ final int length () {
175
175
return length ;
176
176
}
177
177
178
178
@ Override
179
- public String toString () {
179
+ public final String toString () {
180
180
return new String (buffer , 0 , length , utf8 );
181
181
}
182
182
@@ -195,7 +195,7 @@ private static int readFully(final byte[] buffer, final InputStream stream, fina
195
195
196
196
private static class EmptyEOFException extends EOFException {
197
197
198
- static final long serialVersionUID = 1L ;
198
+ private static final long serialVersionUID = 1L ;
199
199
200
200
@ Override
201
201
public Throwable fillInStackTrace () {
@@ -245,7 +245,7 @@ private int prepareNextBlock() {
245
245
return available ;
246
246
}
247
247
248
- boolean isEndOfStream () {
248
+ final boolean isEndOfStream () {
249
249
if (stream == null ) {
250
250
return length == currentIndex ;
251
251
}
@@ -262,12 +262,12 @@ boolean isEndOfStream() {
262
262
* @return which was the last byte read
263
263
*/
264
264
@ Override
265
- public byte currentToken () {
265
+ public final byte currentToken () {
266
266
return currentIndex == 0 ? nextToken () : last ;
267
267
}
268
268
269
269
@ Override
270
- public String location () {
270
+ public final String location () {
271
271
final StringBuilder error = new StringBuilder (60 );
272
272
positionDescription (0 , error );
273
273
return error .toString ();
@@ -297,11 +297,11 @@ private void positionDescription(int offset, StringBuilder error) {
297
297
}
298
298
}
299
299
300
- int getCurrentIndex () {
300
+ final int getCurrentIndex () {
301
301
return currentIndex ;
302
302
}
303
303
304
- int scanNumber () {
304
+ final int scanNumber () {
305
305
tokenStart = currentIndex - 1 ;
306
306
int i = 1 ;
307
307
int ci = currentIndex ;
@@ -316,7 +316,7 @@ int scanNumber() {
316
316
return tokenStart ;
317
317
}
318
318
319
- char [] prepareBuffer (final int start , final int len ) {
319
+ final char [] prepareBuffer (final int start , final int len ) {
320
320
if (len > maxNumberDigits ) {
321
321
throw newParseErrorWith ("Too many digits detected in number" , len , "Too many digits detected in number" , len , "" );
322
322
}
@@ -331,15 +331,15 @@ char[] prepareBuffer(final int start, final int len) {
331
331
return _tmp ;
332
332
}
333
333
334
- boolean allWhitespace (final int start , final int end ) {
334
+ final boolean allWhitespace (final int start , final int end ) {
335
335
final byte [] _buf = buffer ;
336
336
for (int i = start ; i < end ; i ++) {
337
337
if (!WHITESPACE [_buf [i ] + 128 ]) return false ;
338
338
}
339
339
return true ;
340
340
}
341
341
342
- int findNonWhitespace (final int end ) {
342
+ final int findNonWhitespace (final int end ) {
343
343
final byte [] _buf = buffer ;
344
344
for (int i = end - 1 ; i > 0 ; i --) {
345
345
if (!WHITESPACE [_buf [i ] + 128 ]) return i + 1 ;
@@ -353,7 +353,7 @@ int findNonWhitespace(final int end) {
353
353
*
354
354
* @return temporary buffer
355
355
*/
356
- char [] readSimpleQuote () {
356
+ final char [] readSimpleQuote () {
357
357
if (last != '"' ) throw newParseError ("Expecting '\" ' for string start" );
358
358
int ci = tokenStart = currentIndex ;
359
359
try {
@@ -371,40 +371,40 @@ char[] readSimpleQuote() {
371
371
}
372
372
373
373
@ Override
374
- public int readInt () {
374
+ public final int readInt () {
375
375
if (isNullValue ()) return 0 ;
376
376
return NumberParser .deserializeInt (this );
377
377
}
378
378
379
379
@ Override
380
- public long readLong () {
380
+ public final long readLong () {
381
381
if (isNullValue ()) return 0L ;
382
382
return NumberParser .deserializeLong (this );
383
383
}
384
384
385
385
@ Override
386
- public short readShort () {
386
+ public final short readShort () {
387
387
return NumberParser .deserializeShort (this );
388
388
}
389
389
390
390
@ Override
391
- public double readDouble () {
391
+ public final double readDouble () {
392
392
if (isNullValue ()) return 0D ;
393
393
return NumberParser .deserializeDouble (this );
394
394
}
395
395
396
396
@ Override
397
- public BigDecimal readDecimal () {
397
+ public final BigDecimal readDecimal () {
398
398
return NumberParser .deserializeDecimal (this );
399
399
}
400
400
401
401
@ Override
402
- public BigInteger readBigInteger () {
402
+ public final BigInteger readBigInteger () {
403
403
return NumberParser .deserializeBigInt (this );
404
404
}
405
405
406
406
@ Override
407
- public boolean readBoolean () {
407
+ public final boolean readBoolean () {
408
408
if (wasTrue ()) {
409
409
return true ;
410
410
} else if (wasFalse () || isNullValue ()) {
@@ -422,13 +422,13 @@ public boolean readBoolean() {
422
422
* @return parsed string
423
423
*/
424
424
@ Override
425
- public String readString () {
425
+ public final String readString () {
426
426
final int len = parseString ();
427
427
//return valuesCache == null ? new String(chars, 0, len) : valuesCache.get(chars, len);
428
428
return new String (chars , 0 , len );
429
429
}
430
430
431
- int parseString () {
431
+ final int parseString () {
432
432
final int startIndex = currentIndex ;
433
433
if (last != '"' ) throw newParseError ("Expecting '\" ' for string start" );
434
434
else if (currentIndex == length ) throw newParseErrorAt ("Premature end of JSON string" , 0 );
@@ -633,7 +633,7 @@ private boolean wasWhiteSpace() {
633
633
}
634
634
635
635
@ Override
636
- public boolean hasNextStreamElement () {
636
+ public final boolean hasNextStreamElement () {
637
637
if (currentIndex >= length ) {
638
638
return false ;
639
639
}
@@ -651,7 +651,7 @@ public boolean hasNextStreamElement() {
651
651
}
652
652
653
653
@ Override
654
- public boolean hasNextElement () {
654
+ public final boolean hasNextElement () {
655
655
if (currentIndex >= length ) {
656
656
return false ;
657
657
}
@@ -677,7 +677,7 @@ public boolean hasNextElement() {
677
677
* @return next non-whitespace byte in the JSON input
678
678
*/
679
679
@ Override
680
- public byte nextToken () {
680
+ public final byte nextToken () {
681
681
read ();
682
682
if (WHITESPACE [last + 128 ]) {
683
683
while (wasWhiteSpace ()) {
@@ -687,11 +687,11 @@ public byte nextToken() {
687
687
return last ;
688
688
}
689
689
690
- long positionInStream (final int offset ) {
690
+ final long positionInStream (final int offset ) {
691
691
return currentPosition + currentIndex - offset ;
692
692
}
693
693
694
- int calcHash () {
694
+ final int calcHash () {
695
695
if (last != '"' ) throw newParseError ("Expecting '\" ' for attribute name start" );
696
696
tokenStart = currentIndex ;
697
697
int ci = currentIndex ;
@@ -784,7 +784,7 @@ private byte skipString() {
784
784
}
785
785
786
786
@ Override
787
- public String readRaw () {
787
+ public final String readRaw () {
788
788
readRawStartPosition = currentIndex - 1 ;
789
789
if (stream != null ) {
790
790
readRawBuffer = new ByteArrayOutputStream ();
@@ -805,7 +805,7 @@ public String readRaw() {
805
805
}
806
806
807
807
@ Override
808
- public void skipValue () {
808
+ public final void skipValue () {
809
809
skipNextValue ();
810
810
// go back one as nextToken() is called next
811
811
last = buffer [--currentIndex ];
@@ -881,7 +881,7 @@ private byte skipObject() {
881
881
}
882
882
883
883
@ Override
884
- public byte [] readBinary () {
884
+ public final byte [] readBinary () {
885
885
if (stream != null && Base64 .findEnd (buffer , currentIndex ) == buffer .length ) {
886
886
final int len = parseString ();
887
887
final byte [] input = new byte [len ];
@@ -899,7 +899,7 @@ public byte[] readBinary() {
899
899
}
900
900
901
901
@ Override
902
- public String nextField () {
902
+ public final String nextField () {
903
903
if (currentNames != null ) {
904
904
final int hash = calcHash ();
905
905
String key = currentNames .lookup (hash );
@@ -927,7 +927,7 @@ private String readKey() {
927
927
}
928
928
929
929
@ Override
930
- public boolean isNullValue () {
930
+ public final boolean isNullValue () {
931
931
if (last == 'n' ) {
932
932
if (currentIndex + 2 < length
933
933
&& buffer [currentIndex ] == 'u'
@@ -980,7 +980,7 @@ private boolean wasFalse() {
980
980
}
981
981
982
982
@ Override
983
- public void startStream () {
983
+ public final void startStream () {
984
984
if (last == '[' ) return ;
985
985
if (last == '{' ) {
986
986
// go back one
@@ -999,15 +999,15 @@ public void startStream() {
999
999
}
1000
1000
1001
1001
@ Override
1002
- public void endStream () {
1002
+ public final void endStream () {
1003
1003
// do nothing
1004
1004
}
1005
1005
1006
1006
/**
1007
1007
* Parse array start
1008
1008
*/
1009
1009
@ Override
1010
- public void startArray () {
1010
+ public final void startArray () {
1011
1011
if (last != '[' && nextToken () != '[' ) {
1012
1012
if (currentIndex >= length ) throw newParseErrorAt ("Unexpected end in JSON" , 0 , eof );
1013
1013
throw newParseError ("Expecting '[' as array start" );
@@ -1018,7 +1018,7 @@ public void startArray() {
1018
1018
* Parse array end
1019
1019
*/
1020
1020
@ Override
1021
- public void endArray () {
1021
+ public final void endArray () {
1022
1022
if (last != ']' && nextToken () != ']' ) {
1023
1023
if (currentIndex >= length ) throw newParseErrorAt ("Unexpected end in JSON" , 0 , eof );
1024
1024
throw newParseError ("Expecting ']' as array end" );
@@ -1036,7 +1036,7 @@ private void readStartObject() {
1036
1036
}
1037
1037
1038
1038
@ Override
1039
- public void startObject () {
1039
+ public final void startObject () {
1040
1040
readStartObject ();
1041
1041
if (currentNames != null ) {
1042
1042
nameStack .addFirst (currentNames );
@@ -1045,7 +1045,7 @@ public void startObject() {
1045
1045
}
1046
1046
1047
1047
@ Override
1048
- public void startObject (final JsonNames names ) {
1048
+ public final void startObject (final JsonNames names ) {
1049
1049
readStartObject ();
1050
1050
if (currentNames != null ) {
1051
1051
nameStack .addFirst (currentNames );
@@ -1057,7 +1057,7 @@ public void startObject(final JsonNames names) {
1057
1057
* Ensure object end
1058
1058
*/
1059
1059
@ Override
1060
- public void endObject () {
1060
+ public final void endObject () {
1061
1061
currentNames = nameStack .pollFirst ();
1062
1062
if (last != '}' && nextToken () != '}' ) {
1063
1063
if (currentIndex >= length ) throw newParseErrorAt ("Unexpected end in JSON" , 0 , eof );
@@ -1068,7 +1068,7 @@ public void endObject() {
1068
1068
private final StringBuilder error = new StringBuilder (0 );
1069
1069
private final Formatter errorFormatter = new Formatter (error );
1070
1070
1071
- JsonDataException newParseError (final String description ) {
1071
+ final JsonDataException newParseError (final String description ) {
1072
1072
error .setLength (0 );
1073
1073
error .append (description );
1074
1074
error .append (", instead found '" );
@@ -1083,7 +1083,7 @@ private String errorMessage() {
1083
1083
return error .toString ().replace ("\n " , "\\ n" );
1084
1084
}
1085
1085
1086
- JsonDataException newParseErrorAt (final String description , final int offset ) {
1086
+ final JsonDataException newParseErrorAt (final String description , final int offset ) {
1087
1087
if (errorInfo == ErrorInfo .MINIMAL || errorInfo == ErrorInfo .DESCRIPTION_ONLY ) {
1088
1088
return new JsonDataException (description );
1089
1089
}
@@ -1094,7 +1094,7 @@ JsonDataException newParseErrorAt(final String description, final int offset) {
1094
1094
return new JsonDataException (errorMessage ());
1095
1095
}
1096
1096
1097
- JsonDataException newParseErrorAt (final String description , final int offset , final Exception cause ) {
1097
+ final JsonDataException newParseErrorAt (final String description , final int offset , final Exception cause ) {
1098
1098
if (cause == null ) throw new IllegalArgumentException ("cause can't be null" );
1099
1099
if (errorInfo == ErrorInfo .MINIMAL ) return new JsonDataException (description , cause );
1100
1100
error .setLength (0 );
@@ -1113,7 +1113,7 @@ JsonDataException newParseErrorAt(final String description, final int offset, fi
1113
1113
return new JsonDataException (errorMessage ());
1114
1114
}
1115
1115
1116
- JsonDataException newParseErrorFormat (final String description , final int offset , final String extraFormat , Object ... args ) {
1116
+ final JsonDataException newParseErrorFormat (final String description , final int offset , final String extraFormat , Object ... args ) {
1117
1117
if (errorInfo == ErrorInfo .MINIMAL ) return new JsonDataException (description );
1118
1118
error .setLength (0 );
1119
1119
errorFormatter .format (extraFormat , args );
@@ -1123,11 +1123,11 @@ JsonDataException newParseErrorFormat(final String description, final int offset
1123
1123
return new JsonDataException (errorMessage ());
1124
1124
}
1125
1125
1126
- JsonDataException newParseErrorWith (String description , Object argument ) {
1126
+ final JsonDataException newParseErrorWith (String description , Object argument ) {
1127
1127
return newParseErrorWith (description , 0 , description , argument , "" );
1128
1128
}
1129
1129
1130
- JsonDataException newParseErrorWith (String description , int offset , String extra , Object extraArgument , String extraSuffix ) {
1130
+ final JsonDataException newParseErrorWith (String description , int offset , String extra , Object extraArgument , String extraSuffix ) {
1131
1131
if (errorInfo == ErrorInfo .MINIMAL ) return new JsonDataException (description );
1132
1132
error .setLength (0 );
1133
1133
error .append (extra );
0 commit comments