public interface ChannelBuf
DataView
if necessary.Modifier and Type | Method and Description |
---|---|
byte[] |
array()
Gets the backing byte array of this stream.
|
int |
available()
Gets the number of bytes available between the reader and the writer.
|
ChannelBuf |
clear()
Sets the readerIndex and writerIndex of this buffer to 0.
|
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.
|
ByteOrder |
getByteOrder()
Returns the endianness (
ByteOrder ) of this buffer. |
int |
getCapacity()
Gets the number of bytes this buffer can contain.
|
char |
getChar(int index)
Gets a character at the specified absolute index in this buffer.
|
DataView |
getDataView(int index)
Gets a
DataView at the specified absolute index in this buffer. |
double |
getDouble(int index)
Gets a double at the specified absolute index in this buffer.
|
float |
getFloat(int index)
Gets a float at the specified absolute index in this buffer.
|
int |
getInteger(int index)
Gets an integer at the specified absolute index in this buffer.
|
long |
getLong(int index)
Gets a long integer at the specified absolute index in this buffer.
|
short |
getShort(int index)
Gets a short integer at the specified absolute index in this buffer.
|
String |
getString(int index)
Gets a string at the specified absolute index in this buffer.
|
UUID |
getUniqueId(int index)
Gets a
UUID at the specified absolute index in this buffer. |
String |
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.
|
boolean |
hasArray()
Returns
true if and only if this buffer has a backing byte array. |
ChannelBuf |
markRead()
Marks the current readerIndex in this buffer.
|
ChannelBuf |
markWrite()
Marks the current writerIndex in this buffer.
|
ChannelBuf |
order(ByteOrder order)
Returns a buffer with the specified endianness which shares the whole
region, indexes, and marks of this buffer.
|
boolean |
readBoolean()
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[] |
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.
|
byte[] |
readByteArray(int index)
Gets a byte array at the specified absolute index in this buffer.
|
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 and increases the
readerIndex by 2 in this buffer.
|
DataView |
readDataView()
Gets a
DataView at the current readerIndex and increases the
readerIndex according to the length of the data view in this buffer. |
double |
readDouble()
Gets a double at the current readerIndex and increases the
readerIndex by 8 in this buffer.
|
int |
readerIndex()
Gets the readerIndex of this buffer.
|
float |
readFloat()
Gets a float at the current readerIndex and increases the
readerIndex by 4 in this buffer.
|
int |
readInteger()
Gets an integer at the current readerIndex and increases the
readerIndex by 4 in this buffer.
|
long |
readLong()
Gets a long integer at the current readerIndex and increases the
readerIndex by 8 in this buffer.
|
short |
readShort()
Gets a short integer at the current readerIndex and increases the
readerIndex by 2 in this buffer.
|
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.
|
UUID |
readUniqueId()
Gets a UUID at the current readerIndex and increases the
readerIndex by 16 in this buffer.
|
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.
|
int |
readVarInt()
Gets a varint at the current readerIndex and increases the readerIndex by
the number of bytes read.
|
ChannelBuf |
resetRead()
Resets the current readerIndex in this buffer to the marked reader
index.
|
ChannelBuf |
resetWrite()
Resets the current writerIndex in this buffer to the marked writer
index.
|
ChannelBuf |
setBoolean(int index,
boolean data)
Sets the boolean at the specified absolute index in this
buffer.
|
ChannelBuf |
setByte(int index,
byte data)
Sets the byte at the specified absolute index in this
buffer.
|
ChannelBuf |
setByteArray(int index,
byte[] data)
Sets the specified byte array at the specified absolute index in this
buffer.
|
ChannelBuf |
setByteArray(int index,
byte[] data,
int start,
int length)
Sets the specified byte array at the specified absolute index in this
buffer.
|
ChannelBuf |
setBytes(int index,
byte[] data)
Sets the specified byte array at the specified absolute index in this
buffer.
|
ChannelBuf |
setBytes(int index,
byte[] data,
int start,
int length)
Sets the specified byte array at the specified absolute index in this
buffer.
|
ChannelBuf |
setChar(int index,
char data)
Sets the char at the specified absolute index in this
buffer.
|
ChannelBuf |
setDataView(int index,
DataView data)
Sets the
DataView at the specified absolute index in this
buffer. |
ChannelBuf |
setDouble(int index,
double data)
Sets the double at the specified absolute index in this
buffer.
|
ChannelBuf |
setFloat(int index,
float data)
Sets the float at the specified absolute index in this
buffer.
|
ChannelBuf |
setIndex(int readIndex,
int writeIndex)
Sets both the reader and writer indices.
|
ChannelBuf |
setInteger(int index,
int data)
Sets the integer at the specified absolute index in this
buffer.
|
ChannelBuf |
setLong(int index,
long data)
Sets the long integer at the specified absolute index in this
buffer.
|
ChannelBuf |
setReadIndex(int index)
Sets the readerIndex of this buffer.
|
ChannelBuf |
setShort(int index,
short data)
Sets the short at the specified absolute index in this
buffer.
|
ChannelBuf |
setString(int index,
String data)
Sets the string at the specified absolute index in this
buffer.
|
ChannelBuf |
setUniqueId(int index,
UUID data)
Sets the
UUID at the specified absolute index in this
buffer. |
ChannelBuf |
setUTF(int index,
String data)
Sets the string at the specified absolute index in this
buffer.
|
ChannelBuf |
setVarInt(int index,
int data)
Sets the specified varint at the specified absolute index in this buffer.
|
ChannelBuf |
setWriteIndex(int index)
Sets the writerIndex of this buffer.
|
ChannelBuf |
slice()
Returns a slice of this buffer's readable bytes.
|
ChannelBuf |
slice(int index,
int length)
Returns a slice of this buffer's sub-region.
|
ChannelBuf |
writeBoolean(boolean data)
Sets the specified boolean at the current writerIndex and increases
the writerIndex by 1 in this buffer.
|
ChannelBuf |
writeByte(byte data)
Sets the specified byte at the current writerIndex and increases
the writerIndex by 1 in this buffer.
|
ChannelBuf |
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.
|
ChannelBuf |
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.
|
ChannelBuf |
writeBytes(byte[] data)
Sets the specified byte array at the current writerIndex and increases
the writerIndex by the number of bytes.
|
ChannelBuf |
writeBytes(byte[] data,
int start,
int length)
Sets the specified byte array at the current writerIndex and increases
the writerIndex by the length specified.
|
ChannelBuf |
writeChar(char data)
Sets the specified character at the current writerIndex and
increases the writerIndex by 2 in this buffer.
|
ChannelBuf |
writeDataView(DataView data)
Sets the specified
DataView at the current writerIndex and
increases the writerIndex according to the length of the data view
in this buffer. |
ChannelBuf |
writeDouble(double data)
Sets the specified double at the current writerIndex and increases
the writerIndex by 8 in this buffer.
|
ChannelBuf |
writeFloat(float data)
Sets the specified float at the current writerIndex and increases
the writerIndex by 4 in this buffer.
|
ChannelBuf |
writeInteger(int data)
Sets the specified integer at the current writerIndex and increases
the writerIndex by 4 in this buffer.
|
ChannelBuf |
writeLong(long data)
Sets the specified long integer at the current writerIndex and
increases the writerIndex by 8 in this buffer.
|
int |
writerIndex()
Gets the writerIndex of this buffer.
|
ChannelBuf |
writeShort(short data)
Sets the specified short integer at the current writerIndex and
increases the writerIndex by 2 in this buffer.
|
ChannelBuf |
writeString(String data)
Sets the specified string at the current writerIndex and increases the
writerIndex by the length of the string.
|
ChannelBuf |
writeUniqueId(UUID data)
Sets the specified
UUID at the current writerIndex and
increases the writerIndex by 16 in this buffer. |
ChannelBuf |
writeUTF(String data)
Sets the specified string at the current writerIndex and increases the
writerIndex by the length of the string.
|
ChannelBuf |
writeVarInt(int data)
Sets the specified varint at the current writerIndex and increases the
writerIndex by the number of bytes written.
|
int getCapacity()
int available()
ChannelBuf order(ByteOrder order)
If the specified endianness is identical to this buffer's byte order, this method can return this.
This method does not modify readerIndex or writerIndex of this buffer.
order
- The orderByteOrder getByteOrder()
ByteOrder
) of this buffer.int readerIndex()
ChannelBuf setReadIndex(int index)
index
- The new indexint writerIndex()
ChannelBuf setWriteIndex(int index)
index
- The new indexChannelBuf setIndex(int readIndex, int writeIndex)
readIndex
- The reader indexwriteIndex
- The writer indexChannelBuf clear()
setIndex(int, int)
.ChannelBuf markRead()
ChannelBuf markWrite()
ChannelBuf resetRead()
ChannelBuf resetWrite()
ChannelBuf slice()
ChannelBuf slice(int index, int length)
index
- The starter indexlength
- The ending indexboolean hasArray()
true
if and only if this buffer has a backing byte array.
If this method returns true, you can safely call array()
.
true
if this buffer has a backing byte arraybyte[] array() throws UnsupportedOperationException
UnsupportedOperationException
- if there is no backing byte arrayChannelBuf writeBoolean(boolean data)
data
- The boolean dataChannelBuf setBoolean(int index, boolean data)
index
- The indexdata
- The boolean databoolean readBoolean()
boolean getBoolean(int index)
index
- The indexChannelBuf writeByte(byte data)
data
- The byte dataChannelBuf setByte(int index, byte data)
index
- The indexdata
- The byte databyte readByte()
byte getByte(int index)
index
- The indexChannelBuf writeByteArray(byte[] data)
The length of the array is written preceding the data as a varint.
data
- The byte array dataChannelBuf writeByteArray(byte[] data, int start, int length)
The length of the array is written preceding the data as a varint.
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 arrayChannelBuf setByteArray(int index, byte[] data)
The length of the array is written preceding the data as a varint.
index
- The indexdata
- The byte array dataChannelBuf setByteArray(int index, byte[] data, int start, int length)
The length of the array is written preceding the data as a varint.
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 arraybyte[] readByteArray()
The length of the array is expected to be preceding the array as a varint.
byte[] readByteArray(int index)
The length of the array is expected to be preceding the array as a varint.
index
- The index to read the byte array atChannelBuf writeBytes(byte[] data)
data
- The byte array dataChannelBuf writeBytes(byte[] data, int start, int length)
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 arrayChannelBuf setBytes(int index, byte[] data)
index
- The indexdata
- The byte array dataChannelBuf setBytes(int index, byte[] data, int start, int length)
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 arraybyte[] readBytes(int length)
length
- The length of the byte array to read frombyte[] readBytes(int index, int length)
index
- The index of this channel buff to read fromlength
- The length of the byte arrayChannelBuf writeShort(short data)
data
- The short dataChannelBuf setShort(int index, short data)
index
- The indexdata
- The short datashort readShort()
short getShort(int index)
index
- The indexChannelBuf writeChar(char data)
data
- The char dataChannelBuf setChar(int index, char data)
index
- The indexdata
- The char datachar readChar()
char getChar(int index)
index
- The indexChannelBuf writeInteger(int data)
data
- The integer dataChannelBuf setInteger(int index, int data)
index
- The indexdata
- The integer dataint readInteger()
int getInteger(int index)
index
- The indexChannelBuf writeLong(long data)
data
- The long dataChannelBuf setLong(int index, long data)
index
- The indexdata
- The long datalong readLong()
long getLong(int index)
index
- The indexChannelBuf writeFloat(float data)
data
- The float dataChannelBuf setFloat(int index, float data)
index
- The indexdata
- The float datafloat readFloat()
float getFloat(int index)
index
- The indexChannelBuf writeDouble(double data)
data
- The double dataChannelBuf setDouble(int index, double data)
index
- The indexdata
- The double datadouble readDouble()
double getDouble(int index)
index
- The indexChannelBuf writeVarInt(int data)
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.
data
- The varint dataChannelBuf setVarInt(int index, int data)
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.
index
- The indexdata
- The varint dataint readVarInt()
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.
int getVarInt(int index)
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.
index
- The indexChannelBuf writeString(String data)
The string will be encoded as the utf length as a varint followed by the UTF-8 bytes of the string.
data
- The string dataChannelBuf setString(int index, String data)
The string will be encoded as the utf length as a varint followed by the UTF-8 bytes of the string.
index
- The indexdata
- The string dataString readString()
The string will be encoded as the utf length as a varint followed by the UTF-8 bytes of the string.
String getString(int index)
The string will be encoded as the utf length as a varint followed by the UTF-8 bytes of the string.
index
- The indexChannelBuf writeUTF(String data)
The string will be encoded as the utf length as a short followed by the UTF-8 bytes of the string.
data
- The string dataChannelBuf setUTF(int index, String data)
The string will be encoded as the utf length as a short followed by the UTF-8 bytes of the string.
index
- The indexdata
- The string dataString readUTF()
The string will be encoded as the utf length as a short followed by the UTF-8 bytes of the string.
String getUTF(int index)
The string will be encoded as the utf length as a short followed by the UTF-8 bytes of the string.
index
- The indexChannelBuf writeUniqueId(UUID data)
UUID
at the current writerIndex and
increases the writerIndex by 16 in this buffer.data
- The unique id dataChannelBuf setUniqueId(int index, UUID data)
UUID
at the specified absolute index in this
buffer. This method does not modify readerIndex or writerIndex
of this buffer.index
- The indexdata
- The unique id dataUUID readUniqueId()
UUID getUniqueId(int index)
UUID
at the specified absolute index in this buffer.index
- The indexChannelBuf writeDataView(DataView data)
DataView
at the current writerIndex and
increases the writerIndex according to the length of the data view
in this buffer.data
- The data view dataChannelBuf setDataView(int index, DataView data)
DataView
at the specified absolute index in this
buffer. This method does not modify readerIndex or writerIndex
of this buffer.index
- The indexdata
- The data view dataDataView readDataView()
DataView
at the current readerIndex and increases the
readerIndex according to the length of the data view in this buffer.