Difference between revisions of "HexUtils Object"
(Created page with "==Description== The package name of this class is hubitat.helper. So to use in an App or Driver you would reference it with hubitat.helper.HexUtils. == <code>integerToHexStr...") |
|||
Line 15: | Line 15: | ||
'''Returns''' | '''Returns''' | ||
− | The value of the integer encoded as a hex string. | + | String - The value of the integer encoded as a hex string. |
'''Example''' | '''Example''' | ||
Line 34: | Line 34: | ||
'''Returns''' | '''Returns''' | ||
− | The integer value represented by the hex string. | + | int - The integer value represented by the hex string. |
'''Example''' | '''Example''' | ||
Line 45: | Line 45: | ||
'''Signature''' | '''Signature''' | ||
String byteArrayToHexString(byte[] value) | String byteArrayToHexString(byte[] value) | ||
+ | |||
+ | '''Parameters''' | ||
+ | |||
+ | value - the byte array to convert. | ||
+ | |||
+ | '''Returns''' | ||
+ | |||
+ | String - The hex string representation of the byte array. | ||
== <code>hexStringToByteArray</code> == | == <code>hexStringToByteArray</code> == |
Revision as of 21:00, 3 December 2018
Contents
Description
The package name of this class is hubitat.helper. So to use in an App or Driver you would reference it with hubitat.helper.HexUtils.
integerToHexString
Convert integer value to hex string.
Signature
String integerToHexString(int value, int minBytes)
Parameters
value - the integer value to encode minBytes - the minmum number of hex encoded bytes, must be greater than 0
Returns
String - The value of the integer encoded as a hex string.
Example
int i = 5 def hexStr = hubitat.helper.HexUtils.integerToHexString(i, 1)
hexStringToInt
Convert hex string to integer.
Signature
int hexStringToInt(String value)
Parameters
value - the hex string to convert
Returns
int - The integer value represented by the hex string.
Example
def myInt = hubitat.helper.HexUtils.hexStringToInt("01A6")
byteArrayToHexString
Convert a byte array to hex string.
Signature
String byteArrayToHexString(byte[] value)
Parameters
value - the byte array to convert.
Returns
String - The hex string representation of the byte array.
hexStringToByteArray
Convert a hex string to a byte array.
Signature
byte[] hexStringToByteArray(String value)
intArrayToHexString
Convert an integer array to a hex string.
Signature
String intArrayToHexString(int[] value)
hexStringToIntArray
Convert a hex string into an integer array.
Signature
int[] hexStringToIntArray(String value)