public final class Bytes extends Object
Modifier and Type | Method and Description |
---|---|
static ByteBuffer |
fromHexString(String str)
Parse an hex string representing a CQL blob.
|
static byte[] |
fromRawHexString(String str,
int strOffset)
Converts a CQL hex string representation into a byte array.
|
static byte[] |
getArray(ByteBuffer bytes)
Extract the content of the provided
ByteBuffer as a byte array. |
static String |
toHexString(byte[] byteArray)
Converts a blob to its CQL hex string representation.
|
static String |
toHexString(ByteBuffer bytes)
Converts a blob to its CQL hex string representation.
|
static String |
toRawHexString(ByteBuffer bytes)
Converts a blob to its CQL hex string representation.
|
public static String toHexString(ByteBuffer bytes)
bytes
- the blob/bytes to convert to a string.bytes
. If bytes
is null
, this method returns null
.public static String toRawHexString(ByteBuffer bytes)
bytes
- the blob/bytes to convert to a string.bytes
. If bytes
is null
, this method returns null
.public static String toHexString(byte[] byteArray)
byteArray
- the blob/bytes array to convert to a string.bytes
. If bytes
is null
, this method returns null
.public static ByteBuffer fromHexString(String str)
str
- the CQL blob string representation to parse.str
. If str
is null
, this method returns null
.IllegalArgumentException
- if str
is not a valid CQL
blob string.public static byte[] getArray(ByteBuffer bytes)
ByteBuffer
as a byte array.
This method work with any type of ByteBuffer
(direct and non-direct
ones), but when the ByteBuffer
is backed by an array, this method
will try to avoid copy when possible. As a consequence, changes to the
returned byte array may or may not reflect into the initial ByteBuffer
.bytes
- the buffer whose content to extract.bytes
. That array may be the
array backing bytes
if this can avoid a copy.public static byte[] fromRawHexString(String str, int strOffset)
str
- the string converted in hex representation.strOffset
- he offset for starting the string conversionCopyright © 2012–2017. All rights reserved.