|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.alien.enterpriseRFID.util.BitMath
Bit Math contains a number of methods for bitwise manipulate of byte data commonly found in RFID scenarios.
Constructor Summary | |
BitMath()
|
Method Summary | |
static int |
generateCRC16Checksum09(byte[] byteArray,
int offset,
int length)
Generates a CRC-type checksum used to store an EPC-64 ID. |
static int |
generateCRC16Checksum10(byte[] byteArray,
int offset,
int length)
Generates a CRC-type checksum used to store an EPC-64 ID. |
static int |
generateCRC16Checksum10(java.lang.String tagID)
Generates a CRC-type checksum for a Tag ID string. |
static short |
generateLRC16Checksum(byte[] byteArray,
int offset,
int length)
Generates an LRC16-type checksum over a portion of a byteArray. |
static byte[] |
getBitArray(byte[] byteArray)
Returns an array of bits, given an array of bytes. |
static byte[] |
getBitArray(byte[] byteArray,
int offset,
int length)
Get Bit Array from an array of bytes, specifying the offset and length to extract data from within the byte array. |
static byte[] |
getByteArray(byte[] bitArray)
Get an array of bytes from an array of bits. |
static long |
getValue(byte[] bitArray,
int start,
int length)
Return a long value from a bit array. |
static byte[] |
reverseBitArray(byte[] bitArray)
Reverses the order of a bit array. |
static byte[] |
setValue(byte[] bitArray,
long value,
int start,
int length)
Inserts values into an existing bit array. |
static void |
validate(java.lang.String valueName,
long value,
int bitCount)
Ensures a given number is small enough to fit within a certain number of bits. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public BitMath()
Method Detail |
public static byte[] reverseBitArray(byte[] bitArray)
bitArray
- an array of bytes to be reversed
public static byte[] getBitArray(byte[] byteArray) throws java.lang.IllegalArgumentException
byteArray
- the array of bytes to extract data from
java.lang.IllegalArgumentException
- if the byteArray is nullpublic static byte[] getBitArray(byte[] byteArray, int offset, int length) throws java.lang.IllegalArgumentException
byteArray
- the array of bytes to extract data fromoffset
- the start offset to start getting bits of data fromlength
- the number of bytes to include
java.lang.IllegalArgumentException
- if the byteArray is nullpublic static byte[] getByteArray(byte[] bitArray) throws java.lang.IllegalArgumentException
bitArray
- the array of bits to extract data from
java.lang.IllegalArgumentException
- if the bitArray is nullpublic static long getValue(byte[] bitArray, int start, int length) throws java.lang.IllegalArgumentException
bitArray
- the array of bits to extract data fromstart
- the starting Bit, from the left to get data fromlength
- the number of bits to extract
java.lang.IllegalArgumentException
- if the bitArray is null
java.lang.IllegalArgumentException
- if the start value is negative or larger than the bitArray's length
java.lang.IllegalArgumentException
- if the length start+length is longer than the bitArray's lengthpublic static byte[] setValue(byte[] bitArray, long value, int start, int length) throws java.lang.IllegalArgumentException
bitArray
- the bitArray to set values intovalue
- a long value containing the data to setstart
- the starting bit to insert into, from the leftlength
- the number of bits to fill in
java.lang.IllegalArgumentException
- if the bitArray is null
java.lang.IllegalArgumentException
- if the start is negative or greater than the bitArray's length
java.lang.IllegalArgumentException
- if the start+length is greater than the bitArray's lengthpublic static void validate(java.lang.String valueName, long value, int bitCount) throws java.lang.IllegalArgumentException
valueName
- a description of the value, for use in exception reportingvalue
- the value to validatebitCount
- the maximum number of bits
java.lang.IllegalArgumentException
- if the number of out of rangepublic static short generateLRC16Checksum(byte[] byteArray, int offset, int length)
byteArray
- the byte array to generate checksum foroffset
- the start offset at which to start generating checksum datalength
- the number of bytes to include in the checksum
public static int generateCRC16Checksum09(byte[] byteArray, int offset, int length) throws java.lang.IllegalArgumentException
byteArray
- the byte array over which to generate checksumoffset
- the start offset at which to start generating checksum datalength
- the number of bytes to include in the checksum
java.lang.IllegalArgumentException
- if the byteArray is nullpublic static int generateCRC16Checksum10(byte[] byteArray, int offset, int length) throws java.lang.IllegalArgumentException
byteArray
- the byte array over which to generate checksumoffset
- the start offset at which to start generating checksum datalength
- the number of bytes to include in the checksum
java.lang.IllegalArgumentException
- if the byteArray is nullpublic static int generateCRC16Checksum10(java.lang.String tagID) throws java.lang.IllegalArgumentException
tagID
- the string tag ID
java.lang.IllegalArgumentException
- if the tagID is empty or null
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |