@ThreadSafe public final class Codec extends Object
Modifier and Type | Field and Description |
---|---|
static Charset |
CHARSET
The charset used for Strings
|
Modifier and Type | Method and Description |
---|---|
static byte[] |
asArray(ByteBuf buf)
Writes the full contents of a ByteBuf to an array
|
static byte[] |
asArray(ByteBuf buf,
int length)
Writes a certain length of bytes from a ByteBuf to an array
|
static String |
readString(ByteBuf buf)
Read a string from the encoded buffer
|
static int |
readVarInt32(ByteBuf buf)
Reads a 32bit VarInt from the encoded buffer
|
static long |
readVarInt64(ByteBuf buf)
Reads a 64bit VarInt from the encoded buffer
|
static int |
sizeOf(int integer)
Gets the byte length of provided integer
|
static void |
writeString(ByteBuf buf,
String string)
Writes a string to the buffer
|
static void |
writeVarInt32(ByteBuf buf,
int toEncode)
Writes an int value as a VarInt to the buffer.
|
static void |
writeVarInt64(ByteBuf buf,
long toEncode)
Writes a long value as a VarInt to the buffer.
|
public static String readString(ByteBuf buf)
buf
- the buffer to decode the string frompublic static int sizeOf(int integer)
integer
- integer to get the byte length ofpublic static void writeString(ByteBuf buf, String string)
buf
- the buffer to decode the string frompublic static int readVarInt32(ByteBuf buf)
buf
- the buffer to decode the integer frompublic static void writeVarInt32(ByteBuf buf, int toEncode)
buf
- the buffer to encode intotoEncode
- the integer encode into bufpublic static long readVarInt64(ByteBuf buf)
buf
- the buffer to decode the long frompublic static void writeVarInt64(ByteBuf buf, long toEncode)
buf
- the buffer to encode intotoEncode
- the integer encode into bufpublic static byte[] asArray(ByteBuf buf)
buf
- the buffer to get data frompublic static byte[] asArray(ByteBuf buf, int length)
buf
- the buffer to get data fromlength
- the length to toPacketCopyright © 2016. All rights reserved.