public final class Streamables extends Object
Streamables and/or data streams.| Constructor and Description |
|---|
Streamables() |
| Modifier and Type | Method and Description |
|---|---|
static int |
calcUtfLength(String str)
Returns the length in bytes of a string's UTF-8 encoding.
|
Object |
fromByteArray(byte[] array) |
static void |
fromByteArray(Streamable streamable,
byte[] array)
Reads a
Streamable's serialized contents from a byte array. |
static void |
fromByteArray(Streamable streamable,
byte[] array,
int offset)
Reads a
Streamable's serialized contents from a byte array. |
static void |
fromByteArray(Streamable streamable,
byte[] array,
int offset,
int length)
Reads a
Streamable's serialized contents from a byte array. |
Object |
read(DataInput in) |
<T extends Streamable> |
register(byte qualifier,
Class<T> clazz) |
static byte[] |
toByteArray(Streamable streamable)
Serializes a
Streamable into a byte array. |
static void |
writeBuffer(DataOutput out,
ByteBuffer buffer)
Writes the given
ByteBuffer into the given DataOutput. |
public static byte[] toByteArray(Streamable streamable)
Streamable into a byte array.streamable - The object to serialize.public static void fromByteArray(Streamable streamable, byte[] array)
Streamable's serialized contents from a byte array.
The serialized form begins in the beginning of the array and extends to the end of the array.
Same as calling fromByteArray(streamable, array, 0, array.length).
streamable - The object whose contents are to be read.array - The array from which to read the serialized form.public static void fromByteArray(Streamable streamable, byte[] array, int offset)
Streamable's serialized contents from a byte array.
The serialized form begins in the given offset and extends to the end of the array.
Same as calling fromByteArray(streamable, array, offset, array.length - offset).
streamable - The object whose contents are to be read.array - The array from which to read the serialized form.offset - The offset into the array from which to start reading the serialized form.public static void fromByteArray(Streamable streamable, byte[] array, int offset, int length)
Streamable's serialized contents from a byte array.streamable - The object whose contents are to be read.array - The array from which to read the serialized form.offset - The offset into the array from which to start reading the serialized form.length - The length of the serialized form to read from the array.public static void writeBuffer(DataOutput out, ByteBuffer buffer) throws IOException
ByteBuffer into the given DataOutput.out - The DataOutput into which the buffer will be written.buffer - The buffer to write into the DataOutput.IOExceptionpublic static int calcUtfLength(String str)
str - The string to measure.public <T extends Streamable> void register(byte qualifier, Class<T> clazz)
public Object read(DataInput in) throws IOException
IOExceptionpublic Object fromByteArray(byte[] array) throws IOException
IOException