private int readInteger ( ) { int b = buf . get ( ) ; if ( buf . hasRemaining ( ) ) { int n = 0 ; int result = 0 ; while ( ( b & 0x80 ) != 0 && n < 3 ) { result <<= 7 ; result |= ( b & 0x7f ) ; b = buf . get ( ) ; n ++ ; } if ( n < 3 ) { result <<= 7 ; result |= b ; } else { // use all 8 bits from the 4th byte result <<= 8 ; result |= b & 0x0ff ; // check if the integer should be negative if ( ( result & 0x10000000 ) != 0 ) { // extend the sign bit result |= 0xe0000000 ; } } return result ; } return b ; }
Parser of AMF3 compressed integer data type