Interface ChannelBuf
DataView
if necessary.-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
array()
Gets the backing byte array of this stream.Gets thisChannelBuf
as aInputStream
.Gets thisChannelBuf
as aOutputStream
.int
Gets the number of bytes available between the reader and the writer.int
capacity()
Gets the number of bytes this buffer can contain.clear()
Sets the readerIndex and writerIndex of this buffer to 0.ensureWritable
(int minWritableBytes) Makes sure the number of the writable bytes is equal to or greater than the specified value.boolean
getBoolean
(int index) Gets a boolean at the specified absolute index in this buffer.byte
getByte
(int index) Gets a byte at the specified absolute index in this buffer.byte[]
getByteArray
(int index) Gets a byte array at the specified absolute index in this buffer.byte[]
getByteArray
(int index, int limit) Gets a byte array at the specified absolute index in this buffer.char
getChar
(int index) Gets a character at the specified absolute index from this buffer.getDataView
(int index) Gets aDataView
at the specified absolute index in this buffer.double
getDouble
(int index) Gets a double at the specified absolute index in this buffer.double
getDoubleLE
(int index) Gets a double at the specified absolute index from this buffer in little endian byte order.float
getFloat
(int index) Gets a float at the specified absolute index from this buffer.float
getFloatLE
(int index) Gets a float at the specified absolute index from this buffer in little endian byte order.int
getInt
(int index) Gets an integer at the specified absolute index from this buffer.int
getIntLE
(int index) Gets an integer at the specified absolute index from this buffer in little endian byte order.long
getLong
(int index) Gets a long integer at the specified absolute index from this buffer.long
getLongLE
(int index) Gets a long integer at the specified absolute index from this buffer in little endian byte order.short
getShort
(int index) Gets a short integer at the specified absolute index from this buffer.short
getShortLE
(int index) Gets a short integer at the specified absolute index from this buffer in little endian byte order.getString
(int index) Gets a string at the specified absolute index in this buffer.getUniqueId
(int index) Gets aUUID
at the specified absolute index in this buffer.getUTF
(int index) Gets a string at the specified absolute index in this buffer.int
getVarInt
(int index) Gets a varint at the specified absolute index in this buffer.long
getVarLong
(int index) Gets a varlong at the specified absolute index in this buffer.boolean
hasArray()
Returnstrue
if and only if this buffer has a backing byte array.boolean
Gets a boolean at the current readerIndex and increases the readerIndex by 1 in this buffer.byte
readByte()
Gets a byte at the current readerIndex and increases the readerIndex by 1 in this buffer.byte[]
Gets a byte array at the current readerIndex and increases the readerIndex by the length of the array and the length of the array size.byte[]
readByteArray
(int limit) Gets a byte array at the current readerIndex and increases the readerIndex by the length of the array and the length of the array size.byte[]
readBytes
(int length) Gets a byte array at the current readerIndex and increases the readerIndex by the length of the array.byte[]
readBytes
(int index, int length) Gets a byte array at the specified absolute index in this buffer.char
readChar()
Gets a character at the current readerIndex from this buffer and increases the readerIndex by 2.Gets aDataView
at the current readerIndex and increases the readerIndex according to the length of the data view in this buffer.double
Gets a double at the current readerIndex and increases the readerIndex by 8 in this buffer.double
Gets a double at the current readerIndex from this buffer in little endian byte order and increases the readerIndex by 8.int
Gets the readerIndex of this buffer.readerIndex
(int index) Sets the readerIndex of this buffer.float
Gets a float at the current readerIndex of this buffer and increases the readerIndex by 4.float
Gets a float at the current readerIndex of this buffer in little endian byte order and increases the readerIndex by 4.int
readInt()
Gets an integer at the current readerIndex from this buffer and increases the readerIndex by 4.int
Gets an integer at the current readerIndex in little endian byte order from this buffer and increases the readerIndex by 4.long
readLong()
Gets a long integer at the current readerIndex from this buffer and increases the readerIndex by 8.long
Gets a long integer at the current readerIndex from this buffer in little endian byte order and increases the readerIndex by 8.short
Gets a short integer at the current readerIndex from this buffer and increases the readerIndex by 2.short
Gets a short integer at the current readerIndex from this buffer in little endian byte order and increases the readerIndex by 2.readSlice
(int length) Returns a slice of this buffer's sub-region at the current readerIndex.Gets a string at the current readerIndex and increases the readerIndex by the length of a varint followed by the utf-8 bytes of the string.Gets a UUID at the current readerIndex and increases the readerIndex by 16 in this buffer.readUTF()
Gets a string at the current readerIndex and increases the readerIndex by the length of a varint followed by the utf-8 bytes of the string.int
Gets a varint at the current readerIndex and increases the readerIndex by the number of bytes read.long
Gets a varlong at the current readerIndex and increases the readerIndex by the number of bytes read.setBoolean
(int index, boolean data) Sets the boolean at the specified absolute index in this buffer.setByte
(int index, byte data) Sets the byte at the specified absolute index in this buffer.setByteArray
(int index, byte[] data) Sets the specified byte array at the specified absolute index in this buffer.setByteArray
(int index, byte[] data, int start, int length) Sets the specified byte array at the specified absolute index in this buffer.setBytes
(int index, byte[] data) Sets the specified byte array at the specified absolute index in this buffer.setBytes
(int index, byte[] data, int start, int length) Sets the specified byte array at the specified absolute index in this buffer.setChar
(int index, char data) Sets the char at the specified absolute index of this buffer.setDataView
(int index, DataView data) Sets theDataView
at the specified absolute index in this buffer.setDouble
(int index, double data) Sets the double at the specified absolute index of this buffer.setDoubleLE
(int index, double data) Sets the double at the specified absolute index of this buffer in little endian byte order.setFloat
(int index, float data) Sets the float at the specified absolute index of this buffer.setFloatLE
(int index, float data) Sets the float at the specified absolute index of this buffer in little endian byte order.setIndex
(int readIndex, int writeIndex) Sets both the reader and writer indices.setInt
(int index, int data) Sets the integer at the specified absolute index of this buffer.setIntLE
(int index, int data) Sets the integer at the specified absolute index of this buffer in little endian byte order.setLong
(int index, long data) Sets the long integer at the specified absolute index of this buffer.setLongLE
(int index, long data) Sets the long integer at the specified absolute index of this buffer in little endian byte order.setShort
(int index, short data) Sets the short at the specified absolute index of this buffer.setShortLE
(int index, short data) Sets the short at the specified absolute index of this buffer in little endian byte order.Sets the string at the specified absolute index in this buffer.setUniqueId
(int index, UUID data) Sets theUUID
at the specified absolute index in this buffer.Sets the string at the specified absolute index in this buffer.setVarInt
(int index, int data) Sets the specified varint at the specified absolute index in this buffer.setVarLong
(int index, long value) Sets the specified varlong at the specified absolute index in this buffer.slice()
Returns a slice of this buffer's readable bytes.slice
(int index, int length) Returns a slice of this buffer's sub-region.writeBoolean
(boolean data) Sets the specified boolean at the current writerIndex and increases the writerIndex by 1 in this buffer.writeByte
(byte data) Sets the specified byte at the current writerIndex and increases the writerIndex by 1 in this buffer.writeByteArray
(byte[] data) Sets the specified byte array at the current writerIndex and increases the writerIndex by the number of bytes and the size of the length as a varint.writeByteArray
(byte[] data, int start, int length) Sets the specified byte array at the current writerIndex and increases the writerIndex by the length specified and the size of the length as a varint.writeBytes
(byte[] data) Sets the specified byte array at the current writerIndex and increases the writerIndex by the number of bytes.writeBytes
(byte[] data, int start, int length) Sets the specified byte array at the current writerIndex and increases the writerIndex by the length specified.writeChar
(char data) Sets the specified character at the current writerIndex of this buffer and increases the writerIndex by 2.writeDataView
(DataView data) Sets the specifiedDataView
at the current writerIndex and increases the writerIndex according to the length of the data view in this buffer.writeDouble
(double data) Sets the specified double at the current writerIndex of this buffer and increases the writerIndex by 8.writeDoubleLE
(double data) Sets the specified double at the current writerIndex of this buffer in little endian byte order and increases the writerIndex by 8.writeFloat
(float data) Sets the specified float at the current writerIndex of this buffer and increases the writerIndex by 4.writeFloatLE
(float data) Sets the specified float at the current writerIndex of this buffer in little endian byte order and increases the writerIndex by 4.writeInt
(int data) Sets the specified integer at the current writerIndex of this buffer and increases the writerIndex by 4.writeIntLE
(int data) Sets the specified integer at the current writerIndex of this buffer in little endian byte order and increases the writerIndex by 4.writeLong
(long data) Sets the specified long integer at the current writerIndex of this buffer and increases the writerIndex by 8.writeLongLE
(long data) Sets the specified long integer at the current writerIndex of this buffer in little endian byte order and increases the writerIndex by 8.int
Gets the writerIndex of this buffer.writerIndex
(int index) Sets the writerIndex of this buffer.writeShort
(short data) Sets the specified short integer at the current writerIndex of this buffer and increases the writerIndex by 2.writeShortLE
(short data) Sets the specified short integer at the current writerIndex in little endian byte order and increases the writerIndex by 2 in this buffer.writeString
(String data) Sets the specified string at the current writerIndex and increases the writerIndex by the length of the string.writeUniqueId
(UUID data) Sets the specifiedUUID
at the current writerIndex and increases the writerIndex by 16 in this buffer.Sets the specified string at the current writerIndex and increases the writerIndex by the length of the string.writeVarInt
(int data) Sets the specified varint at the current writerIndex and increases the writerIndex by the number of bytes written.writeVarLong
(long value) Sets the specified varlong at the current writerIndex and increases the writerIndex by the number of bytes written.
-
Method Details
-
capacity
int capacity()Gets the number of bytes this buffer can contain.- Returns:
- The number of bytes this buffer can contain
-
ensureWritable
Makes sure the number of the writable bytes is equal to or greater than the specified value.- Parameters:
minWritableBytes
- The minimum writable bytes- Returns:
- This stream for chaining
-
available
int available()Gets the number of bytes available between the reader and the writer.- Returns:
- The number of available bytes
-
readerIndex
int readerIndex()Gets the readerIndex of this buffer.- Returns:
- The current read index
-
readerIndex
Sets the readerIndex of this buffer.- Parameters:
index
- The new index- Returns:
- This stream for chaining
-
writerIndex
int writerIndex()Gets the writerIndex of this buffer.- Returns:
- The current write index
-
writerIndex
Sets the writerIndex of this buffer.- Parameters:
index
- The new index- Returns:
- This stream for chaining
-
setIndex
Sets both the reader and writer indices.- Parameters:
readIndex
- The reader indexwriteIndex
- The writer index- Returns:
- This stream for chaining
-
clear
ChannelBuf clear()Sets the readerIndex and writerIndex of this buffer to 0. This method is identical tosetIndex(int, int)
.- Returns:
- This stream for chaining
-
slice
ChannelBuf slice()Returns a slice of this buffer's readable bytes. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method is identical to buf.slice(buf.readerIndex(), buf.readableBytes()). This method does not modify readerIndex or writerIndex of this buffer.- Returns:
- The sliced stream
-
slice
Returns a slice of this buffer's sub-region. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method does not modify readerIndex or writerIndex of this buffer.- Parameters:
index
- The starter indexlength
- The ending index- Returns:
- The sliced stream
-
readSlice
Returns a slice of this buffer's sub-region at the current readerIndex. The readerIndex is increased by the given length.Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks.
- Parameters:
length
- The amount of bytes in the slice- Returns:
- The sliced stream
-
hasArray
boolean hasArray()Returnstrue
if and only if this buffer has a backing byte array.If this method returns true, you can safely call
array()
.- Returns:
true
if this buffer has a backing byte array
-
array
Gets the backing byte array of this stream.- Returns:
- A copy of the backing byte array
- Throws:
UnsupportedOperationException
- if there is no backing byte array
-
writeBoolean
Sets the specified boolean at the current writerIndex and increases the writerIndex by 1 in this buffer.- Parameters:
data
- The boolean data- Returns:
- This stream for chaining
-
setBoolean
Sets the boolean at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.- Parameters:
index
- The indexdata
- The boolean data- Returns:
- This stream for chaining
-
readBoolean
boolean readBoolean()Gets a boolean at the current readerIndex and increases the readerIndex by 1 in this buffer.- Returns:
- The boolean
-
getBoolean
boolean getBoolean(int index) Gets a boolean at the specified absolute index in this buffer.- Parameters:
index
- The index- Returns:
- The boolean
-
writeByte
Sets the specified byte at the current writerIndex and increases the writerIndex by 1 in this buffer.- Parameters:
data
- The byte data- Returns:
- This stream for chaining
-
setByte
Sets the byte at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.- Parameters:
index
- The indexdata
- The byte data- Returns:
- This stream for chaining
-
readByte
byte readByte()Gets a byte at the current readerIndex and increases the readerIndex by 1 in this buffer.- Returns:
- The byte
-
getByte
byte getByte(int index) Gets a byte at the specified absolute index in this buffer.- Parameters:
index
- The index- Returns:
- The byte
-
writeByteArray
Sets the specified byte array at the current writerIndex and increases the writerIndex by the number of bytes and the size of the length as a varint.The length of the array is written preceding the data as a varint.
- Parameters:
data
- The byte array data- Returns:
- This stream for chaining
-
writeByteArray
Sets the specified byte array at the current writerIndex and increases the writerIndex by the length specified and the size of the length as a varint.The length of the array is written preceding the data as a varint.
- Parameters:
data
- The byte array datastart
- The starting index of the source array to start reading fromlength
- The length of bytes to read from the source array- Returns:
- This stream for chaining
-
setByteArray
Sets the specified byte array at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.The length of the array is written preceding the data as a varint.
- Parameters:
index
- The indexdata
- The byte array data- Returns:
- This stream for chaining
-
setByteArray
Sets the specified byte array at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.The length of the array is written preceding the data as a varint.
- Parameters:
index
- The indexdata
- The byte array datastart
- The starting index of the source array to start reading fromlength
- The length of bytes to read from the source array- Returns:
- This stream for chaining
-
readByteArray
byte[] readByteArray()Gets a byte array at the current readerIndex and increases the readerIndex by the length of the array and the length of the array size.The length of the array is expected to be preceding the array as a varint.
- Returns:
- The byte array
-
readByteArray
byte[] readByteArray(int limit) Gets a byte array at the current readerIndex and increases the readerIndex by the length of the array and the length of the array size.The length of the array is expected to be preceding the array as a varint.
- Parameters:
limit
- The limit of the length of the array- Returns:
- The byte array
-
getByteArray
byte[] getByteArray(int index) Gets a byte array at the specified absolute index in this buffer.The length of the array is expected to be preceding the array as a varint.
- Parameters:
index
- The index to read the byte array at- Returns:
- The byte array
-
getByteArray
byte[] getByteArray(int index, int limit) Gets a byte array at the specified absolute index in this buffer.The length of the array is expected to be preceding the array as a varint.
- Parameters:
index
- The index to read the byte array atlimit
- The limit of the length of the array- Returns:
- The byte array
-
writeBytes
Sets the specified byte array at the current writerIndex and increases the writerIndex by the number of bytes.- Parameters:
data
- The byte array data- Returns:
- This stream for chaining
-
writeBytes
Sets the specified byte array at the current writerIndex and increases the writerIndex by the length specified.- Parameters:
data
- The byte array datastart
- The starting index of the source array to start reading fromlength
- The length of bytes to read from the source array- Returns:
- This stream for chaining
-
setBytes
Sets the specified byte array at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.- Parameters:
index
- The indexdata
- The byte array data- Returns:
- This stream for chaining
-
setBytes
Sets the specified byte array at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.- Parameters:
index
- The indexdata
- The byte array datastart
- The starting index of the source array to start reading fromlength
- The length of bytes to read from the source array- Returns:
- This stream for chaining
-
readBytes
byte[] readBytes(int length) Gets a byte array at the current readerIndex and increases the readerIndex by the length of the array.- Parameters:
length
- The length of the byte array to read from- Returns:
- The byte array
-
readBytes
byte[] readBytes(int index, int length) Gets a byte array at the specified absolute index in this buffer.- Parameters:
index
- The index of this channel buff to read fromlength
- The length of the byte array- Returns:
- The byte array
-
writeShort
Sets the specified short integer at the current writerIndex of this buffer and increases the writerIndex by 2.- Parameters:
data
- The short data- Returns:
- This stream for chaining
-
writeShortLE
Sets the specified short integer at the current writerIndex in little endian byte order and increases the writerIndex by 2 in this buffer.- Parameters:
data
- The short data- Returns:
- This stream for chaining
-
setShort
Sets the short at the specified absolute index of this buffer. This method does not modify readerIndex or writerIndex.- Parameters:
index
- The indexdata
- The short data- Returns:
- This stream for chaining
-
setShortLE
Sets the short at the specified absolute index of this buffer in little endian byte order. This method does not modify readerIndex or writerIndex.- Parameters:
index
- The indexdata
- The short data- Returns:
- This stream for chaining
-
readShort
short readShort()Gets a short integer at the current readerIndex from this buffer and increases the readerIndex by 2.- Returns:
- The short integer
-
readShortLE
short readShortLE()Gets a short integer at the current readerIndex from this buffer in little endian byte order and increases the readerIndex by 2.- Returns:
- The short integer
-
getShort
short getShort(int index) Gets a short integer at the specified absolute index from this buffer.- Parameters:
index
- The index- Returns:
- The short integer
-
getShortLE
short getShortLE(int index) Gets a short integer at the specified absolute index from this buffer in little endian byte order.- Parameters:
index
- The index- Returns:
- The short integer
-
writeChar
Sets the specified character at the current writerIndex of this buffer and increases the writerIndex by 2.- Parameters:
data
- The char data- Returns:
- This stream for chaining
-
setChar
Sets the char at the specified absolute index of this buffer. This method does not modify readerIndex or writerIndex.- Parameters:
index
- The indexdata
- The char data- Returns:
- This stream for chaining
-
readChar
char readChar()Gets a character at the current readerIndex from this buffer and increases the readerIndex by 2.- Returns:
- The character
-
getChar
char getChar(int index) Gets a character at the specified absolute index from this buffer.- Parameters:
index
- The index- Returns:
- The character
-
writeInt
Sets the specified integer at the current writerIndex of this buffer and increases the writerIndex by 4.- Parameters:
data
- The integer data- Returns:
- This stream for chaining
-
writeIntLE
Sets the specified integer at the current writerIndex of this buffer in little endian byte order and increases the writerIndex by 4.- Parameters:
data
- The integer data- Returns:
- This stream for chaining
-
setInt
Sets the integer at the specified absolute index of this buffer. This method does not modify readerIndex or writerIndex.- Parameters:
index
- The indexdata
- The integer data- Returns:
- This stream for chaining
-
setIntLE
Sets the integer at the specified absolute index of this buffer in little endian byte order. This method does not modify readerIndex or writerIndex.- Parameters:
index
- The indexdata
- The integer data- Returns:
- This stream for chaining
-
readInt
int readInt()Gets an integer at the current readerIndex from this buffer and increases the readerIndex by 4.- Returns:
- The integer
-
readIntLE
int readIntLE()Gets an integer at the current readerIndex in little endian byte order from this buffer and increases the readerIndex by 4.- Returns:
- The integer
-
getInt
int getInt(int index) Gets an integer at the specified absolute index from this buffer.- Parameters:
index
- The index- Returns:
- The integer
-
getIntLE
int getIntLE(int index) Gets an integer at the specified absolute index from this buffer in little endian byte order.- Parameters:
index
- The index- Returns:
- The integer
-
writeLong
Sets the specified long integer at the current writerIndex of this buffer and increases the writerIndex by 8.- Parameters:
data
- The long data- Returns:
- This stream for chaining
-
writeLongLE
Sets the specified long integer at the current writerIndex of this buffer in little endian byte order and increases the writerIndex by 8.- Parameters:
data
- The long data- Returns:
- This stream for chaining
-
setLong
Sets the long integer at the specified absolute index of this buffer. This method does not modify readerIndex or writerIndex.- Parameters:
index
- The indexdata
- The long data- Returns:
- This stream for chaining
-
setLongLE
Sets the long integer at the specified absolute index of this buffer in little endian byte order. This method does not modify readerIndex or writerIndex.- Parameters:
index
- The indexdata
- The long data- Returns:
- This stream for chaining
-
readLong
long readLong()Gets a long integer at the current readerIndex from this buffer and increases the readerIndex by 8.- Returns:
- The long integer
-
readLongLE
long readLongLE()Gets a long integer at the current readerIndex from this buffer in little endian byte order and increases the readerIndex by 8.- Returns:
- The long integer
-
getLong
long getLong(int index) Gets a long integer at the specified absolute index from this buffer. This method does not modify readerIndex.- Parameters:
index
- The index- Returns:
- The long integer
-
getLongLE
long getLongLE(int index) Gets a long integer at the specified absolute index from this buffer in little endian byte order. This method does not modify readerIndex.- Parameters:
index
- The index- Returns:
- The long integer
-
writeFloat
Sets the specified float at the current writerIndex of this buffer and increases the writerIndex by 4.- Parameters:
data
- The float data- Returns:
- This stream for chaining
-
writeFloatLE
Sets the specified float at the current writerIndex of this buffer in little endian byte order and increases the writerIndex by 4.- Parameters:
data
- The float data- Returns:
- This stream for chaining
-
setFloat
Sets the float at the specified absolute index of this buffer. This method does not modify readerIndex or writerIndex.- Parameters:
index
- The indexdata
- The float data- Returns:
- This stream for chaining
-
setFloatLE
Sets the float at the specified absolute index of this buffer in little endian byte order. This method does not modify readerIndex or writerIndex.- Parameters:
index
- The indexdata
- The float data- Returns:
- This stream for chaining
-
readFloat
float readFloat()Gets a float at the current readerIndex of this buffer and increases the readerIndex by 4.- Returns:
- The float
-
readFloatLE
float readFloatLE()Gets a float at the current readerIndex of this buffer in little endian byte order and increases the readerIndex by 4.- Returns:
- The float
-
getFloat
float getFloat(int index) Gets a float at the specified absolute index from this buffer. This method does not modify readerIndex.- Parameters:
index
- The index- Returns:
- The string
-
getFloatLE
float getFloatLE(int index) Gets a float at the specified absolute index from this buffer in little endian byte order. This method does not modify readerIndex.- Parameters:
index
- The index- Returns:
- The string
-
writeDouble
Sets the specified double at the current writerIndex of this buffer and increases the writerIndex by 8.- Parameters:
data
- The double data- Returns:
- This stream for chaining
-
writeDoubleLE
Sets the specified double at the current writerIndex of this buffer in little endian byte order and increases the writerIndex by 8.- Parameters:
data
- The double data- Returns:
- This stream for chaining
-
setDouble
Sets the double at the specified absolute index of this buffer. This method does not modify readerIndex or writerIndex.- Parameters:
index
- The indexdata
- The double data- Returns:
- This stream for chaining
-
setDoubleLE
Sets the double at the specified absolute index of this buffer in little endian byte order. This method does not modify readerIndex or writerIndex.- Parameters:
index
- The indexdata
- The double data- Returns:
- This stream for chaining
-
readDouble
double readDouble()Gets a double at the current readerIndex and increases the readerIndex by 8 in this buffer.- Returns:
- The double
-
readDoubleLE
double readDoubleLE()Gets a double at the current readerIndex from this buffer in little endian byte order and increases the readerIndex by 8.- Returns:
- The double
-
getDouble
double getDouble(int index) Gets a double at the specified absolute index in this buffer. This method does not modify readerIndex.- Parameters:
index
- The index- Returns:
- The double
-
getDoubleLE
double getDoubleLE(int index) Gets a double at the specified absolute index from this buffer in little endian byte order. This method does not modify readerIndex.- Parameters:
index
- The index- Returns:
- The double
-
writeVarInt
Sets the specified varint at the current writerIndex and increases the writerIndex by the number of bytes written.The number of bytes written depends on the size of the value, see https://developers.google.com/protocol-buffers/docs/encoding#varints for a full description.
- Parameters:
data
- The varint data- Returns:
- This stream for chaining
-
setVarInt
Sets the specified varint at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.The number of bytes written depends on the size of the value, see https://developers.google.com/protocol-buffers/docs/encoding#varints for a full description.
- Parameters:
index
- The indexdata
- The varint data- Returns:
- This stream for chaining
-
readVarInt
int readVarInt()Gets a varint at the current readerIndex and increases the readerIndex by the number of bytes read.The number of bytes read depends on the size of the value, see https://developers.google.com/protocol-buffers/docs/encoding#varints for a full description.
- Returns:
- The varint
-
getVarInt
int getVarInt(int index) Gets a varint at the specified absolute index in this buffer.The number of bytes read depends on the size of the value, see https://developers.google.com/protocol-buffers/docs/encoding#varints for a full description.
- Parameters:
index
- The index- Returns:
- The double
-
writeVarLong
Sets the specified varlong at the current writerIndex and increases the writerIndex by the number of bytes written.The number of bytes written depends on the size of the value.
- Parameters:
value
- The varlong value- Returns:
- This stream for chaining
-
setVarLong
Sets the specified varlong at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.The number of bytes written depends on the size of the value.
- Parameters:
index
- The indexvalue
- The varlong value- Returns:
- This stream for chaining
-
readVarLong
long readVarLong()Gets a varlong at the current readerIndex and increases the readerIndex by the number of bytes read.The number of bytes read depends on the size of the value.
- Returns:
- The varlong value
-
getVarLong
long getVarLong(int index) Gets a varlong at the specified absolute index in this buffer.The number of bytes read depends on the size of the value.
- Parameters:
index
- The index- Returns:
- The varlong value
-
writeString
Sets the specified string at the current writerIndex and increases the writerIndex by the length of the string.The string will be encoded as the utf length as a varint followed by the UTF-8 bytes of the string.
- Parameters:
data
- The string data- Returns:
- This stream for chaining
-
setString
Sets the string at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.The string will be encoded as the utf length as a varint followed by the UTF-8 bytes of the string.
- Parameters:
index
- The indexdata
- The string data- Returns:
- This stream for chaining
-
readString
String readString()Gets a string at the current readerIndex and increases the readerIndex by the length of a varint followed by the utf-8 bytes of the string.The string will be encoded as the utf length as a varint followed by the UTF-8 bytes of the string.
- Returns:
- The string
-
getString
Gets a string at the specified absolute index in this buffer.The string will be encoded as the utf length as a varint followed by the UTF-8 bytes of the string.
- Parameters:
index
- The index- Returns:
- The string
-
writeUTF
Sets the specified string at the current writerIndex and increases the writerIndex by the length of the string.The string will be encoded as the utf length as a short followed by the UTF-8 bytes of the string.
- Parameters:
data
- The string data- Returns:
- This stream for chaining
-
setUTF
Sets the string at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.The string will be encoded as the utf length as a short followed by the UTF-8 bytes of the string.
- Parameters:
index
- The indexdata
- The string data- Returns:
- This stream for chaining
-
readUTF
String readUTF()Gets a string at the current readerIndex and increases the readerIndex by the length of a varint followed by the utf-8 bytes of the string.The string will be encoded as the utf length as a short followed by the UTF-8 bytes of the string.
- Returns:
- The string
-
getUTF
Gets a string at the specified absolute index in this buffer.The string will be encoded as the utf length as a short followed by the UTF-8 bytes of the string.
- Parameters:
index
- The index- Returns:
- The string
-
writeUniqueId
Sets the specifiedUUID
at the current writerIndex and increases the writerIndex by 16 in this buffer.- Parameters:
data
- The unique id data- Returns:
- This stream for chaining
-
setUniqueId
Sets theUUID
at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.- Parameters:
index
- The indexdata
- The unique id data- Returns:
- This stream for chaining
-
readUniqueId
UUID readUniqueId()Gets a UUID at the current readerIndex and increases the readerIndex by 16 in this buffer.- Returns:
- This stream for chaining
-
getUniqueId
Gets aUUID
at the specified absolute index in this buffer.- Parameters:
index
- The index- Returns:
- The uuid
-
writeDataView
Sets the specifiedDataView
at the current writerIndex and increases the writerIndex according to the length of the data view in this buffer.- Parameters:
data
- The data view data- Returns:
- This stream for chaining
-
setDataView
Sets theDataView
at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.- Parameters:
index
- The indexdata
- The data view data- Returns:
- This stream for chaining
-
readDataView
DataView readDataView()Gets aDataView
at the current readerIndex and increases the readerIndex according to the length of the data view in this buffer.- Returns:
- The data view
-
getDataView
Gets aDataView
at the specified absolute index in this buffer.- Parameters:
index
- The index- Returns:
- The data view
-
asOutputStream
OutputStream asOutputStream()Gets thisChannelBuf
as aOutputStream
.- Returns:
- The output stream
-
asInputStream
InputStream asInputStream()Gets thisChannelBuf
as aInputStream
.- Returns:
- The input stream
-