@@ -712,6 +712,9 @@ public JsonToken nextToken() throws IOException
712
712
case 2 : // byte[]
713
713
_typeByte = ch ;
714
714
_tokenIncomplete = true ;
715
+ if (_tagValue >= 0 ) {
716
+ return _nextBinaryWithTag (_tagValue );
717
+ }
715
718
return (_currToken = JsonToken .VALUE_EMBEDDED_OBJECT );
716
719
717
720
case 3 : // String
@@ -777,16 +780,6 @@ public JsonToken nextToken() throws IOException
777
780
}
778
781
return null ;
779
782
}
780
-
781
- protected JsonToken _handleCBOREOF () throws IOException {
782
- /* NOTE: here we can and should close input, release buffers,
783
- * since this is "hard" EOF, not a boundary imposed by
784
- * header token.
785
- */
786
- _tagValue = -1 ;
787
- close ();
788
- return (_currToken = null );
789
- }
790
783
791
784
protected String _numberToName (int ch , boolean neg ) throws IOException
792
785
{
@@ -823,17 +816,33 @@ protected String _numberToName(int ch, boolean neg) throws IOException
823
816
return String .valueOf (1 );
824
817
}
825
818
826
- // base impl is fine:
827
- //public String getCurrentName() throws IOException
828
-
829
- protected void _invalidToken (int ch ) throws JsonParseException {
830
- ch &= 0xFF ;
831
- if (ch == 0xFF ) {
832
- throw _constructError ("Mismatched BREAK byte (0xFF): encountered where value expected" );
819
+ protected JsonToken _nextBinaryWithTag (int tag ) throws IOException
820
+ {
821
+ // For now all we should get is BigInteger
822
+
823
+ boolean neg ;
824
+ if (tag == CBORConstants .TAG_BIGNUM_POS ) {
825
+ neg = false ;
826
+ } else if (tag == CBORConstants .TAG_BIGNUM_NEG ) {
827
+ neg = true ;
828
+ } else {
829
+ // 12-May-2016, tatu: Since that's all we know, let's otherwise
830
+ // just return default Binary data marker
831
+ return (_currToken = JsonToken .VALUE_EMBEDDED_OBJECT );
833
832
}
834
- throw _constructError ("Invalid CBOR value token (first byte): 0x" +Integer .toHexString (ch ));
833
+
834
+ // First: get the data
835
+ _finishToken ();
836
+
837
+ _numberBigInt = new BigInteger (_binaryValue );
838
+ _numTypesValid |= NR_BIGINT ;
839
+
840
+ return (_currToken = JsonToken .VALUE_NUMBER_INT );
835
841
}
836
842
843
+ // base impl is fine:
844
+ //public String getCurrentName() throws IOException
845
+
837
846
/**
838
847
* Method for forcing full read of current token, even if it might otherwise
839
848
* only be read if data is accessed via {@link #getText} and similar methods.
@@ -2939,10 +2948,28 @@ protected void _handleEOF() throws JsonParseException {
2939
2948
2940
2949
/*
2941
2950
/**********************************************************
2942
- /* Internal methods, error reporting
2951
+ /* Internal methods, error handling, reporting
2943
2952
/**********************************************************
2944
2953
*/
2945
2954
2955
+ protected JsonToken _handleCBOREOF () throws IOException {
2956
+ /* NOTE: here we can and should close input, release buffers,
2957
+ * since this is "hard" EOF, not a boundary imposed by
2958
+ * header token.
2959
+ */
2960
+ _tagValue = -1 ;
2961
+ close ();
2962
+ return (_currToken = null );
2963
+ }
2964
+
2965
+ protected void _invalidToken (int ch ) throws JsonParseException {
2966
+ ch &= 0xFF ;
2967
+ if (ch == 0xFF ) {
2968
+ throw _constructError ("Mismatched BREAK byte (0xFF): encountered where value expected" );
2969
+ }
2970
+ throw _constructError ("Invalid CBOR value token (first byte): 0x" +Integer .toHexString (ch ));
2971
+ }
2972
+
2946
2973
protected void _reportUnexpectedBreak () throws IOException {
2947
2974
if (_parsingContext .inRoot ()) {
2948
2975
throw _constructError ("Unexpected Break (0xFF) token in Root context" );
0 commit comments