public final class VarIntUtils extends Object
TODO: add more unit tests.
| Modifier and Type | Method and Description |
|---|---|
static int |
checkNextVarInt(io.netty.buffer.ByteBuf buf)
Checks the next variable-length integer position/index.
|
static long |
crossReadVarInt(io.netty.buffer.ByteBuf firstPart,
io.netty.buffer.ByteBuf secondPart) |
static long |
readVarInt(io.netty.buffer.ByteBuf buf)
Note: it will change
buf readerIndex. |
static void |
reserveVarInt(io.netty.buffer.ByteBuf buf)
Reserve a seat of an unknown var integer in
buf header. |
static io.netty.buffer.ByteBuf |
setReservedVarInt(io.netty.buffer.ByteBuf buf,
int value)
Set a var integer to the
buf header from 32-bits integer, the buf header should be
reserved by reserveVarInt(io.netty.buffer.ByteBuf). |
static void |
setReservedVarInt(io.netty.buffer.ByteBuf buf,
long value)
Set a var integer to the
buf header from 64-bits integer, the buf header should be
reserved by reserveVarInt(io.netty.buffer.ByteBuf). |
static int |
varIntBytes(int value)
Calculate encoded bytes of a var integer.
|
static void |
writeVarInt(io.netty.buffer.ByteBuf buf,
int value)
Write MySQL var integer to
buf from 32-bits integer. |
static void |
writeVarInt(io.netty.buffer.ByteBuf buf,
long value)
Write MySQL var integer to
buf from 64-bits integer. |
public static long crossReadVarInt(io.netty.buffer.ByteBuf firstPart,
io.netty.buffer.ByteBuf secondPart)
public static long readVarInt(io.netty.buffer.ByteBuf buf)
buf readerIndex.buf - a readable buffer include a var integer.public static int checkNextVarInt(io.netty.buffer.ByteBuf buf)
buf has not a var integer. If the index is 0, means buf looks like has only
a var integer which buffer has no other data. If the index is a positive integer means how much buffer
size after read a var integer.buf - a readable buffer for check it has next a var integer or not.public static int varIntBytes(int value)
Note: it will NOT check value validation.
value - a integer to calculate encoded bytes.public static void reserveVarInt(io.netty.buffer.ByteBuf buf)
buf header.
Note: make sure the var integer will be set into the buf header, can not use it when you want
write a var integer into a buf which has data before the var integer. i.e. the buf
should be a new ByteBuf.
buf - that want reserve to this ByteBuf.public static io.netty.buffer.ByteBuf setReservedVarInt(io.netty.buffer.ByteBuf buf,
int value)
buf header from 32-bits integer, the buf header should be
reserved by reserveVarInt(io.netty.buffer.ByteBuf).buf - that want set to this ByteBuf, which is reserved a var integer.value - integer that want to set.buf which is set a var integer to the reserved seat.public static void setReservedVarInt(io.netty.buffer.ByteBuf buf,
long value)
buf header from 64-bits integer, the buf header should be
reserved by reserveVarInt(io.netty.buffer.ByteBuf).buf - that want set to this ByteBuf, which is reserved a var integer.value - integer that want to set.public static void writeVarInt(io.netty.buffer.ByteBuf buf,
int value)
buf from 32-bits integer.buf - that want write to this ByteBufvalue - integer that want writepublic static void writeVarInt(io.netty.buffer.ByteBuf buf,
long value)
buf from 64-bits integer.buf - that want write to this ByteBufvalue - integer that want writeCopyright © 2018–2023 asyncer.io. All rights reserved.