public class IOUtil extends Object
Code of this class is partially copied from com.google.protobuf.CodedOutputStream and com.google.protobuf.CodedInputStream classes from Google's protobuf library.
| Constructor and Description |
|---|
IOUtil() |
| Modifier and Type | Method and Description |
|---|---|
static int |
computeRawVarint32Size(int value)
Compute the number of bytes that would be needed to encode a varint.
|
static int |
computeRawVarint64Size(long value)
Compute the number of bytes that would be needed to encode a varint.
|
static int |
decodeZigZag32(int n)
Decode a ZigZag-encoded 32-bit value.
|
static long |
decodeZigZag64(long n)
Decode a ZigZag-encoded 64-bit value.
|
static int |
encodeZigZag32(int n)
Encode a ZigZag-encoded 32-bit value.
|
static long |
encodeZigZag64(long n)
Encode a ZigZag-encoded 64-bit value.
|
static int |
readRawVarint32(InputStream is,
int eofVaule)
Read a raw Varint from the stream.
|
static long |
readRawVarint64(InputStream is,
long eofValue)
Read a raw Varint from the stream.
|
static void |
writeRawVarint32(OutputStream os,
int value)
Encode and write a varint.
|
static void |
writeRawVarint64(OutputStream os,
long value)
Encode and write a varint.
|
public static int readRawVarint32(InputStream is, int eofVaule) throws IOException
Based on com.google.protobuf.CodedInputStream class from Google's protobuf library.
IOExceptionpublic static long readRawVarint64(InputStream is, long eofValue) throws IOException
Based on com.google.protobuf.CodedInputStream class from Google's protobuf library.
IOExceptionpublic static void writeRawVarint32(OutputStream os, int value) throws IOException
value is treated as unsigned, so it won't be sign-extended if negative.
Copied from com.google.protobuf.CodedOutputStream from Google's protobuf library.
IOExceptionpublic static int computeRawVarint32Size(int value)
value is treated as unsigned, so it
won't be sign-extended if negative.
Copied from com.google.protobuf.CodedOutputStream from Google's protobuf library.
public static void writeRawVarint64(OutputStream os, long value) throws IOException
Copied from com.google.protobuf.CodedOutputStream from Google's protobuf library.
IOExceptionpublic static int computeRawVarint64Size(long value)
Copied from com.google.protobuf.CodedOutputStream from Google's protobuf library.
public static int encodeZigZag32(int n)
Copied from com.google.protobuf.CodedOutputStream from Google's protobuf library.
n - A signed 32-bit integer.public static long encodeZigZag64(long n)
Copied from com.google.protobuf.CodedOutputStream from Google's protobuf library.
n - A signed 64-bit integer.public static int decodeZigZag32(int n)
Copied from com.google.protobuf.CodedInputStream from Google's protobuf library.
n - An unsigned 32-bit integer, stored in a signed int because Java has no explicit unsigned support.public static long decodeZigZag64(long n)
Copied from com.google.protobuf.CodedInputStream from Google's protobuf library.
n - An unsigned 64-bit integer, stored in a signed int because Java has no explicit unsigned support.Copyright © 2018. All rights reserved.