public static int unpackInt ( final byte [ ] array , final JBBPIntCounter position ) { final int code = array [ position . getAndIncrement ( ) ] & 0xFF ; if ( code < 0x80 ) { return code ; } final int result ; switch ( code ) { case 0x80 : { result = ( ( array [ position . getAndIncrement ( ) ] & 0xFF ) << 8 ) | ( array [ position . getAndIncrement ( ) ] & 0xFF ) ; } break ; case 0x81 : { result = ( ( array [ position . getAndIncrement ( ) ] & 0xFF ) << 24 ) | ( ( array [ position . getAndIncrement ( ) ] & 0xFF ) << 16 ) | ( ( array [ position . getAndIncrement ( ) ] & 0xFF ) << 8 ) | ( array [ position . getAndIncrement ( ) ] & 0xFF ) ; } break ; default : throw new IllegalArgumentException ( "Unsupported packed integer prefix [0x" + Integer . toHexString ( code ) . toUpperCase ( Locale . ENGLISH ) + ' ' ) ; } return result ; }
Unpack an integer value from defined position in a byte array .