static protected int getPadBits ( int bitString ) { int val = 0 ; for ( int i = 3 ; i >= 0 ; i -- ) { // // this may look a little odd, but if it isn't done like this pre jdk1.2 // JVM's break! // if ( i != 0 ) { if ( ( bitString >> ( i * 8 ) ) != 0 ) { val = ( bitString >> ( i * 8 ) ) & 0xFF ; break ; } } else { if ( bitString != 0 ) { val = bitString & 0xFF ; break ; } } } if ( val == 0 ) { return 7 ; } int bits = 1 ; while ( ( ( val <<= 1 ) & 0xFF ) != 0 ) { bits ++ ; } return 8 - bits ; }
return the correct number of pad bits for a bit string defined in a 32 bit constant