public class VarInt extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
long |
value |
| 构造器和说明 |
|---|
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.
|
| 限定符和类型 | 方法和说明 |
|---|---|
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 © 2021. All rights reserved.