public void skipValue ( int count ) throws IOException { while ( count > 0 ) { byte b = readByte ( ) ; MessageFormat f = MessageFormat . valueOf ( b ) ; switch ( f ) { case POSFIXINT : case NEGFIXINT : case BOOLEAN : case NIL : break ; case FIXMAP : { int mapLen = b & 0x0f ; count += mapLen * 2 ; break ; } case FIXARRAY : { int arrayLen = b & 0x0f ; count += arrayLen ; break ; } case FIXSTR : { int strLen = b & 0x1f ; skipPayload ( strLen ) ; break ; } case INT8 : case UINT8 : skipPayload ( 1 ) ; break ; case INT16 : case UINT16 : skipPayload ( 2 ) ; break ; case INT32 : case UINT32 : case FLOAT32 : skipPayload ( 4 ) ; break ; case INT64 : case UINT64 : case FLOAT64 : skipPayload ( 8 ) ; break ; case BIN8 : case STR8 : skipPayload ( readNextLength8 ( ) ) ; break ; case BIN16 : case STR16 : skipPayload ( readNextLength16 ( ) ) ; break ; case BIN32 : case STR32 : skipPayload ( readNextLength32 ( ) ) ; break ; case FIXEXT1 : skipPayload ( 2 ) ; break ; case FIXEXT2 : skipPayload ( 3 ) ; break ; case FIXEXT4 : skipPayload ( 5 ) ; break ; case FIXEXT8 : skipPayload ( 9 ) ; break ; case FIXEXT16 : skipPayload ( 17 ) ; break ; case EXT8 : skipPayload ( readNextLength8 ( ) + 1 ) ; break ; case EXT16 : skipPayload ( readNextLength16 ( ) + 1 ) ; break ; case EXT32 : skipPayload ( readNextLength32 ( ) + 1 ) ; break ; case ARRAY16 : count += readNextLength16 ( ) ; break ; case ARRAY32 : count += readNextLength32 ( ) ; break ; case MAP16 : count += readNextLength16 ( ) * 2 ; break ; case MAP32 : count += readNextLength32 ( ) * 2 ; // TODO check int overflow break ; case NEVER_USED : throw new MessageNeverUsedFormatException ( "Encountered 0xC1 \"NEVER_USED\" byte" ) ; } count -- ; } }
Skip next values then move the cursor at the end of the value