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