Package org.fusesource.hawtbuf
Class AbstractVarIntSupport
java.lang.Object
org.fusesource.hawtbuf.AbstractVarIntSupport
- Direct Known Subclasses:
BufferEditor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
computeVarIntSize
(int value) Compute the number of bytes that would be needed to encode a varint.static int
computeVarLongSize
(long value) Compute the number of bytes that would be needed to encode a varint.static int
computeVarSignedIntSize
(int value) Compute the number of bytes that would be needed to encode a signed varint.static int
computeVarSignedLongSize
(long value) Compute the number of bytes that would be needed to encode a signed varint.private static int
decodeZigZag32
(int n) private static long
decodeZigZag64
(long n) private static int
encodeZigZag32
(int n) private static long
encodeZigZag64
(long n) protected abstract byte
readByte()
int
Read a raw Varint from the stream.long
Read a raw Varint from the stream.int
Read ansint32
field value from the stream.long
Read ansint64
field value from the stream.protected abstract void
writeByte
(int value) void
writeVarInt
(int value) Encode and write a varint.void
writeVarLong
(long value) Encode and write a varint.void
writeVarSignedInt
(int value) void
writeVarSignedLong
(long value)
-
Constructor Details
-
AbstractVarIntSupport
public AbstractVarIntSupport()
-
-
Method Details
-
readByte
- Throws:
IOException
-
writeByte
- Throws:
IOException
-
readVarInt
Read a raw Varint from the stream. If larger than 32 bits, discard the upper bits.- Throws:
IOException
-
readVarLong
Read a raw Varint from the stream.- Throws:
IOException
-
readVarSignedInt
Read ansint32
field value from the stream.- Throws:
IOException
-
readVarSignedLong
Read ansint64
field value from the stream.- Throws:
IOException
-
writeVarInt
Encode and write a varint.value
is treated as unsigned, so it won't be sign-extended if negative.- Throws:
IOException
-
writeVarLong
Encode and write a varint.- Throws:
IOException
-
writeVarSignedInt
- Throws:
IOException
-
writeVarSignedLong
- Throws:
IOException
-
decodeZigZag32
private static int decodeZigZag32(int n) -
decodeZigZag64
private static long decodeZigZag64(long n) -
encodeZigZag32
private static int encodeZigZag32(int n) -
encodeZigZag64
private static long encodeZigZag64(long n) -
computeVarIntSize
public static int computeVarIntSize(int value) Compute the number of bytes that would be needed to encode a varint.value
is treated as unsigned, so it won't be sign-extended if negative. -
computeVarLongSize
public static int computeVarLongSize(long value) Compute the number of bytes that would be needed to encode a varint. -
computeVarSignedIntSize
public static int computeVarSignedIntSize(int value) Compute the number of bytes that would be needed to encode a signed varint. -
computeVarSignedLongSize
public static int computeVarSignedLongSize(long value) Compute the number of bytes that would be needed to encode a signed varint.
-