public class BasicSerialization extends Object
Modifier and Type | Method and Description |
---|---|
static byte[] |
readBytes(InputStream input)
Read a fixed length byte array whose length is specified as a varint.
|
static <T extends CodedEnum> |
readEnum(InputStream input,
T[] all)
Read an enum whose code is stored as a varint.
|
static int |
readFixInt32(InputStream input)
Read a fixed-width 32 bit integer in network byte order (big-endian).
|
static long |
readFixInt64(InputStream input)
Read a fixed-width 64 bit integer in network byte order (big-endian).
|
static String |
readString(InputStream input)
Read a UTF-8 string, prefixed by its byte length in a varint.
|
static int |
readVarInt32(InputStream input)
Read a varint from the input, one byte at a time.
|
static void |
writeBytes(OutputStream output,
byte[] data)
Write a byte array prefixed by its length in a varint.
|
static void |
writeBytes(OutputStream output,
byte[] data,
int offset,
int len)
Write a byte array prefixed by its length in a varint.
|
static <T extends CodedEnum> |
writeEnum(OutputStream output,
T e)
Write an enum whose code is stored as a varint.
|
static void |
writeFixInt32(OutputStream output,
int val)
Write a fixed-width 32 bit integer in network byte order (big-endian).
|
static void |
writeFixInt64(OutputStream output,
long val)
Write a fixed-width 64 bit integer in network byte order (big-endian).
|
static void |
writeString(OutputStream output,
String s)
Write a UTF-8 string, prefixed by its byte length in a varint.
|
static void |
writeVarInt32(OutputStream output,
int value)
Write a varint; value is treated as an unsigned value.
|
public static long readFixInt64(InputStream input) throws IOException
IOException
public static void writeFixInt64(OutputStream output, long val) throws IOException
IOException
public static int readFixInt32(InputStream input) throws IOException
IOException
public static void writeFixInt32(OutputStream output, int val) throws IOException
IOException
public static int readVarInt32(InputStream input) throws IOException
IOException
public static void writeVarInt32(OutputStream output, int value) throws IOException
IOException
public static byte[] readBytes(InputStream input) throws IOException
IOException
public static void writeBytes(OutputStream output, byte[] data) throws IOException
IOException
public static void writeBytes(OutputStream output, byte[] data, int offset, int len) throws IOException
IOException
public static String readString(InputStream input) throws IOException
IOException
public static void writeString(OutputStream output, String s) throws IOException
IOException
public static <T extends CodedEnum> T readEnum(InputStream input, T[] all) throws IOException
IOException
public static <T extends CodedEnum> void writeEnum(OutputStream output, T e) throws IOException
IOException