public Integer decode(ByteBuffer buffer){
  byte b=buffer.get();
  int result=b & 0x7F;
  if ((b & 0x80) != 0) {
    b=buffer.get();
    result|=(b & 0x7F) << 7;
    if ((b & 0x80) != 0) {
      b=buffer.get();
      result|=(b & 0x7F) << 14;
      if ((b & 0x80) != 0) {
        b=buffer.get();
        result|=(b & 0x7F) << 21;
        if ((b & 0x80) != 0) {
          b=buffer.get();
          result|=(b & 0x7F) << 28;
        }
      }
    }
  }
  return Integer.valueOf(result);
}

public Integer decode ( ByteBuffer buffer ) { byte b = buffer . get ( ) ; int result = b & 0x7F ; if ( ( b & 0x80 ) != 0 ) { b = buffer . get ( ) ; result |= ( b & 0x7F ) << 7 ; if ( ( b & 0x80 ) != 0 ) { b = buffer . get ( ) ; result |= ( b & 0x7F ) << 14 ; if ( ( b & 0x80 ) != 0 ) { b = buffer . get ( ) ; result |= ( b & 0x7F ) << 21 ; if ( ( b & 0x80 ) != 0 ) { b = buffer . get ( ) ; result |= ( b & 0x7F ) << 28 ; } } } } return Integer . valueOf ( result ) ; }
decode the integer from the byte buffer . the input byte buffer should be readable , and it read from its current position .
