public class VarInt extends Object
Modifier and Type | Field and Description |
---|---|
long |
value |
Constructor and Description |
---|
VarInt(byte[] buf,
int offset)
Constructs a new VarInt with the value parsed from the specified offset of the given buffer.
|
VarInt(long value)
Constructs a new VarInt with the given unsigned long value.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
encode()
Encodes the value into its minimal representation.
|
int |
getOriginalSizeInBytes()
Returns the original number of bytes used to encode the value if it was
deserialized from a byte array, or the minimum encoded size if it was not.
|
int |
getSizeInBytes()
Returns the minimum encoded size of the value.
|
static int |
sizeOf(long value)
Returns the minimum encoded size of the given unsigned long value.
|
public VarInt(long value)
value
- the unsigned long value (beware widening conversion of negatives!)public VarInt(byte[] buf, int offset)
buf
- the buffer containing the valueoffset
- the offset of the valuepublic int getOriginalSizeInBytes()
public final int getSizeInBytes()
public static int sizeOf(long value)
value
- the unsigned long value (beware widening conversion of negatives!)public byte[] encode()
Copyright © 2016. All rights reserved.