@Test public void testMSBMask() { int numBits = 1; int mask = BitBufferHelper.getMSBMask(numBits); Assert.assertTrue(mask == 128); numBits = 8; mask = BitBufferHelper.getMSBMask(numBits); Assert.assertTrue(mask == 255); numBits = 2; mask = BitBufferHelper.getMSBMask(numBits); Assert.assertTrue(mask == 192); }
public static int getMSBMask(int numBits) { int mask = 0; for (int i = 0; i < numBits; i++) { mask = mask | 1 << 7 - i; } return mask; }
BitBufferHelper { public static int getMSBMask(int numBits) { int mask = 0; for (int i = 0; i < numBits; i++) { mask = mask | 1 << 7 - i; } return mask; } }
BitBufferHelper { public static int getMSBMask(int numBits) { int mask = 0; for (int i = 0; i < numBits; i++) { mask = mask | 1 << 7 - i; } return mask; } private  BitBufferHelper(); }
BitBufferHelper { public static int getMSBMask(int numBits) { int mask = 0; for (int i = 0; i < numBits; i++) { mask = mask | 1 << 7 - i; } return mask; } private  BitBufferHelper(); static byte getByte(byte[] data); static short getShort(byte[] data, int numBits); static short getShort(byte[] data); static int getInt(byte[] data, int numBits); static int getInt(byte[] data); static long getLong(byte[] data, int numBits); static long getLong(byte[] data); static byte[] getBits(byte[] data, int startOffset, int numBits); static void setByte(byte[] data, byte input, int startOffset, int numBits); static void setBytes(byte[] data, byte[] input, int startOffset, int numBits); static int getMSBMask(int numBits); static int getLSBMask(int numBits); static long toNumber(byte[] array); static long toNumber(@Nonnull byte[] array, int numBits); static byte[] toByteArray(Number input); static byte[] toByteArray(Number input, int numBits); static byte[] shiftBitsToMSB(byte[] inputBytes, int numBits); static byte[] shiftBitsToLSB(byte[] inputBytes, int numBits); static void insertBits(byte[] data, byte[] inputdataLSB, int startOffset, int numBits); static void checkExceptions(byte[] data, int startOffset, int numBits); }
BitBufferHelper { public static int getMSBMask(int numBits) { int mask = 0; for (int i = 0; i < numBits; i++) { mask = mask | 1 << 7 - i; } return mask; } private  BitBufferHelper(); static byte getByte(byte[] data); static short getShort(byte[] data, int numBits); static short getShort(byte[] data); static int getInt(byte[] data, int numBits); static int getInt(byte[] data); static long getLong(byte[] data, int numBits); static long getLong(byte[] data); static byte[] getBits(byte[] data, int startOffset, int numBits); static void setByte(byte[] data, byte input, int startOffset, int numBits); static void setBytes(byte[] data, byte[] input, int startOffset, int numBits); static int getMSBMask(int numBits); static int getLSBMask(int numBits); static long toNumber(byte[] array); static long toNumber(@Nonnull byte[] array, int numBits); static byte[] toByteArray(Number input); static byte[] toByteArray(Number input, int numBits); static byte[] shiftBitsToMSB(byte[] inputBytes, int numBits); static byte[] shiftBitsToLSB(byte[] inputBytes, int numBits); static void insertBits(byte[] data, byte[] inputdataLSB, int startOffset, int numBits); static void checkExceptions(byte[] data, int startOffset, int numBits); static final long BYTE_MASK; }