public class MessageUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static boolean |
booleanFromByte(byte[] data,
int offset)
Converts a byte into a boolean.
|
static boolean |
booleanFromNumber(int data)
Parses an integer from a boolean.
|
static java.lang.String |
getHexString(byte[] data)
Converts a byte array to a text string of hexadecimal numbers.
|
static java.lang.String |
getHexString(int number)
Converts a number to a text string of hexadecimal numbers.
|
static boolean |
inRange(int value,
int min,
int max)
Checks to see if a given value is within a set range.
|
static boolean |
isFlagSet(int flagMask,
byte[] data,
int offset)
Performs the same operation as
isFlagSet(int, int) , using a byte from a byte
array as the bit set. |
static boolean |
isFlagSet(int flagMask,
int flags)
Checks if the flag(s) given in flagMask is set in the given flags.
|
static int |
numberFromBits(byte[] data,
int offset,
int mask,
int shift)
Performs the same operations as
numberFromBits(int, int, int) instead using a
byte from a byte array as the bit set. |
static int |
numberFromBits(int data,
int mask,
int shift)
Will return the integer value of a masked bit set in some desired magnitude range.
|
static int |
numberFromBoolean(boolean data)
Parses a boolean from an integer.
|
static int |
numberFromByte(byte data)
Parses an unsigned byte into an integer.
|
static int |
numberFromByte(byte[] data,
int offset)
Parses an integer from a byte found in a byte array.
|
static long |
numberFromBytes(byte[] data,
int startOffset,
int numberOfBytes)
Parses an number from a set of bytes found in a byte array.
|
static void |
placeInArray(boolean data,
byte[] destination,
int offset)
Replaces the value in a given element of a byte array with a given boolean.
|
static void |
placeInArray(int number,
byte[] destination,
int offset)
Replaces the value in a given element of a byte array with a given integer.
|
static void |
placeInArray(long number,
byte[] destination,
int numberOfBytes,
int startOffset)
Replaces the values within a byte array with a given long integer value.
|
static int |
signedNumberFromByte(byte[] data,
int offset)
Parses a signed number from a byte found in a byte array.
|
static long |
signedNumberFromBytes(byte[] data,
int startOffset,
int numberOfBytes)
Parses a signed number from a set of bytes found in a byte array.
|
public static boolean isFlagSet(int flagMask, int flags)
flagMask
- The bit mask that the bit set is compared to.flags
- The bit set that is being checked.public static boolean isFlagSet(int flagMask, byte[] data, int offset)
isFlagSet(int, int)
, using a byte from a byte
array as the bit set.flagMask
- The bit mask that the bit set is compared to.data
- The byte array that the desired byte will be taken from.offset
- The byte array offset at which the byte will be taken.public static int numberFromBits(byte[] data, int offset, int mask, int shift)
numberFromBits(int, int, int)
instead using a
byte from a byte array as the bit set.data
- The array that holds the given value to be operated on.offset
- The offset of the byte taken from the bit set that will be operated on.mask
- A bit mask used to mask the bit set.shift
- The magnitude of the right shift performed on the result of the masked bit set.public static int numberFromBits(int data, int mask, int shift)
data
- The given bit set.mask
- A bit mask used to mask the bit set.shift
- The magnitude of the right shift performed on the result of the masked bit set.public static int numberFromByte(byte data)
data
- The given unsigned byte parameter to be parsed.public static int numberFromByte(byte[] data, int offset)
data
- The byte array from which the return byte is found.offset
- The offset at which the desired byte is found in the byte array.public static int signedNumberFromByte(byte[] data, int offset)
data
- The byte array from which the return byte is found.offset
- The offset at which the desired byte is found in the byte array.public static long numberFromBytes(byte[] data, int startOffset, int numberOfBytes)
data
- The source of the byte(s) to be returned.startOffset
- The index of the first byte of the number to be returned.numberOfBytes
- Number of bytes the returned value will contain.public static long signedNumberFromBytes(byte[] data, int startOffset, int numberOfBytes)
data
- The source of the byte(s) to be returned.startOffset
- The index of the first byte of the number to be returned.numberOfBytes
- numberOfBytes Number of bytes the returned value will contain.public static boolean booleanFromNumber(int data)
data
- The integer to be parsed.public static int numberFromBoolean(boolean data)
data
- The boolean to be parsed.public static boolean booleanFromByte(byte[] data, int offset)
data
- The byte array from which the byte of interest is taken.offset
- The byte element of interest within the byte array.public static void placeInArray(boolean data, byte[] destination, int offset)
data
- The boolean that will replace the desired element's current value.destination
- The byte array that will be altered.offset
- The index of the element that will be altered.public static void placeInArray(int number, byte[] destination, int offset)
number
- The integer that will replace the desired element's current value.destination
- The byte array that will be altered.offset
- The index of the element that will be altered.public static void placeInArray(long number, byte[] destination, int numberOfBytes, int startOffset)
number
- The value that will replace the desired element's current value.destination
- The byte array that will be altered.numberOfBytes
- The number of bytes that will be replaced in the array.startOffset
- The first element that will be replaced in destinationpublic static final boolean inRange(int value, int min, int max)
min
- The minimum bound of the set range.max
- The maximum bound of the set range.value
- The value to be checked against the given bounds.public static java.lang.String getHexString(int number)
number
- The integer to be converted into the hexadecimal number string.public static java.lang.String getHexString(byte[] data)
data
- The byte array to be converted into the hexadecimal number string.Copyright © 2015 Dynastream Innovations Inc. All Rights Reserved.