Class Hex
java.lang.Object
dev.getelements.elements.sdk.util.Hex
- Direct Known Subclasses:
Hex
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static enum
The case (upper or lower case).static class
Thrown when the hex string is not valid. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
Decodes aString
into raw hexadecimal bytes.static ByteBuffer
decodeToBuffer
(String hex) Decodes aString
into raw hexadecimal bytes, allocating a newByteBuffer
for storage.static ByteBuffer
decodeToBuffer
(String hex, Hex.ByteBufferAllocator byteBufferAllocator) Decodes aString
into raw hexadecimal bytes, allocating a newByteBuffer
for storage using the suppliedHex.ByteBufferAllocator
.static String
encode
(byte[] raw) Encodes hex to to lower-case hex encoding.static String
Encodes hex to to lower-case hex encoding.static String
encode
(ByteBuffer raw) Encodes hex to to lower-case hex encoding.static String
encode
(ByteBuffer raw, Hex.Case c) Encodes hex to to lower-case hex encoding.static char
Gets a characte for the supplied nibble.
-
Field Details
-
VALID_REGEX
- See Also:
-
VALID_PATTERN
-
-
Constructor Details
-
Hex
public Hex()
-
-
Method Details
-
forNibble
Gets a characte for the supplied nibble.- Parameters:
nibble
- the nibblec
- the desired case format- Returns:
- the char for the nibble.
-
encode
Encodes hex to to lower-case hex encoding.- Parameters:
raw
- the raw byte value- Returns:
- the
String
representing the hex string
-
encode
Encodes hex to to lower-case hex encoding. -
encode
Encodes hex to to lower-case hex encoding.- Parameters:
raw
- the raw byte value- Returns:
- the
String
representing the hex string
-
encode
Encodes hex to to lower-case hex encoding. -
decode
Decodes aString
into raw hexadecimal bytes.- Parameters:
hex
- the hex string- Returns:
- a
invalid reference
byte[]
-
decodeToBuffer
Decodes aString
into raw hexadecimal bytes, allocating a newByteBuffer
for storage.- Parameters:
hex
- the hex string- Returns:
- a
invalid reference
byte[]
-
decodeToBuffer
Decodes aString
into raw hexadecimal bytes, allocating a newByteBuffer
for storage using the suppliedHex.ByteBufferAllocator
.- Parameters:
hex
- the hex string- Returns:
- a
invalid reference
byte[]
-