Package com.google.gerrit.server.ioutil
Class BasicSerialization
java.lang.Object
com.google.gerrit.server.ioutil.BasicSerialization
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 Details
-
readFixInt64
Read a fixed-width 64 bit integer in network byte order (big-endian).- Throws:
IOException
-
writeFixInt64
Write a fixed-width 64 bit integer in network byte order (big-endian).- Throws:
IOException
-
readFixInt32
Read a fixed-width 32 bit integer in network byte order (big-endian).- Throws:
IOException
-
writeFixInt32
Write a fixed-width 32 bit integer in network byte order (big-endian).- Throws:
IOException
-
readVarInt32
Read a varint from the input, one byte at a time.- Throws:
IOException
-
writeVarInt32
Write a varint; value is treated as an unsigned value.- Throws:
IOException
-
readBytes
Read a fixed length byte array whose length is specified as a varint.- Throws:
IOException
-
writeBytes
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
Read a UTF-8 string, prefixed by its byte length in a varint.- Throws:
IOException
-
writeString
Write a UTF-8 string, prefixed by its byte length in a varint.- Throws:
IOException
-
readEnum
Read an enum whose code is stored as a varint.- Throws:
IOException
-
writeEnum
Write an enum whose code is stored as a varint.- Throws:
IOException
-