public final class Bytes
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.nio.ByteBuffer |
fromHexString(java.lang.String str)
Parse an hex string representing a CQL blob.
|
static byte[] |
getArray(java.nio.ByteBuffer bytes)
Extract the content of the provided
ByteBuffer as a byte array. |
static java.lang.String |
toHexString(byte[] byteArray)
Converts a blob to its CQL hex string representation.
|
static java.lang.String |
toHexString(java.nio.ByteBuffer bytes)
Converts a blob to its CQL hex string representation.
|
public static java.lang.String toHexString(java.nio.ByteBuffer bytes)
A CQL blob string representation consist of the hexadecimal representation of the blob bytes prefixed by "0x".
bytes
- the blob/bytes to convert to a string.bytes
. If bytes
is null
, this
method returns null
.public static java.lang.String toHexString(byte[] byteArray)
A CQL blob string representation consist of the hexadecimal representation of the blob bytes prefixed by "0x".
byteArray
- the blob/bytes array to convert to a string.bytes
. If bytes
is null
, this
method returns null
.public static java.nio.ByteBuffer fromHexString(java.lang.String str)
The input should be a valid representation of a CQL blob, i.e. it must start by "0x" followed by the hexadecimal representation of the blob bytes.
str
- the CQL blob string representation to parse.str
. If str
is null
, this method
returns null
.java.lang.IllegalArgumentException
- if str
is not a valid CQL blob string.public static byte[] getArray(java.nio.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.Copyright © 2009-2020 The Apache Software Foundation