public abstract class ParseUtil extends Object
| Constructor and Description |
|---|
ParseUtil() |
| Modifier and Type | Method and Description |
|---|---|
static float |
byteArrayToFloat(byte[] bytes,
int size,
int fpBits)
Convert a byte array to its floating point representation.
|
static long |
byteArrayToLong(byte[] bytes,
int size)
Convert a byte array to its integer representation.
|
static long |
cimDateTimeToMillis(String cimDate)
Parses a CIM_DateTime format (from WMI) to milliseconds since the epoch.
|
static byte[] |
hexStringToByteArray(String digits)
Parse a string of hexadecimal digits into a byte array
|
static String |
hexStringToString(String hexString)
Parses a string of hex digits to a string
|
static String |
jsonPrettyPrint(javax.json.JsonObject json)
Pretty print a JSON string.
|
static byte[] |
longToByteArray(long value,
int valueSize,
int length)
Convert a long value to a byte array using Big Endian, truncating or
padding with zeros (if necessary) so the array has the specified length.
|
static long |
parseHertz(String hertz)
Parse hertz from a string, eg.
|
static int |
parseLastInt(String s,
int i)
Parse the last element of a string to a value
|
static byte[] |
stringToByteArray(String text,
int length)
Parse a human readable string into a byte array, truncating or padding
with zeros (if necessary) so the array has the specified length.
|
static long |
strToLong(String str,
int size)
Convert a string to an integer representation.
|
public static long parseHertz(String hertz)
hertz - Hertz size.Long Hertz value or -1 if not parsable.public static int parseLastInt(String s, int i)
s - The string to parsei - Default integer if not parsableInteger value or the given default if not parsablepublic static byte[] hexStringToByteArray(String digits)
digits - The string to be parsedpublic static byte[] stringToByteArray(String text, int length)
text - The string to be parsedlength - Length of the returned array.public static byte[] longToByteArray(long value,
int valueSize,
int length)
value - The value to be convertedvalueSize - Number of bytes representing the valuelength - Number of bytes to returnpublic static long strToLong(String str, int size)
str - A human readable stringsize - Number of characters to convert to the long. May not exceed 8.public static long byteArrayToLong(byte[] bytes,
int size)
bytes - An array of bytes no smaller than the size to be convertedsize - Number of bytes to convert to the long. May not exceed 8.public static float byteArrayToFloat(byte[] bytes,
int size,
int fpBits)
bytes - An array of bytes no smaller than the size to be convertedsize - Number of bytes to convert to the float. May not exceed 8.fpBits - Number of bits representing the decimalpublic static String jsonPrettyPrint(javax.json.JsonObject json)
json - A JSON objectpublic static long cimDateTimeToMillis(String cimDate)
cimDate - A string containing the CIM_DateTimeCopyright © 2010–2016 com.github.dblock. All rights reserved.