|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.edg.data.util.BitUtils
A set of helper methods useful when working with byte[]
that
actually need to be manipulated on the bit level, not the byte level. We
support bit arrays up to 2^^31
bits long.
We assume that range checking on the array has already been done for indexes;
we just throw the underlying IndexOutOfBoundsException
.
Method Summary | |
static int |
bitsToBytes(int bits)
return the number of bytes needed to hold this number of bits. |
static java.lang.String |
byteArrayToString(byte[] bits,
int numBits)
given a bit bits, turn it into a string of bits |
static void |
clearBit(byte[] bits,
int bit)
clear a bit in the bit array |
static byte |
decrHighNybble(byte b)
decrement the high nybble, treating it a an unsigned nybble. |
static byte |
decrLowNybble(byte b)
decrement the low nybble, treating it a an unsigned nybble. |
static int |
fourByteToInt(byte b0,
byte b1,
byte b2,
byte b3)
|
static byte |
highNybble(byte b)
|
static byte |
incrHighNybble(byte b)
increment the high nybble, treating it a an unsigned nybble. |
static byte |
incrLowNybble(byte b)
descrement the high nybble, treating it a an unsigned nybble. |
static boolean |
isSet(byte[] bits,
int bit)
Is a bit set in the bit array. |
static byte |
lowNybble(byte b)
|
static int |
numBytes(int number)
return the number of 8 bit bytes needed to represent this positive integer. |
static void |
setBit(byte[] bits,
int bit)
set a bit in the bit array |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static final int numBytes(int number)
number
- the number
public static final int bitsToBytes(int bits)
bits
- the bit array
public static final void setBit(byte[] bits, int bit)
bits
- the bit arraybit
- the bit to setpublic static final void clearBit(byte[] bits, int bit)
bits
- the bit arraybit
- the bit to setpublic static final boolean isSet(byte[] bits, int bit)
bits
- the bit arraybit
- the bit to check
true
if the bit is setpublic static final java.lang.String byteArrayToString(byte[] bits, int numBits)
bits
- the bit bitsnumBits
- the number of bits in the bits
public static int fourByteToInt(byte b0, byte b1, byte b2, byte b3)
public static byte incrHighNybble(byte b)
b
- the byte
public static byte decrHighNybble(byte b)
b
- the byte
public static byte incrLowNybble(byte b)
b
- the byte
public static byte decrLowNybble(byte b)
b
- the byte
public static byte lowNybble(byte b)
public static byte highNybble(byte b)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |