Package org.fusesource.hawtbuf
Class AbstractVarIntSupport
- java.lang.Object
-
- org.fusesource.hawtbuf.AbstractVarIntSupport
-
- Direct Known Subclasses:
BufferEditor
public abstract class AbstractVarIntSupport extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description AbstractVarIntSupport()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static intcomputeVarIntSize(int value)Compute the number of bytes that would be needed to encode a varint.static intcomputeVarLongSize(long value)Compute the number of bytes that would be needed to encode a varint.static intcomputeVarSignedIntSize(int value)Compute the number of bytes that would be needed to encode a signed varint.static intcomputeVarSignedLongSize(long value)Compute the number of bytes that would be needed to encode a signed varint.private static intdecodeZigZag32(int n)private static longdecodeZigZag64(long n)private static intencodeZigZag32(int n)private static longencodeZigZag64(long n)protected abstract bytereadByte()intreadVarInt()Read a raw Varint from the stream.longreadVarLong()Read a raw Varint from the stream.intreadVarSignedInt()Read ansint32field value from the stream.longreadVarSignedLong()Read ansint64field value from the stream.protected abstract voidwriteByte(int value)voidwriteVarInt(int value)Encode and write a varint.voidwriteVarLong(long value)Encode and write a varint.voidwriteVarSignedInt(int value)voidwriteVarSignedLong(long value)
-
-
-
Method Detail
-
readByte
protected abstract byte readByte() throws java.io.IOException- Throws:
java.io.IOException
-
writeByte
protected abstract void writeByte(int value) throws java.io.IOException- Throws:
java.io.IOException
-
readVarInt
public int readVarInt() throws java.io.IOExceptionRead a raw Varint from the stream. If larger than 32 bits, discard the upper bits.- Throws:
java.io.IOException
-
readVarLong
public long readVarLong() throws java.io.IOExceptionRead a raw Varint from the stream.- Throws:
java.io.IOException
-
readVarSignedInt
public int readVarSignedInt() throws java.io.IOExceptionRead ansint32field value from the stream.- Throws:
java.io.IOException
-
readVarSignedLong
public long readVarSignedLong() throws java.io.IOExceptionRead ansint64field value from the stream.- Throws:
java.io.IOException
-
writeVarInt
public void writeVarInt(int value) throws java.io.IOExceptionEncode and write a varint.valueis treated as unsigned, so it won't be sign-extended if negative.- Throws:
java.io.IOException
-
writeVarLong
public void writeVarLong(long value) throws java.io.IOExceptionEncode and write a varint.- Throws:
java.io.IOException
-
writeVarSignedInt
public void writeVarSignedInt(int value) throws java.io.IOException- Throws:
java.io.IOException
-
writeVarSignedLong
public void writeVarSignedLong(long value) throws java.io.IOException- Throws:
java.io.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.valueis 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.
-
-