public class Utils extends Object
| Constructor and Description |
|---|
Utils() |
| Modifier and Type | Method and Description |
|---|---|
static double |
bound(double n,
double low,
double high)
Ensures: low <= n <= high
|
static int |
bound(int n,
int low,
int high)
Ensures: low <= n <= high
|
static long |
bound(long n,
long low,
long high)
Ensures: low <= n <= high
|
static String |
bytesToString(byte[] bytes)
Creates a String from the given byte array.
|
static byte |
checksum(byte[] data,
int offset,
int len,
boolean invert,
byte... extra)
Calculates a checksum from the data and extra bytes
|
static byte[] |
convertToByteArray(List<Byte> a)
Converts a List of Byte Objects to an array of byte primatives.
|
static <K,V> void |
mergeMaps(Map<K,V> dest,
Map<K,V>... srcs)
Adds the values from src to dest where the key from src does not exist in dest.
|
static int |
readHex(char c)
Converts the characters '0'-'9' (48-58), 'A'-'F' (65-70), and 'a'-'f'
(32-37) or to the decimal value of their corresponding hex values.
|
static int |
readHex(String xx)
Returns the decimal value of a two character hex string.
|
static int |
unsign(byte b)
Returns the unsigned value of the given signed byte.
|
public static String bytesToString(byte[] bytes)
bytes - array of bytespublic static <K,V> void mergeMaps(Map<K,V> dest, Map<K,V>... srcs)
K - V - srcs - dest - public static int unsign(byte b)
b - signed bytepublic static byte checksum(byte[] data,
int offset,
int len,
boolean invert,
byte... extra)
data - byte array to checkoffset - array offsetlen - data lengthinvert - should the value be invertedextra - extra bytes to use in calculating the checksumpublic static double bound(double n,
double low,
double high)
n - value to be boundedlow - lower boundhigh - upper boundpublic static long bound(long n,
long low,
long high)
n - value to be boundedlow - lower boundhigh - upper boundpublic static int bound(int n,
int low,
int high)
n - value to be boundedlow - lower boundhigh - upper boundpublic static int readHex(String xx)
xx - two character hex string [0-9a-fA-F]public static int readHex(char c)
c - character to convertCopyright © 2011-2014. All Rights Reserved.