public class VarInt
extends java.lang.Object
Handles, in a common encoding format, signed bytes, shorts, ints, and longs. Takes between 1 and 10 bytes. Less efficient than BigEndian{Int,Long} coder for negative or large numbers. All negative ints are encoded using 5 bytes, longs take 10 bytes.
Constructor and Description |
---|
VarInt() |
Modifier and Type | Method and Description |
---|---|
static int |
decodeInt(java.io.InputStream stream)
Decodes an integer value from the given stream.
|
static long |
decodeLong(java.io.InputStream stream)
Decodes a long value from the given stream.
|
static void |
encode(int v,
java.io.OutputStream stream)
Encodes the given value onto the stream.
|
static void |
encode(long v,
java.io.OutputStream stream)
Encodes the given value onto the stream.
|
static int |
getLength(int v)
Returns the length of the encoding of the given value (in bytes).
|
static int |
getLength(long v)
Returns the length of the encoding of the given value (in bytes).
|
public static void encode(int v, java.io.OutputStream stream) throws java.io.IOException
java.io.IOException
public static void encode(long v, java.io.OutputStream stream) throws java.io.IOException
java.io.IOException
public static int decodeInt(java.io.InputStream stream) throws java.io.IOException
java.io.IOException
public static long decodeLong(java.io.InputStream stream) throws java.io.IOException
java.io.IOException
public static int getLength(int v)
public static int getLength(long v)