Class OceanusDataConverter
java.lang.Object
io.github.tonywasher.joceanus.oceanus.convert.OceanusDataConverter
Data Conversion utility functions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intBase64 mask.static final intByte mask.static final intByte shift.static final intColor mask.static final intHexadecimal Radix.static final intNybble mask.static final intNybble shift.static final intRGB colour length. -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]base64ToByteArray(String pBase64) Convert a Base64 string into a byte array.static StringbyteArrayToBase64(byte[] pBytes) Convert a byte array to a Base64 string.static intbyteArrayToInteger(byte[] pBytes) parse an integer from a byte array.static longbyteArrayToLong(byte[] pBytes) parse a long from a byte array.static shortbyteArrayToShort(byte[] pBytes) parse a short from a byte array.static StringbyteArrayToString(byte[] pInput) get Bytes from String.static char[]bytesToCharArray(byte[] pBytes) Convert byte array to character array.static StringbytesToHexString(byte[] pBytes) format a byte array as a hexadecimal string.static byte[]charsToByteArray(char[] pChars) Convert character array to byte array.static byte[]hexStringToBytes(String pHexString) parse a byte array from a hexadecimal string.static longhexStringToLong(String pHexString) parse a long from a hexadecimal string.static byte[]integerToByteArray(int pValue) build a byte array from an integer.static byte[]longToByteArray(long pValue) build a byte array from a long.static StringlongToHexString(long pValue) format a long as a hexadecimal string.static byte[]shortToByteArray(short pValue) build a byte array from a short.static byte[]stringToByteArray(String pInput) get Bytes from String.
-
Field Details
-
HEX_RADIX
public static final int HEX_RADIXHexadecimal Radix.- See Also:
-
BYTE_SHIFT
public static final int BYTE_SHIFTByte shift.- See Also:
-
BYTE_MASK
public static final int BYTE_MASKByte mask.- See Also:
-
BASE64_MASK
public static final int BASE64_MASKBase64 mask.- See Also:
-
COLOR_MASK
public static final int COLOR_MASKColor mask.- See Also:
-
NYBBLE_SHIFT
public static final int NYBBLE_SHIFTNybble shift.- See Also:
-
NYBBLE_MASK
public static final int NYBBLE_MASKNybble mask.- See Also:
-
RGB_LENGTH
public static final int RGB_LENGTHRGB colour length.- See Also:
-
-
Method Details
-
bytesToHexString
format a byte array as a hexadecimal string.- Parameters:
pBytes- the byte array- Returns:
- the string
-
longToHexString
format a long as a hexadecimal string.- Parameters:
pValue- the long value- Returns:
- the string
-
hexStringToBytes
parse a byte array from a hexadecimal string.- Parameters:
pHexString- the hex string- Returns:
- the bytes
- Throws:
OceanusException- on error
-
hexStringToLong
parse a long from a hexadecimal string.- Parameters:
pHexString- the hex string- Returns:
- the bytes
- Throws:
OceanusException- on error
-
charsToByteArray
Convert character array to byte array.- Parameters:
pChars- the character array- Returns:
- the byte array
- Throws:
OceanusException- on error
-
bytesToCharArray
Convert byte array to character array.- Parameters:
pBytes- the byte array- Returns:
- the character array
- Throws:
OceanusException- on error
-
byteArrayToLong
public static long byteArrayToLong(byte[] pBytes) parse a long from a byte array.- Parameters:
pBytes- the eight byte array holding the long- Returns:
- the long value
-
longToByteArray
public static byte[] longToByteArray(long pValue) build a byte array from a long.- Parameters:
pValue- the long value to convert- Returns:
- the byte array
-
byteArrayToInteger
public static int byteArrayToInteger(byte[] pBytes) parse an integer from a byte array.- Parameters:
pBytes- the four byte array holding the integer- Returns:
- the integer value
-
integerToByteArray
public static byte[] integerToByteArray(int pValue) build a byte array from an integer.- Parameters:
pValue- the integer value to convert- Returns:
- the byte array
-
byteArrayToShort
public static short byteArrayToShort(byte[] pBytes) parse a short from a byte array.- Parameters:
pBytes- the four byte array holding the integer- Returns:
- the short value
-
shortToByteArray
public static byte[] shortToByteArray(short pValue) build a byte array from a short.- Parameters:
pValue- the short value to convert- Returns:
- the byte array
-
byteArrayToString
get Bytes from String.- Parameters:
pInput- the bytes to obtain the string from- Returns:
- the bytes representing the bytes
-
stringToByteArray
get Bytes from String.- Parameters:
pInput- the string to obtain the bytes from- Returns:
- the bytes representing the string
-
byteArrayToBase64
Convert a byte array to a Base64 string.- Parameters:
pBytes- the byte array (not null)- Returns:
- the translated Base64 string (not null)
-
base64ToByteArray
Convert a Base64 string into a byte array.- Parameters:
pBase64- the Base64 string (not null)- Returns:
- the byte array (not null)
-