public final class ByteBufferUtil extends Object
ByteBuffer manipulation.
This class is a partial copy of org.apache.cassandra.utils.ByteBufferUtil class from
cassandra-all library.
| Modifier and Type | Method and Description |
|---|---|
static ByteBuffer |
bytes(byte b)
Encodes a
byte in a ByteBuffer. |
static ByteBuffer |
bytes(double d)
Encodes a
double in a ByteBuffer. |
static ByteBuffer |
bytes(float f)
Encodes a
float in a ByteBuffer. |
static ByteBuffer |
bytes(int i)
Encodes an
int in a ByteBuffer. |
static ByteBuffer |
bytes(long n)
Encodes a
long in a ByteBuffer. |
static ByteBuffer |
bytes(short s)
Encodes a
short in a ByteBuffer. |
static ByteBuffer |
bytes(String s)
Encodes a
String in a ByteBuffer using UTF-8. |
static byte[] |
getArray(ByteBuffer buffer)
Gets a
byte array representation of a ByteBuffer. |
static double |
toDouble(ByteBuffer bytes)
Converts a
ByteBuffer to a double. |
static float |
toFloat(ByteBuffer bytes)
Converts a
ByteBuffer to a float. |
static int |
toInt(ByteBuffer bytes)
Converts a
ByteBuffer to an integer. |
static long |
toLong(ByteBuffer bytes)
Converts a
ByteBuffer to a long. |
static short |
toShort(ByteBuffer bytes)
Converts a
ByteBuffer to a short. |
public static ByteBuffer bytes(String s)
String in a ByteBuffer using UTF-8.s - The string to encode.public static ByteBuffer bytes(byte b)
byte in a ByteBuffer.b - The byte to encode.public static ByteBuffer bytes(short s)
short in a ByteBuffer.s - The short to encode.public static ByteBuffer bytes(int i)
int in a ByteBuffer.i - The int to encode.public static ByteBuffer bytes(long n)
long in a ByteBuffer.n - The long to encode.public static ByteBuffer bytes(float f)
float in a ByteBuffer.f - The float to encode.public static ByteBuffer bytes(double d)
double in a ByteBuffer.d - The double to encode.public static int toInt(ByteBuffer bytes)
ByteBuffer to an integer.
Does not change the byte buffer position.bytes - The byte buffer to convert to integer.public static short toShort(ByteBuffer bytes)
ByteBuffer to a short.
Does not change the byte buffer position.bytes - The byte buffer to convert to short.public static long toLong(ByteBuffer bytes)
ByteBuffer to a long.
Does not change the byte buffer position.bytes - The byte buffer to convert to long.public static float toFloat(ByteBuffer bytes)
ByteBuffer to a float.
Does not change the byte buffer position.bytes - The byte buffer to convert to float.public static double toDouble(ByteBuffer bytes)
ByteBuffer to a double.
Does not change the byte buffer position.bytes - The byte buffer to convert to double.public static byte[] getArray(ByteBuffer buffer)
byte array representation of a ByteBuffer.buffer - The byte buffer to represent as an array.Copyright © 2020–2024 ING Bank. All rights reserved.