public class TypeConversion
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static int |
byteArrayToInt(byte[] byteArray)
convert a byte array into an int; big endian is assumed
|
static int |
byteArrayToInt(byte[] byteArray,
java.nio.ByteOrder byteOrder)
convert a byte array into an int
|
static long |
byteArrayToLong(byte[] byteArray)
convert a byte array into a long; big endian is assumed
|
static long |
byteArrayToLong(byte[] byteArray,
java.nio.ByteOrder byteOrder)
convert a byte array into a long
|
static short |
byteArrayToShort(byte[] byteArray)
convert a byte array into a short; big endian is assumed
|
static short |
byteArrayToShort(byte[] byteArray,
java.nio.ByteOrder byteOrder)
convert a byte array into a short
|
static short |
byteArrayToShort(byte[] byteArray,
int ibFirst,
java.nio.ByteOrder byteOrder) |
static double |
doubleFromFixed(int value,
int fractionBits) |
static double |
doubleFromFixed(long value,
int fractionBits) |
static int |
doubleToFixedInt(double value,
int fractionBits) |
static long |
doubleToFixedLong(double value,
int fractionBits) |
static byte[] |
intToByteArray(int integer)
convert an int into a byte array; big endian is assumed
|
static byte[] |
intToByteArray(int integer,
java.nio.ByteOrder byteOrder)
convert an int into a byte array
|
static byte[] |
longToByteArray(long longInt)
convert a long into a byte array; big endian is assumed
|
static byte[] |
longToByteArray(long longInt,
java.nio.ByteOrder byteOrder)
convert a long into a byte array
|
static byte[] |
shortToByteArray(short shortInt)
convert a short into a byte array; big endian is assumed
|
static byte[] |
shortToByteArray(short shortInt,
java.nio.ByteOrder byteOrder)
convert a short into a byte array
|
static byte[] |
stringToUtf8(java.lang.String javaString)
Convert a Java String into a UTF-8 byte array
|
static boolean |
toBoolean(java.lang.Boolean value) |
static boolean |
toBoolean(java.lang.Boolean value,
boolean defaultValue) |
static double |
unsignedByteToDouble(byte b)
Accept a byte, treat that byte as an unsigned byte, then covert it to the return type
|
static int |
unsignedByteToInt(byte b)
Accept a byte, treat that byte as an unsigned byte, then covert it to the return type
|
static long |
unsignedIntToLong(int i)
Accept an int, treat that int as an unsigned int, then covert it to the return type
|
static int |
unsignedShortToInt(short s)
Treats a short as an unsigned value and returns that value as a int
|
static java.lang.String |
utf8ToString(byte[] utf8String) |
public static byte[] shortToByteArray(short shortInt)
shortInt
- public static byte[] shortToByteArray(short shortInt, java.nio.ByteOrder byteOrder)
shortInt
- byteOrder
- public static byte[] intToByteArray(int integer)
integer
- public static byte[] intToByteArray(int integer, java.nio.ByteOrder byteOrder)
integer
- byteOrder
- public static byte[] longToByteArray(long longInt)
longInt
- public static byte[] longToByteArray(long longInt, java.nio.ByteOrder byteOrder)
longInt
- byteOrder
- public static short byteArrayToShort(byte[] byteArray)
byteArray
- public static short byteArrayToShort(byte[] byteArray, java.nio.ByteOrder byteOrder)
byteArray
- byteOrder
- public static short byteArrayToShort(byte[] byteArray, int ibFirst, java.nio.ByteOrder byteOrder)
public static int byteArrayToInt(byte[] byteArray)
byteArray
- public static int byteArrayToInt(byte[] byteArray, java.nio.ByteOrder byteOrder)
byteArray
- byteOrder
- public static long byteArrayToLong(byte[] byteArray)
byteArray
- public static long byteArrayToLong(byte[] byteArray, java.nio.ByteOrder byteOrder)
byteArray
- byteOrder
- public static int unsignedByteToInt(byte b)
b
- byte to treat as unsigned bytepublic static int unsignedShortToInt(short s)
s
- the short to be converted to an intpublic static double unsignedByteToDouble(byte b)
b
- byte to treat as unsigned bytepublic static long unsignedIntToLong(int i)
i
- int to treat as unsigned intpublic static byte[] stringToUtf8(java.lang.String javaString)
javaString
- Java String to convertjava.lang.IllegalArgumentException
- if unable to cleanly convert the Java Stringpublic static int doubleToFixedInt(double value, int fractionBits)
public static double doubleFromFixed(int value, int fractionBits)
public static long doubleToFixedLong(double value, int fractionBits)
public static double doubleFromFixed(long value, int fractionBits)
public static java.lang.String utf8ToString(byte[] utf8String)
public static boolean toBoolean(java.lang.Boolean value)
public static boolean toBoolean(java.lang.Boolean value, boolean defaultValue)