Contents
- Description
- Method Summary
- Method Details
- writeSignedVarLong(long, DataOutput)
- writeUnsignedVarLong(long, DataOutput)
- writeSignedVarInt(int, DataOutput)
- writeUnsignedVarInt(int, DataOutput)
- writeSignedVarInt(int)
- writeUnsignedVarInt(int)
- readSignedVarLong(DataInput)
- readUnsignedVarLong(DataInput)
- readSignedVarInt(DataInput)
- readUnsignedVarInt(DataInput)
- readSignedVarInt(byte[])
- readUnsignedVarInt(byte[])
Class VarInt
java.lang.Object
com.hypixel.hytale.math.data.VarInt
- Since:
- 16.03.2016
-
Method Summary
Modifier and TypeMethodDescriptionstatic intreadSignedVarInt(byte[] bytes) static intstatic longstatic intreadUnsignedVarInt(byte[] bytes) static intstatic longstatic byte[]writeSignedVarInt(int value) static voidwriteSignedVarInt(int value, DataOutput out) Encodes a value using the variable-length encoding from Google Protocol Buffers.static voidwriteSignedVarLong(long value, DataOutput out) Encodes a value using the variable-length encoding from Google Protocol Buffers.static byte[]writeUnsignedVarInt(int value) static voidwriteUnsignedVarInt(int value, DataOutput out) Encodes a value using the variable-length encoding from Google Protocol Buffers.static voidwriteUnsignedVarLong(long value, DataOutput out) Encodes a value using the variable-length encoding from Google Protocol Buffers.
-
Method Details
-
writeSignedVarLong
Encodes a value using the variable-length encoding from Google Protocol Buffers. It uses zig-zag encoding to efficiently encode signed values. If values are known to be nonnegative,writeUnsignedVarLong(long, DataOutput)should be used.- Parameters:
value- value to encodeout- to write bytes to- Throws:
IOException- ifDataOutputthrowsIOException
-
writeUnsignedVarLong
Encodes a value using the variable-length encoding from Google Protocol Buffers. Zig-zag is not used, so input must not be negative. If values can be negative, usewriteSignedVarLong(long, DataOutput)instead. This method treats negative input as like a large unsigned value.- Parameters:
value- value to encodeout- to write bytes to- Throws:
IOException- ifDataOutputthrowsIOException
-
writeSignedVarInt
Encodes a value using the variable-length encoding from Google Protocol Buffers. It uses zig-zag encoding to efficiently encode signed values. If values are known to be nonnegative,writeUnsignedVarLong(long, DataOutput)should be used.- Parameters:
value- value to encodeout- to write bytes to- Throws:
IOException- ifDataOutputthrowsIOException
-
writeUnsignedVarInt
Encodes a value using the variable-length encoding from Google Protocol Buffers. Zig-zag is not used, so input must not be negative. If values can be negative, usewriteSignedVarLong(long, DataOutput)instead. This method treats negative input as like a large unsigned value.- Parameters:
value- value to encodeout- to write bytes to- Throws:
IOException- ifDataOutputthrowsIOException
-
writeSignedVarInt
public static byte[] writeSignedVarInt(int value) -
writeUnsignedVarInt
public static byte[] writeUnsignedVarInt(int value) - Parameters:
value- value to encode- Returns:
- the byte array of the encoded value
- See Also:
-
readSignedVarLong
- Parameters:
in- to read bytes from- Returns:
- decode value
- Throws:
IOException- ifDataInputthrowsIOExceptionIllegalArgumentException- if variable-length value does not terminate after 9 bytes have been read- See Also:
-
readUnsignedVarLong
- Parameters:
in- to read bytes from- Returns:
- decode value
- Throws:
IOException- ifDataInputthrowsIOExceptionIllegalArgumentException- if variable-length value does not terminate after 9 bytes have been read- See Also:
-
readSignedVarInt
- Parameters:
in- the input- Returns:
- the varint read from data input
- Throws:
IllegalArgumentException- if variable-length value does not terminate after 5 bytes have been readIOException- ifDataInputthrowsIOException- See Also:
-
readUnsignedVarInt
- Parameters:
in- the input- Returns:
- the var int read from in
- Throws:
IllegalArgumentException- if variable-length value does not terminate after 5 bytes have been readIOException- ifDataInputthrowsIOException- See Also:
-
readSignedVarInt
public static int readSignedVarInt(@Nonnull byte[] bytes) -
readUnsignedVarInt
public static int readUnsignedVarInt(@Nonnull byte[] bytes)
-