|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.robokind.api.common.utils.Utils
public class Utils
Miscellaneous utility methods.
Constructor Summary | |
---|---|
Utils()
|
Method Summary | ||
---|---|---|
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
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Utils()
Method Detail |
---|
public static String bytesToString(byte[] bytes)
bytes
- array of bytes
public 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 byte
public 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 checksum
public static double bound(double n, double low, double high)
n
- value to be boundedlow
- lower boundhigh
- upper bound
public static long bound(long n, long low, long high)
n
- value to be boundedlow
- lower boundhigh
- upper bound
public static int bound(int n, int low, int high)
n
- value to be boundedlow
- lower boundhigh
- upper bound
public static int readHex(String xx)
xx
- two character hex string [0-9a-fA-F]
public static int readHex(char c)
c
- character to convert
public static byte[] convertToByteArray(List<Byte> a)
a
- List of Byte Objects
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |