- Author:
- Sly Technologies Inc, repos@slytechs.com, mark
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
parseHexString
(String hexString) Parses a hex string to a byte array.static String
toAddressString
(byte[] array) Format an array as either IP ver 4, IP ver 6 or MAC address.static String
toHexCurleyString
(byte[] array) Formats individual bytes in an array to 2 digit hex values, each separated by ':' character enclosed within curley brackets {}.static String
toHexCurleyString
(byte[] array, int offset, int length) Formats individual bytes in an array to 2 digit hex values, each separated by ':' character enclosed within curley brackets {}.static String
Formats individual bytes in a ByteBuffer to 2 digit hex values, each separated by ':' character enclosed within square brackets[]
.static String
toHexSquareString
(byte[] array) Formats individual bytes in an array to 2 digit hex values, each separated by ':' character enclosed within square brackets[]
.static String
toHexSquareString
(byte[] array, int offset, int length) Formats individual bytes in an array to 2 digit hex values, each separated by ':' character enclosed within square brackets[]
.static String
Formats individual bytes in a ByteBuffer to 2 digit hex values, each separated by ':' character enclosed within square brackets[]
.static String
toHexString
(byte[] array) Formats individual bytes in an array to 2 digit hex values, each separated by ':' character.static String
toHexString
(byte[] array, int offset, int length) Formats individual bytes in an array to 2 digit hex values, each separated by ':' character.static String
toHexString
(byte[] array, int offset, int length, String prefix, String postfix) Formats individual bytes in an array to 2 digit hex values, each separated by ':' character.static String
toHexString
(byte[] array, String prefix, String postfix) Formats individual bytes in an array to 2 digit hex values, each separated by ':' character.static String
toHexString
(ByteBuffer buf) Formats individual bytes in a ByteBuffer to 2 digit hex values, each separated by ':' character.static String
toIp4AddressString
(byte[] array) Formats the given array as a IP ver 4 address in the form of 192.168.1.1.
-
Method Details
-
parseHexString
Parses a hex string to a byte array. Any whitespace and ':' characters are allowed and ignored.- Parameters:
hexString
- the hex input string with characters in range[0-9a-fA-f\\s:]
- Returns:
- the byte[] comprised of the hex values parsed from the input string
-
toAddressString
Format an array as either IP ver 4, IP ver 6 or MAC address. If array length is 4 bytes, the address is treated as an IP ver 4 address. Otherwise both MAC and IP ver 6 addresses are formatted with a ':' separator and a 2 digit hex string.- Parameters:
array
- the address- Returns:
- the formatted string
-
toHexCurleyString
Formats individual bytes in an array to 2 digit hex values, each separated by ':' character enclosed within curley brackets {}.For example this is the formatted string of an array {00:26:62:2f:47:87} using a
toHexCurleyString(array, 0, 6)
.- Parameters:
array
- the source array for bytes- Returns:
- the formatted string
-
toHexCurleyString
Formats individual bytes in an array to 2 digit hex values, each separated by ':' character enclosed within curley brackets {}.For example this is the formatted string of 6 bytes out of the an array {00:26:62:2f:47:87} using a
toHexCurleyString(array, 0, 6)
.- Parameters:
array
- the source array for bytesoffset
- the offset into the array to startlength
- the number of bytes to format- Returns:
- the formatted string
-
toHexCurleyString
Formats individual bytes in a ByteBuffer to 2 digit hex values, each separated by ':' character enclosed within square brackets[]
.For example this is the formatted string of an ByteBuffer {00:26:62:2f:47:87} using a
toHexCurleyString(buf)
.- Parameters:
buf
- the source ByteBuffer for bytes- Returns:
- the formatted string
-
toHexSquareString
Formats individual bytes in an array to 2 digit hex values, each separated by ':' character enclosed within square brackets[]
.For example this is the formatted string of an ByteBuffer [00:26:62:2f:47:87] using a
toHexSquareString(array)
.- Parameters:
array
- the source array for bytes- Returns:
- the formatted string
-
toHexSquareString
Formats individual bytes in an array to 2 digit hex values, each separated by ':' character enclosed within square brackets[]
.For example this is the formatted string of 6 bytes out of the an array [00:26:62:2f:47:87] using a
toHexSquareString(array, 0, 6)
.- Parameters:
array
- the source array for bytesoffset
- the offset into the array to startlength
- the number of bytes to format- Returns:
- the formatted string
-
toHexSquareString
Formats individual bytes in a ByteBuffer to 2 digit hex values, each separated by ':' character enclosed within square brackets[]
.For example this is the formatted string of an ByteBuffer [00:26:62:2f:47:87] using a
toHexSquareString(buf)
.- Parameters:
buf
- the source ByteBuffer for bytes- Returns:
- the formatted string
-
toHexString
Formats individual bytes in an array to 2 digit hex values, each separated by ':' character.For example this is the formatted string of 6 bytes out of the an array 00:26:62:2f:47:87 using a
toHexString(array)
.- Parameters:
array
- the source array for bytes- Returns:
- the formatted string
-
toHexString
Formats individual bytes in an array to 2 digit hex values, each separated by ':' character.For example this is the formatted string of 6 bytes out of the an array 00:26:62:2f:47:87 using a
toHexString(array, 0, 6)
.- Parameters:
array
- the source array for bytesoffset
- the offset into the array to startlength
- the number of bytes to format- Returns:
- the formatted string
-
toHexString
public static String toHexString(byte[] array, int offset, int length, String prefix, String postfix) Formats individual bytes in an array to 2 digit hex values, each separated by ':' character. Additionally aprefix
andpostfix
are used to enclose the resultant hex string.For example this is the formatted string of 6 bytes out of the an array <00:26:62:2f:47:87> using a
toHexString(array, 0, 6, "<", ">")
.- Parameters:
array
- the source array for bytesoffset
- the offset into the array to startlength
- the number of bytes to formatprefix
- the prefix in front of the resulting stringpostfix
- the postfix after the resulting string- Returns:
- the formatted string
-
toHexString
Formats individual bytes in an array to 2 digit hex values, each separated by ':' character. Additionally aprefix
andpostfix
are used to enclose the resultant hex string.For example this is the formatted string an array <00:26:62:2f:47:87> using a
toHexString(array, "<", ">")
.- Parameters:
array
- the source array for bytesprefix
- the prefix in front of the resulting stringpostfix
- the postfix after the resulting string- Returns:
- the formatted string
-
toHexString
Formats individual bytes in a ByteBuffer to 2 digit hex values, each separated by ':' character.For example this is the formatted string a ByteBuffer 00:26:62:2f:47:87 using a
toHexString(buf)
.- Parameters:
buf
- the source ByteBuffer for bytes- Returns:
- the formatted string
-
toIp4AddressString
Formats the given array as a IP ver 4 address in the form of 192.168.1.1.- Parameters:
array
- the IP ver 4 address- Returns:
- the formatted string
-