public DataItem decodeNext ( ) throws CborException { int symbol ; try { symbol = inputStream . read ( ) ; } catch ( IOException ioException ) { throw new CborException ( ioException ) ; } if ( symbol == - 1 ) { return null ; } switch ( MajorType . ofByte ( symbol ) ) { case ARRAY : return arrayDecoder . decode ( symbol ) ; case BYTE_STRING : return byteStringDecoder . decode ( symbol ) ; case MAP : return mapDecoder . decode ( symbol ) ; case NEGATIVE_INTEGER : return negativeIntegerDecoder . decode ( symbol ) ; case UNICODE_STRING : return unicodeStringDecoder . decode ( symbol ) ; case UNSIGNED_INTEGER : return unsignedIntegerDecoder . decode ( symbol ) ; case SPECIAL : return specialDecoder . decode ( symbol ) ; case TAG : Tag tag = tagDecoder . decode ( symbol ) ; DataItem next = decodeNext ( ) ; if ( next == null ) { throw new CborException ( "Unexpected end of stream: tag without following data item." ) ; } else { if ( autoDecodeRationalNumbers && tag . getValue ( ) == 30 ) { return decodeRationalNumber ( next ) ; } else if ( autoDecodeLanguageTaggedStrings && tag . getValue ( ) == 38 ) { return decodeLanguageTaggedString ( next ) ; } else { DataItem itemToTag = next ; while ( itemToTag . hasTag ( ) ) itemToTag = itemToTag . getTag ( ) ; itemToTag . setTag ( tag ) ; return next ; } } case INVALID : default : throw new CborException ( "Not implemented major type " + symbol ) ; } }
Decodes exactly one DataItem from the input stream .