Package jadex.binary
Class VarInt
- java.lang.Object
- 
- jadex.binary.VarInt
 
- 
 public class VarInt extends java.lang.ObjectClass providing methods for encoding integers (longs) as byte array in a variable-length format.
- 
- 
Constructor SummaryConstructors Constructor Description VarInt()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static longdecode(byte[] varint)Decodes a VarInt.static longdecode(byte[] varint, int offset)Decodes a VarInt.static longdecodeWithKnownSize(byte[] varint, int offset, byte extsize)Decodes a VarInt when the extension size is known.static byte[]encode(long val)Encodes a VarInt.static voidencode(long val, byte[] buffer, int offset, int size)Encodes a VarInt and saves it in a buffer at the given offset.static intgetEncodedSize(long val)Determines the encoded size of a value.static bytegetExtensionSize(byte firstbyte)Returns the number of bytes used for this number past the first byte.static bytegetExtensionSize(byte[] varint, int offset)Returns the number of bytes used for this number past the first byte.
 
- 
- 
- 
Method Detail- 
getExtensionSizepublic static final byte getExtensionSize(byte[] varint, int offset)Returns the number of bytes used for this number past the first byte.- Parameters:
- varint- Encoded VarInt.
- offset- The offset.
- Returns:
- Number of bytes belonging to the number after the first byte.
 
 - 
getExtensionSizepublic static final byte getExtensionSize(byte firstbyte) Returns the number of bytes used for this number past the first byte.- Parameters:
- firstbyte- First byte of encoded VarInt.
- Returns:
- Number of bytes belonging to the number after the first byte.
 
 - 
decodepublic static final long decode(byte[] varint) Decodes a VarInt.- Parameters:
- varint- The encoded VarInt.
- Returns:
- The decoded VarInt.
 
 - 
decodepublic static final long decode(byte[] varint, int offset)Decodes a VarInt.- Parameters:
- varint- The encoded VarInt.
- Returns:
- The decoded VarInt.
 
 - 
decodeWithKnownSizepublic static final long decodeWithKnownSize(byte[] varint, int offset, byte extsize)Decodes a VarInt when the extension size is known.- Parameters:
- varint- The encoded VarInt.
- offset- The offset.
- The- number of bytes after the first byte.
- Returns:
- The decoded VarInt.
 
 - 
encodepublic static final byte[] encode(long val) Encodes a VarInt.- Parameters:
- val- The value being encoded.
- Returns:
- Encoded VarInt.
 
 - 
getEncodedSizepublic static final int getEncodedSize(long val) Determines the encoded size of a value.- Parameters:
- val- The value.
- Returns:
- The size of the encoded value.
 
 - 
encodepublic static final void encode(long val, byte[] buffer, int offset, int size)Encodes a VarInt and saves it in a buffer at the given offset.- Parameters:
- val- The value being encoded.
- buffer- The target buffer.
- offset- The buffer offset.
- size- Size of the encoded VarInt.
 
 
- 
 
-