public class PacketByteBuf
extends io.netty.buffer.ByteBuf
| Constructor and Description |
|---|
PacketByteBuf() |
PacketByteBuf(io.netty.buffer.ByteBuf byteBuf) |
| Modifier and Type | Method and Description |
|---|---|
io.netty.buffer.ByteBufAllocator |
alloc()
Returns the
ByteBufAllocator which created this buffer. |
byte[] |
array()
Returns the backing byte array of this buffer.
|
int |
arrayOffset()
Returns the offset of the first byte within the backing byte array of
this buffer.
|
io.netty.buffer.ByteBuf |
asReadOnly()
Returns a read-only version of this buffer.
|
int |
bytesBefore(byte value)
Locates the first occurrence of the specified
value in this
buffer. |
int |
bytesBefore(int length,
byte value)
Locates the first occurrence of the specified
value in this
buffer. |
int |
bytesBefore(int index,
int length,
byte value)
Locates the first occurrence of the specified
value in this
buffer. |
int |
capacity()
Returns the number of bytes (octets) this buffer can contain.
|
io.netty.buffer.ByteBuf |
capacity(int newCapacity)
Adjusts the capacity of this buffer.
|
io.netty.buffer.ByteBuf |
clear()
Sets the
readerIndex and writerIndex of this buffer to
0. |
int |
compareTo(io.netty.buffer.ByteBuf buffer)
Compares the content of the specified buffer to the content of this
buffer.
|
io.netty.buffer.ByteBuf |
copy()
Returns a copy of this buffer's readable bytes.
|
io.netty.buffer.ByteBuf |
copy(int index,
int length)
Returns a copy of this buffer's sub-region.
|
io.netty.buffer.ByteBuf |
discardReadBytes()
Discards the bytes between the 0th index and
readerIndex. |
io.netty.buffer.ByteBuf |
discardSomeReadBytes()
Similar to
ByteBuf.discardReadBytes() except that this method might discard
some, all, or none of read bytes depending on its internal implementation to reduce
overall memory bandwidth consumption at the cost of potentially additional memory
consumption. |
io.netty.buffer.ByteBuf |
duplicate()
Returns a buffer which shares the whole region of this buffer.
|
io.netty.buffer.ByteBuf |
ensureWritable(int minWritableBytes)
Expands the buffer
capacity() to make sure the number of
writable bytes is equal to or greater than the
specified value. |
int |
ensureWritable(int minWritableBytes,
boolean force)
Expands the buffer
capacity() to make sure the number of
writable bytes is equal to or greater than the
specified value. |
boolean |
equals(java.lang.Object obj)
Determines if the content of the specified buffer is identical to the
content of this array.
|
int |
forEachByte(io.netty.util.ByteProcessor processor)
Iterates over the readable bytes of this buffer with the specified
processor in ascending order. |
int |
forEachByte(int index,
int length,
io.netty.util.ByteProcessor processor)
Iterates over the specified area of this buffer with the specified
processor in ascending order. |
int |
forEachByteDesc(io.netty.util.ByteProcessor processor)
Iterates over the readable bytes of this buffer with the specified
processor in descending order. |
int |
forEachByteDesc(int index,
int length,
io.netty.util.ByteProcessor processor)
Iterates over the specified area of this buffer with the specified
processor in descending order. |
boolean |
getBoolean(int index)
Gets a boolean at the specified absolute (@code index) in this buffer.
|
byte |
getByte(int index)
Gets a byte at the specified absolute
index in this buffer. |
io.netty.buffer.ByteBuf |
getBytes(int index,
byte[] dst)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index. |
io.netty.buffer.ByteBuf |
getBytes(int index,
byte[] dst,
int dstIndex,
int length)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index. |
io.netty.buffer.ByteBuf |
getBytes(int index,
io.netty.buffer.ByteBuf dst)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index until the destination becomes
non-writable. |
io.netty.buffer.ByteBuf |
getBytes(int index,
java.nio.ByteBuffer dst)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index until the destination's position
reaches its limit. |
io.netty.buffer.ByteBuf |
getBytes(int index,
io.netty.buffer.ByteBuf dst,
int length)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index. |
io.netty.buffer.ByteBuf |
getBytes(int index,
io.netty.buffer.ByteBuf dst,
int dstIndex,
int length)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index. |
int |
getBytes(int index,
java.nio.channels.FileChannel out,
long position,
int length)
Transfers this buffer's data starting at the specified absolute
index
to the specified channel starting at the given file position. |
int |
getBytes(int index,
java.nio.channels.GatheringByteChannel out,
int length)
Transfers this buffer's data to the specified channel starting at the
specified absolute
index. |
io.netty.buffer.ByteBuf |
getBytes(int index,
java.io.OutputStream out,
int length)
Transfers this buffer's data to the specified stream starting at the
specified absolute
index. |
char |
getChar(int index)
Gets a 2-byte UTF-16 character at the specified absolute
index in this buffer. |
java.lang.CharSequence |
getCharSequence(int index,
int length,
java.nio.charset.Charset charset)
Gets a
CharSequence with the given length at the given index. |
double |
getDouble(int index)
Gets a 64-bit floating point number at the specified absolute
index in this buffer. |
float |
getFloat(int index)
Gets a 32-bit floating point number at the specified absolute
index in this buffer. |
int |
getInt(int index)
Gets a 32-bit integer at the specified absolute
index in
this buffer. |
int |
getIntLE(int index)
Gets a 32-bit integer at the specified absolute
index in
this buffer with Little Endian Byte Order. |
long |
getLong(int index)
Gets a 64-bit long integer at the specified absolute
index in
this buffer. |
long |
getLongLE(int index)
Gets a 64-bit long integer at the specified absolute
index in
this buffer in Little Endian Byte Order. |
int |
getMedium(int index)
Gets a 24-bit medium integer at the specified absolute
index in
this buffer. |
int |
getMediumLE(int index)
Gets a 24-bit medium integer at the specified absolute
index in
this buffer in the Little Endian Byte Order. |
short |
getShort(int index)
Gets a 16-bit short integer at the specified absolute
index in
this buffer. |
short |
getShortLE(int index)
Gets a 16-bit short integer at the specified absolute
index in
this buffer in Little Endian Byte Order. |
short |
getUnsignedByte(int index)
Gets an unsigned byte at the specified absolute
index in this
buffer. |
long |
getUnsignedInt(int index)
Gets an unsigned 32-bit integer at the specified absolute
index
in this buffer. |
long |
getUnsignedIntLE(int index)
Gets an unsigned 32-bit integer at the specified absolute
index
in this buffer in Little Endian Byte Order. |
int |
getUnsignedMedium(int index)
Gets an unsigned 24-bit medium integer at the specified absolute
index in this buffer. |
int |
getUnsignedMediumLE(int index)
Gets an unsigned 24-bit medium integer at the specified absolute
index in this buffer in Little Endian Byte Order. |
int |
getUnsignedShort(int index)
Gets an unsigned 16-bit short integer at the specified absolute
index in this buffer. |
int |
getUnsignedShortLE(int index)
Gets an unsigned 16-bit short integer at the specified absolute
index in this buffer in Little Endian Byte Order. |
static int |
getVarIntLength(int value)
Returns the number of bytes needed to encode
value as a
var int. |
boolean |
hasArray()
Returns
true if and only if this buffer has a backing byte array. |
int |
hashCode()
Returns a hash code which was calculated from the content of this
buffer.
|
boolean |
hasMemoryAddress()
Returns
true if and only if this buffer has a reference to the low-level memory address that points
to the backing data. |
int |
indexOf(int fromIndex,
int toIndex,
byte value)
Locates the first occurrence of the specified
value in this
buffer. |
java.nio.ByteBuffer |
internalNioBuffer(int index,
int length)
Internal use only: Exposes the internal NIO buffer.
|
boolean |
isDirect()
Returns
true if and only if this buffer is backed by an
NIO direct buffer. |
boolean |
isReadable()
Returns
true
if and only if (this.writerIndex - this.readerIndex) is greater
than 0. |
boolean |
isReadable(int size)
Returns
true if and only if this buffer contains equal to or more than the specified number of elements. |
boolean |
isReadOnly()
Returns
true if and only if this buffer is read-only. |
boolean |
isWritable()
Returns
true
if and only if (this.capacity - this.writerIndex) is greater
than 0. |
boolean |
isWritable(int size)
Returns
true if and only if this buffer has enough room to allow writing the specified number of
elements. |
io.netty.buffer.ByteBuf |
markReaderIndex()
Marks the current
readerIndex in this buffer. |
io.netty.buffer.ByteBuf |
markWriterIndex()
Marks the current
writerIndex in this buffer. |
int |
maxCapacity()
Returns the maximum allowed capacity of this buffer.
|
int |
maxWritableBytes()
Returns the maximum possible number of writable bytes, which is equal to
(this.maxCapacity - this.writerIndex). |
long |
memoryAddress()
Returns the low-level memory address that point to the first byte of ths backing data.
|
java.nio.ByteBuffer |
nioBuffer()
Exposes this buffer's readable bytes as an NIO
ByteBuffer. |
java.nio.ByteBuffer |
nioBuffer(int index,
int length)
Exposes this buffer's sub-region as an NIO
ByteBuffer. |
int |
nioBufferCount()
Returns the maximum number of NIO
ByteBuffers that consist this buffer. |
java.nio.ByteBuffer[] |
nioBuffers()
Exposes this buffer's readable bytes as an NIO
ByteBuffer's. |
java.nio.ByteBuffer[] |
nioBuffers(int index,
int length)
Exposes this buffer's bytes as an NIO
ByteBuffer's for the specified index and length
The returned buffer either share or contains the copied content of this buffer, while changing
the position and limit of the returned NIO buffer does not affect the indexes and marks of this buffer. |
java.nio.ByteOrder |
order()
Deprecated.
use the Little Endian accessors, e.g.
getShortLE, getIntLE
instead of creating a buffer with swapped endianness. |
io.netty.buffer.ByteBuf |
order(java.nio.ByteOrder endianness)
Deprecated.
use the Little Endian accessors, e.g.
getShortLE, getIntLE
instead of creating a buffer with swapped endianness. |
int |
readableBytes()
Returns the number of readable bytes which is equal to
(this.writerIndex - this.readerIndex). |
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()
Reads an array of primitive bytes from this buf.
|
byte[] |
readByteArray(int maxSize)
Reads an array of primitive bytes from this buf.
|
io.netty.buffer.ByteBuf |
readBytes(byte[] dst)
Transfers this buffer's data to the specified destination starting at
the current
readerIndex and increases the readerIndex
by the number of the transferred bytes (= dst.length). |
io.netty.buffer.ByteBuf |
readBytes(byte[] dst,
int dstIndex,
int length)
Transfers this buffer's data to the specified destination starting at
the current
readerIndex and increases the readerIndex
by the number of the transferred bytes (= length). |
io.netty.buffer.ByteBuf |
readBytes(io.netty.buffer.ByteBuf dst)
Transfers this buffer's data to the specified destination starting at
the current
readerIndex until the destination becomes
non-writable, and increases the readerIndex by the number of the
transferred bytes. |
io.netty.buffer.ByteBuf |
readBytes(java.nio.ByteBuffer dst)
Transfers this buffer's data to the specified destination starting at
the current
readerIndex until the destination's position
reaches its limit, and increases the readerIndex by the
number of the transferred bytes. |
io.netty.buffer.ByteBuf |
readBytes(io.netty.buffer.ByteBuf dst,
int length)
Transfers this buffer's data to the specified destination starting at
the current
readerIndex and increases the readerIndex
by the number of the transferred bytes (= length). |
io.netty.buffer.ByteBuf |
readBytes(io.netty.buffer.ByteBuf dst,
int dstIndex,
int length)
Transfers this buffer's data to the specified destination starting at
the current
readerIndex and increases the readerIndex
by the number of the transferred bytes (= length). |
int |
readBytes(java.nio.channels.FileChannel out,
long position,
int length)
Transfers this buffer's data starting at the current
readerIndex
to the specified channel starting at the given file position. |
int |
readBytes(java.nio.channels.GatheringByteChannel out,
int length)
Transfers this buffer's data to the specified stream starting at the
current
readerIndex. |
io.netty.buffer.ByteBuf |
readBytes(int length)
Transfers this buffer's data to a newly created buffer starting at
the current
readerIndex and increases the readerIndex
by the number of the transferred bytes (= length). |
io.netty.buffer.ByteBuf |
readBytes(java.io.OutputStream out,
int length)
Transfers this buffer's data to the specified stream starting at the
current
readerIndex. |
char |
readChar()
Gets a 2-byte UTF-16 character at the current
readerIndex
and increases the readerIndex by 2 in this buffer. |
java.lang.CharSequence |
readCharSequence(int length,
java.nio.charset.Charset charset)
Gets a
CharSequence with the given length at the current readerIndex
and increases the readerIndex by the given length. |
double |
readDouble()
Gets a 64-bit floating point number at the current
readerIndex
and increases the readerIndex by 8 in this buffer. |
int |
readerIndex()
Returns the
readerIndex of this buffer. |
io.netty.buffer.ByteBuf |
readerIndex(int readerIndex)
Sets the
readerIndex of this buffer. |
float |
readFloat()
Gets a 32-bit floating point number at the current
readerIndex
and increases the readerIndex by 4 in this buffer. |
int |
readInt()
Gets a 32-bit integer at the current
readerIndex
and increases the readerIndex by 4 in this buffer. |
int[] |
readIntArray()
Reads an array of primitive ints from this buf.
|
int[] |
readIntArray(int maxSize)
Reads an array of primitive ints from this buf.
|
int |
readIntLE()
Gets a 32-bit integer at the current
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 4 in this buffer. |
long |
readLong()
Gets a 64-bit integer at the current
readerIndex
and increases the readerIndex by 8 in this buffer. |
long[] |
readLongArray()
Reads an array of primitive longs from this buf.
|
long[] |
readLongArray(int maxSize)
Reads an array of primitive longs from this buf.
|
long |
readLongLE()
Gets a 64-bit integer at the current
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 8 in this buffer. |
int |
readMedium()
Gets a 24-bit medium integer at the current
readerIndex
and increases the readerIndex by 3 in this buffer. |
int |
readMediumLE()
Gets a 24-bit medium integer at the current
readerIndex
in the Little Endian Byte Order and increases the
readerIndex by 3 in this buffer. |
byte[] |
readReadableBytes() |
io.netty.buffer.ByteBuf |
readRetainedSlice(int length)
Returns a new retained slice of this buffer's sub-region starting at the current
readerIndex and increases the readerIndex by the size
of the new slice (= length). |
short |
readShort()
Gets a 16-bit short integer at the current
readerIndex
and increases the readerIndex by 2 in this buffer. |
short |
readShortLE()
Gets a 16-bit short integer at the current
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 2 in this buffer. |
io.netty.buffer.ByteBuf |
readSlice(int length)
Returns a new slice of this buffer's sub-region starting at the current
readerIndex and increases the readerIndex by the size
of the new slice (= length). |
java.lang.String |
readString(int maxLength)
Reads a string from this buf.
|
short |
readUnsignedByte()
Gets an unsigned byte at the current
readerIndex and increases
the readerIndex by 1 in this buffer. |
long |
readUnsignedInt()
Gets an unsigned 32-bit integer at the current
readerIndex
and increases the readerIndex by 4 in this buffer. |
long |
readUnsignedIntLE()
Gets an unsigned 32-bit integer at the current
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 4 in this buffer. |
int |
readUnsignedMedium()
Gets an unsigned 24-bit medium integer at the current
readerIndex
and increases the readerIndex by 3 in this buffer. |
int |
readUnsignedMediumLE()
Gets an unsigned 24-bit medium integer at the current
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 3 in this buffer. |
int |
readUnsignedShort()
Gets an unsigned 16-bit short integer at the current
readerIndex
and increases the readerIndex by 2 in this buffer. |
int |
readUnsignedShortLE()
Gets an unsigned 16-bit short integer at the current
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 2 in this buffer. |
java.util.UUID |
readUuid()
Reads a UUID (universally unique identifier) from this buf.
|
int |
readVarInt()
Reads a single var int from this buf.
|
int |
refCnt()
Returns the reference count of this object.
|
boolean |
release()
Decreases the reference count by
1 and deallocates this object if the reference count reaches at
0. |
boolean |
release(int decrement)
Decreases the reference count by the specified
decrement and deallocates this object if the reference
count reaches at 0. |
io.netty.buffer.ByteBuf |
resetReaderIndex()
Repositions the current
readerIndex to the marked
readerIndex in this buffer. |
io.netty.buffer.ByteBuf |
resetWriterIndex()
Repositions the current
writerIndex to the marked
writerIndex in this buffer. |
io.netty.buffer.ByteBuf |
retain() |
io.netty.buffer.ByteBuf |
retain(int increment) |
io.netty.buffer.ByteBuf |
retainedDuplicate()
Returns a retained buffer which shares the whole region of this buffer.
|
io.netty.buffer.ByteBuf |
retainedSlice()
Returns a retained slice of this buffer's readable bytes.
|
io.netty.buffer.ByteBuf |
retainedSlice(int index,
int length)
Returns a retained slice of this buffer's sub-region.
|
io.netty.buffer.ByteBuf |
setBoolean(int index,
boolean value)
Sets the specified boolean at the specified absolute
index in this
buffer. |
io.netty.buffer.ByteBuf |
setByte(int index,
int value)
Sets the specified byte at the specified absolute
index in this
buffer. |
io.netty.buffer.ByteBuf |
setBytes(int index,
byte[] src)
Transfers the specified source array's data to this buffer starting at
the specified absolute
index. |
io.netty.buffer.ByteBuf |
setBytes(int index,
byte[] src,
int srcIndex,
int length)
Transfers the specified source array's data to this buffer starting at
the specified absolute
index. |
io.netty.buffer.ByteBuf |
setBytes(int index,
io.netty.buffer.ByteBuf src)
Transfers the specified source buffer's data to this buffer starting at
the specified absolute
index until the source buffer becomes
unreadable. |
io.netty.buffer.ByteBuf |
setBytes(int index,
java.nio.ByteBuffer src)
Transfers the specified source buffer's data to this buffer starting at
the specified absolute
index until the source buffer's position
reaches its limit. |
io.netty.buffer.ByteBuf |
setBytes(int index,
io.netty.buffer.ByteBuf src,
int length)
Transfers the specified source buffer's data to this buffer starting at
the specified absolute
index. |
io.netty.buffer.ByteBuf |
setBytes(int index,
io.netty.buffer.ByteBuf src,
int srcIndex,
int length)
Transfers the specified source buffer's data to this buffer starting at
the specified absolute
index. |
int |
setBytes(int index,
java.nio.channels.FileChannel in,
long position,
int length)
Transfers the content of the specified source channel starting at the given file position
to this buffer starting at the specified absolute
index. |
int |
setBytes(int index,
java.io.InputStream in,
int length)
Transfers the content of the specified source stream to this buffer
starting at the specified absolute
index. |
int |
setBytes(int index,
java.nio.channels.ScatteringByteChannel in,
int length)
Transfers the content of the specified source channel to this buffer
starting at the specified absolute
index. |
io.netty.buffer.ByteBuf |
setChar(int index,
int value)
Sets the specified 2-byte UTF-16 character at the specified absolute
index in this buffer. |
int |
setCharSequence(int index,
java.lang.CharSequence sequence,
java.nio.charset.Charset charset)
Writes the specified
CharSequence at the current writerIndex and increases
the writerIndex by the written bytes. |
io.netty.buffer.ByteBuf |
setDouble(int index,
double value)
Sets the specified 64-bit floating-point number at the specified
absolute
index in this buffer. |
io.netty.buffer.ByteBuf |
setFloat(int index,
float value)
Sets the specified 32-bit floating-point number at the specified
absolute
index in this buffer. |
io.netty.buffer.ByteBuf |
setIndex(int readerIndex,
int writerIndex)
Sets the
readerIndex and writerIndex of this buffer
in one shot. |
io.netty.buffer.ByteBuf |
setInt(int index,
int value)
Sets the specified 32-bit integer at the specified absolute
index in this buffer. |
io.netty.buffer.ByteBuf |
setIntLE(int index,
int value)
Sets the specified 32-bit integer at the specified absolute
index in this buffer with Little Endian byte order
. |
io.netty.buffer.ByteBuf |
setLong(int index,
long value)
Sets the specified 64-bit long integer at the specified absolute
index in this buffer. |
io.netty.buffer.ByteBuf |
setLongLE(int index,
long value)
Sets the specified 64-bit long integer at the specified absolute
index in this buffer in Little Endian Byte Order. |
io.netty.buffer.ByteBuf |
setMedium(int index,
int value)
Sets the specified 24-bit medium integer at the specified absolute
index in this buffer. |
io.netty.buffer.ByteBuf |
setMediumLE(int index,
int value)
Sets the specified 24-bit medium integer at the specified absolute
index in this buffer in the Little Endian Byte Order. |
io.netty.buffer.ByteBuf |
setShort(int index,
int value)
Sets the specified 16-bit short integer at the specified absolute
index in this buffer. |
io.netty.buffer.ByteBuf |
setShortLE(int index,
int value)
Sets the specified 16-bit short integer at the specified absolute
index in this buffer with the Little Endian Byte Order. |
io.netty.buffer.ByteBuf |
setZero(int index,
int length)
Fills this buffer with NUL (0x00) starting at the specified
absolute
index. |
io.netty.buffer.ByteBuf |
skipBytes(int length)
Increases the current
readerIndex by the specified
length in this buffer. |
io.netty.buffer.ByteBuf |
slice()
Returns a slice of this buffer's readable bytes.
|
io.netty.buffer.ByteBuf |
slice(int index,
int length)
Returns a slice of this buffer's sub-region.
|
java.lang.String |
toString()
Returns the string representation of this buffer.
|
java.lang.String |
toString(java.nio.charset.Charset charset)
Decodes this buffer's readable bytes into a string with the specified
character set name.
|
java.lang.String |
toString(int index,
int length,
java.nio.charset.Charset charset)
Decodes this buffer's sub-region into a string with the specified
character set.
|
io.netty.buffer.ByteBuf |
touch() |
io.netty.buffer.ByteBuf |
touch(java.lang.Object hint) |
io.netty.buffer.ByteBuf |
unwrap()
Return the underlying buffer instance if this buffer is a wrapper of another buffer.
|
int |
writableBytes()
Returns the number of writable bytes which is equal to
(this.capacity - this.writerIndex). |
io.netty.buffer.ByteBuf |
writeBoolean(boolean value)
Sets the specified boolean at the current
writerIndex
and increases the writerIndex by 1 in this buffer. |
io.netty.buffer.ByteBuf |
writeByte(int value)
Sets the specified byte at the current
writerIndex
and increases the writerIndex by 1 in this buffer. |
PacketByteBuf |
writeByteArray(byte[] array)
Writes an array of primitive bytes to this buf.
|
io.netty.buffer.ByteBuf |
writeBytes(byte[] src)
Transfers the specified source array's data to this buffer starting at
the current
writerIndex and increases the writerIndex
by the number of the transferred bytes (= src.length). |
io.netty.buffer.ByteBuf |
writeBytes(byte[] src,
int srcIndex,
int length)
Transfers the specified source array's data to this buffer starting at
the current
writerIndex and increases the writerIndex
by the number of the transferred bytes (= length). |
io.netty.buffer.ByteBuf |
writeBytes(io.netty.buffer.ByteBuf src)
Transfers the specified source buffer's data to this buffer starting at
the current
writerIndex until the source buffer becomes
unreadable, and increases the writerIndex by the number of
the transferred bytes. |
io.netty.buffer.ByteBuf |
writeBytes(java.nio.ByteBuffer src)
Transfers the specified source buffer's data to this buffer starting at
the current
writerIndex until the source buffer's position
reaches its limit, and increases the writerIndex by the
number of the transferred bytes. |
io.netty.buffer.ByteBuf |
writeBytes(io.netty.buffer.ByteBuf src,
int length)
Transfers the specified source buffer's data to this buffer starting at
the current
writerIndex and increases the writerIndex
by the number of the transferred bytes (= length). |
io.netty.buffer.ByteBuf |
writeBytes(io.netty.buffer.ByteBuf src,
int srcIndex,
int length)
Transfers the specified source buffer's data to this buffer starting at
the current
writerIndex and increases the writerIndex
by the number of the transferred bytes (= length). |
int |
writeBytes(java.nio.channels.FileChannel in,
long position,
int length)
Transfers the content of the specified channel starting at the given file position
to this buffer starting at the current
writerIndex and increases the
writerIndex by the number of the transferred bytes. |
int |
writeBytes(java.io.InputStream in,
int length)
Transfers the content of the specified stream to this buffer
starting at the current
writerIndex and increases the
writerIndex by the number of the transferred bytes. |
int |
writeBytes(java.nio.channels.ScatteringByteChannel in,
int length)
Transfers the content of the specified channel to this buffer
starting at the current
writerIndex and increases the
writerIndex by the number of the transferred bytes. |
io.netty.buffer.ByteBuf |
writeChar(int value)
Sets the specified 2-byte UTF-16 character at the current
writerIndex and increases the writerIndex by 2
in this buffer. |
int |
writeCharSequence(java.lang.CharSequence sequence,
java.nio.charset.Charset charset)
Writes the specified
CharSequence at the current writerIndex and increases
the writerIndex by the written bytes. |
io.netty.buffer.ByteBuf |
writeDouble(double value)
Sets the specified 64-bit floating point number at the current
writerIndex and increases the writerIndex by 8
in this buffer. |
io.netty.buffer.ByteBuf |
writeFloat(float value)
Sets the specified 32-bit floating point number at the current
writerIndex and increases the writerIndex by 4
in this buffer. |
io.netty.buffer.ByteBuf |
writeInt(int value)
Sets the specified 32-bit integer at the current
writerIndex
and increases the writerIndex by 4 in this buffer. |
PacketByteBuf |
writeIntArray(int[] array)
Writes an array of primitive ints to this buf.
|
io.netty.buffer.ByteBuf |
writeIntLE(int value)
Sets the specified 32-bit integer at the current
writerIndex
in the Little Endian Byte Order and increases the writerIndex
by 4 in this buffer. |
io.netty.buffer.ByteBuf |
writeLong(long value)
Sets the specified 64-bit long integer at the current
writerIndex and increases the writerIndex by 8
in this buffer. |
PacketByteBuf |
writeLongArray(long[] array)
Writes an array of primitive longs to this buf.
|
io.netty.buffer.ByteBuf |
writeLongLE(long value)
Sets the specified 64-bit long integer at the current
writerIndex in the Little Endian Byte Order and
increases the writerIndex by 8
in this buffer. |
io.netty.buffer.ByteBuf |
writeMedium(int value)
Sets the specified 24-bit medium integer at the current
writerIndex and increases the writerIndex by 3
in this buffer. |
io.netty.buffer.ByteBuf |
writeMediumLE(int value)
Sets the specified 24-bit medium integer at the current
writerIndex in the Little Endian Byte Order and
increases the writerIndex by 3 in this
buffer. |
int |
writerIndex()
Returns the
writerIndex of this buffer. |
io.netty.buffer.ByteBuf |
writerIndex(int writerIndex)
Sets the
writerIndex of this buffer. |
io.netty.buffer.ByteBuf |
writeShort(int value)
Sets the specified 16-bit short integer at the current
writerIndex and increases the writerIndex by 2
in this buffer. |
io.netty.buffer.ByteBuf |
writeShortLE(int value)
Sets the specified 16-bit short integer in the Little Endian Byte
Order at the current
writerIndex and increases the
writerIndex by 2 in this buffer. |
PacketByteBuf |
writeString(java.lang.String string)
Writes a string to this buf.
|
PacketByteBuf |
writeUuid(java.util.UUID uuid)
Writes a UUID (universally unique identifier) to this buf.
|
PacketByteBuf |
writeVarInt(int value)
Writes a single var int to this buf.
|
io.netty.buffer.ByteBuf |
writeZero(int length)
Fills this buffer with NUL (0x00) starting at the current
writerIndex and increases the writerIndex by the
specified length. |
public PacketByteBuf()
public PacketByteBuf(io.netty.buffer.ByteBuf byteBuf)
public static int getVarIntLength(int value)
value - the value to encodevalue usespublic int readVarInt()
writeVarInt(int)public PacketByteBuf writeVarInt(int value)
Compared to regular ints, var ints may use less bytes (ranging from 1 to 5, where regular ints use 4) when representing smaller positive numbers.
value - the value to writereadVarInt(),
getVarIntLength(int)public java.lang.String readString(int maxLength)
maxLength.maxLength - the maximum length of the string readio.netty.handler.codec.DecoderException - if the string read
is longer than maxLengthwriteString(String)public PacketByteBuf writeString(java.lang.String string)
string - the string to writereadString(int)public byte[] readByteArray()
readByteArray(int),
writeByteArray(byte[])public byte[] readByteArray(int maxSize)
maxSize.maxSize - the max length of the read arrayio.netty.handler.codec.DecoderException - if the read array has a
length over maxSizereadByteArray(),
writeByteArray(byte[])public PacketByteBuf writeByteArray(byte[] array)
array - the array to writereadByteArray()public PacketByteBuf writeIntArray(int[] array)
array - the array to writereadIntArray(int),
writeIntArray(int[])public int[] readIntArray()
readIntArray(int),
writeIntArray(int[])public int[] readIntArray(int maxSize)
maxSize.maxSize - the max length of the read arrayio.netty.handler.codec.DecoderException - if the read array has a
length over maxSizereadIntArray(),
writeIntArray(int[])public PacketByteBuf writeLongArray(long[] array)
array - the array to writereadLongArray()public long[] readLongArray()
Only when toArray is not null and toArray.length equals to the length var int read will the toArray be reused and returned; otherwise, a new array
of proper size is created.
writeLongArray(long[]),
readLongArray()public long[] readLongArray(int maxSize)
maxSize.
Only when toArray is not null and toArray.length equals to the length var int read will the toArray be reused and returned; otherwise, a new array
of proper size is created.
maxSize - the max length of the read arrayio.netty.handler.codec.DecoderException - if the read array has a
length over maxSizewriteLongArray(long[]),
readLongArray()public PacketByteBuf writeUuid(java.util.UUID uuid)
uuid - the UUID to writereadUuid()public java.util.UUID readUuid()
writeUuid(UUID)public int capacity()
capacity in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf capacity(int newCapacity)
newCapacity is less than the current
capacity, the content of this buffer is truncated. If the newCapacity is greater
than the current capacity, the buffer is appended with unspecified data whose length is
(newCapacity - currentCapacity).capacity in class io.netty.buffer.ByteBufjava.lang.IllegalArgumentException - if the newCapacity is greater than maxCapacity()public int maxCapacity()
capacity().maxCapacity in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBufAllocator alloc()
ByteBufAllocator which created this buffer.alloc in class io.netty.buffer.ByteBuf@Deprecated public java.nio.ByteOrder order()
getShortLE, getIntLE
instead of creating a buffer with swapped endianness.order in class io.netty.buffer.ByteBuf@Deprecated public io.netty.buffer.ByteBuf order(java.nio.ByteOrder endianness)
getShortLE, getIntLE
instead of creating a buffer with swapped endianness.endianness which shares the whole region,
indexes, and marks of this buffer. Modifying the content, the indexes, or the marks of the
returned buffer or this buffer affects each other's content, indexes, and marks. 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 in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf unwrap()
unwrap in class io.netty.buffer.ByteBufnull if this buffer is not a wrapperpublic boolean isDirect()
true if and only if this buffer is backed by an
NIO direct buffer.isDirect in class io.netty.buffer.ByteBufpublic boolean isReadOnly()
true if and only if this buffer is read-only.isReadOnly in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf asReadOnly()
asReadOnly in class io.netty.buffer.ByteBufpublic int readerIndex()
readerIndex of this buffer.readerIndex in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf readerIndex(int readerIndex)
readerIndex of this buffer.readerIndex in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified readerIndex is
less than 0 or
greater than this.writerIndexpublic int writerIndex()
writerIndex of this buffer.writerIndex in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf writerIndex(int writerIndex)
writerIndex of this buffer.writerIndex in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified writerIndex is
less than this.readerIndex or
greater than this.capacitypublic io.netty.buffer.ByteBuf setIndex(int readerIndex,
int writerIndex)
readerIndex and writerIndex of this buffer
in one shot. This method is useful when you have to worry about the
invocation order of readerIndex(int) and writerIndex(int)
methods. For example, the following code will fail:
// Create a buffer whose readerIndex, writerIndex and capacity are // 0, 0 and 8 respectively.ByteBufbuf =Unpooled.buffer(8); // IndexOutOfBoundsException is thrown because the specified // readerIndex (2) cannot be greater than the current writerIndex (0). buf.readerIndex(2); buf.writerIndex(4);
The following code will also fail:
// Create a buffer whose readerIndex, writerIndex and capacity are // 0, 8 and 8 respectively.ByteBufbuf =Unpooled.wrappedBuffer(new byte[8]); // readerIndex becomes 8. buf.readLong(); // IndexOutOfBoundsException is thrown because the specified // writerIndex (4) cannot be less than the current readerIndex (8). buf.writerIndex(4); buf.readerIndex(2);
By contrast, this method guarantees that it never
throws an IndexOutOfBoundsException as long as the specified
indexes meet basic constraints, regardless what the current index
values of the buffer are:
// No matter what the current state of the buffer is, the following // call always succeeds as long as the capacity of the buffer is not // less than 4. buf.setIndex(2, 4);
setIndex in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified readerIndex is less than 0,
if the specified writerIndex is less than the specified
readerIndex or if the specified writerIndex is
greater than this.capacitypublic int readableBytes()
(this.writerIndex - this.readerIndex).readableBytes in class io.netty.buffer.ByteBufpublic int writableBytes()
(this.capacity - this.writerIndex).writableBytes in class io.netty.buffer.ByteBufpublic int maxWritableBytes()
(this.maxCapacity - this.writerIndex).maxWritableBytes in class io.netty.buffer.ByteBufpublic boolean isReadable()
true
if and only if (this.writerIndex - this.readerIndex) is greater
than 0.isReadable in class io.netty.buffer.ByteBufpublic boolean isReadable(int size)
true if and only if this buffer contains equal to or more than the specified number of elements.isReadable in class io.netty.buffer.ByteBufpublic boolean isWritable()
true
if and only if (this.capacity - this.writerIndex) is greater
than 0.isWritable in class io.netty.buffer.ByteBufpublic boolean isWritable(int size)
true if and only if this buffer has enough room to allow writing the specified number of
elements.isWritable in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf clear()
readerIndex and writerIndex of this buffer to
0.
This method is identical to setIndex(0, 0).
Please note that the behavior of this method is different
from that of NIO buffer, which sets the limit to
the capacity of the buffer.
clear in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf markReaderIndex()
readerIndex in this buffer. You can
reposition the current readerIndex to the marked
readerIndex by calling resetReaderIndex().
The initial value of the marked readerIndex is 0.markReaderIndex in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf resetReaderIndex()
readerIndex to the marked
readerIndex in this buffer.resetReaderIndex in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the current writerIndex is less than the marked
readerIndexpublic io.netty.buffer.ByteBuf markWriterIndex()
writerIndex in this buffer. You can
reposition the current writerIndex to the marked
writerIndex by calling resetWriterIndex().
The initial value of the marked writerIndex is 0.markWriterIndex in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf resetWriterIndex()
writerIndex to the marked
writerIndex in this buffer.resetWriterIndex in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the current readerIndex is greater than the marked
writerIndexpublic io.netty.buffer.ByteBuf discardReadBytes()
readerIndex.
It moves the bytes between readerIndex and writerIndex
to the 0th index, and sets readerIndex and writerIndex
to 0 and oldWriterIndex - oldReaderIndex respectively.
Please refer to the class documentation for more detailed explanation.
discardReadBytes in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf discardSomeReadBytes()
ByteBuf.discardReadBytes() except that this method might discard
some, all, or none of read bytes depending on its internal implementation to reduce
overall memory bandwidth consumption at the cost of potentially additional memory
consumption.discardSomeReadBytes in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf ensureWritable(int minWritableBytes)
capacity() to make sure the number of
writable bytes is equal to or greater than the
specified value. If there are enough writable bytes in this buffer, this method
returns with no side effect.ensureWritable in class io.netty.buffer.ByteBufminWritableBytes - the expected minimum number of writable bytesjava.lang.IndexOutOfBoundsException - if writerIndex() + minWritableBytes > maxCapacity().capacity(int)public int ensureWritable(int minWritableBytes,
boolean force)
capacity() to make sure the number of
writable bytes is equal to or greater than the
specified value. Unlike ensureWritable(int), this method returns a status code.ensureWritable in class io.netty.buffer.ByteBufminWritableBytes - the expected minimum number of writable bytesforce - When writerIndex() + minWritableBytes > maxCapacity():
true - the capacity of the buffer is expanded to maxCapacity()false - the capacity of the buffer is unchanged0 if the buffer has enough writable bytes, and its capacity is unchanged.
1 if the buffer does not have enough bytes, and its capacity is unchanged.
2 if the buffer has enough writable bytes, and its capacity has been increased.
3 if the buffer does not have enough bytes, but its capacity has been
increased to its maximum.public boolean getBoolean(int index)
readerIndex or writerIndex
of this buffer.getBoolean in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 1 is greater than this.capacitypublic byte getByte(int index)
index in this buffer.
This method does not modify readerIndex or writerIndex of
this buffer.getByte in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 1 is greater than this.capacitypublic short getUnsignedByte(int index)
index in this
buffer. This method does not modify readerIndex or
writerIndex of this buffer.getUnsignedByte in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 1 is greater than this.capacitypublic short getShort(int index)
index in
this buffer. This method does not modify readerIndex or
writerIndex of this buffer.getShort in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 2 is greater than this.capacitypublic short getShortLE(int index)
index in
this buffer in Little Endian Byte Order. This method does not modify
readerIndex or writerIndex of this buffer.getShortLE in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 2 is greater than this.capacitypublic int getUnsignedShort(int index)
index in this buffer. This method does not modify
readerIndex or writerIndex of this buffer.getUnsignedShort in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 2 is greater than this.capacitypublic int getUnsignedShortLE(int index)
index in this buffer in Little Endian Byte Order.
This method does not modify readerIndex or
writerIndex of this buffer.getUnsignedShortLE in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 2 is greater than this.capacitypublic int getMedium(int index)
index in
this buffer. This method does not modify readerIndex or
writerIndex of this buffer.getMedium in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 3 is greater than this.capacitypublic int getMediumLE(int index)
index in
this buffer in the Little Endian Byte Order. This method does not
modify readerIndex or writerIndex of this buffer.getMediumLE in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 3 is greater than this.capacitypublic int getUnsignedMedium(int index)
index in this buffer. This method does not modify
readerIndex or writerIndex of this buffer.getUnsignedMedium in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 3 is greater than this.capacitypublic int getUnsignedMediumLE(int index)
index in this buffer in Little Endian Byte Order.
This method does not modify readerIndex or
writerIndex of this buffer.getUnsignedMediumLE in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 3 is greater than this.capacitypublic int getInt(int index)
index in
this buffer. This method does not modify readerIndex or
writerIndex of this buffer.getInt in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 4 is greater than this.capacitypublic int getIntLE(int index)
index in
this buffer with Little Endian Byte Order. This method does not
modify readerIndex or writerIndex of this buffer.getIntLE in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 4 is greater than this.capacitypublic long getUnsignedInt(int index)
index
in this buffer. This method does not modify readerIndex or
writerIndex of this buffer.getUnsignedInt in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 4 is greater than this.capacitypublic long getUnsignedIntLE(int index)
index
in this buffer in Little Endian Byte Order. This method does not
modify readerIndex or writerIndex of this buffer.getUnsignedIntLE in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 4 is greater than this.capacitypublic long getLong(int index)
index in
this buffer. This method does not modify readerIndex or
writerIndex of this buffer.getLong in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 8 is greater than this.capacitypublic long getLongLE(int index)
index in
this buffer in Little Endian Byte Order. This method does not
modify readerIndex or writerIndex of this buffer.getLongLE in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 8 is greater than this.capacitypublic char getChar(int index)
index in this buffer. This method does not modify
readerIndex or writerIndex of this buffer.getChar in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 2 is greater than this.capacitypublic float getFloat(int index)
index in this buffer. This method does not modify
readerIndex or writerIndex of this buffer.getFloat in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 4 is greater than this.capacitypublic double getDouble(int index)
index in this buffer. This method does not modify
readerIndex or writerIndex of this buffer.getDouble in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 8 is greater than this.capacitypublic io.netty.buffer.ByteBuf getBytes(int index,
io.netty.buffer.ByteBuf dst)
index until the destination becomes
non-writable. This method is basically same with
getBytes(int, ByteBuf, int, int), except that this
method increases the writerIndex of the destination by the
number of the transferred bytes while
getBytes(int, ByteBuf, int, int) does not.
This method does not modify readerIndex or writerIndex of
the source buffer (i.e. this).getBytes in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
if index + dst.writableBytes is greater than
this.capacitypublic io.netty.buffer.ByteBuf getBytes(int index,
io.netty.buffer.ByteBuf dst,
int length)
index. This method is basically same
with getBytes(int, ByteBuf, int, int), except that this
method increases the writerIndex of the destination by the
number of the transferred bytes while
getBytes(int, ByteBuf, int, int) does not.
This method does not modify readerIndex or writerIndex of
the source buffer (i.e. this).getBytes in class io.netty.buffer.ByteBuflength - the number of bytes to transferjava.lang.IndexOutOfBoundsException - if the specified index is less than 0,
if index + length is greater than
this.capacity, or
if length is greater than dst.writableBytespublic io.netty.buffer.ByteBuf getBytes(int index,
io.netty.buffer.ByteBuf dst,
int dstIndex,
int length)
index.
This method does not modify readerIndex or writerIndex
of both the source (i.e. this) and the destination.getBytes in class io.netty.buffer.ByteBufdstIndex - the first index of the destinationlength - the number of bytes to transferjava.lang.IndexOutOfBoundsException - if the specified index is less than 0,
if the specified dstIndex is less than 0,
if index + length is greater than
this.capacity, or
if dstIndex + length is greater than
dst.capacitypublic io.netty.buffer.ByteBuf getBytes(int index,
byte[] dst)
index.
This method does not modify readerIndex or writerIndex of
this buffergetBytes in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
if index + dst.length is greater than
this.capacitypublic io.netty.buffer.ByteBuf getBytes(int index,
byte[] dst,
int dstIndex,
int length)
index.
This method does not modify readerIndex or writerIndex
of this buffer.getBytes in class io.netty.buffer.ByteBufdstIndex - the first index of the destinationlength - the number of bytes to transferjava.lang.IndexOutOfBoundsException - if the specified index is less than 0,
if the specified dstIndex is less than 0,
if index + length is greater than
this.capacity, or
if dstIndex + length is greater than
dst.lengthpublic io.netty.buffer.ByteBuf getBytes(int index,
java.nio.ByteBuffer dst)
index until the destination's position
reaches its limit.
This method does not modify readerIndex or writerIndex of
this buffer while the destination's position will be increased.getBytes in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
if index + dst.remaining() is greater than
this.capacitypublic io.netty.buffer.ByteBuf getBytes(int index,
java.io.OutputStream out,
int length)
throws java.io.IOException
index.
This method does not modify readerIndex or writerIndex of
this buffer.getBytes in class io.netty.buffer.ByteBuflength - the number of bytes to transferjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
if index + length is greater than
this.capacityjava.io.IOException - if the specified stream threw an exception during I/Opublic int getBytes(int index,
java.nio.channels.GatheringByteChannel out,
int length)
throws java.io.IOException
index.
This method does not modify readerIndex or writerIndex of
this buffer.getBytes in class io.netty.buffer.ByteBuflength - the maximum number of bytes to transferjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
if index + length is greater than
this.capacityjava.io.IOException - if the specified channel threw an exception during I/Opublic int getBytes(int index,
java.nio.channels.FileChannel out,
long position,
int length)
throws java.io.IOException
index
to the specified channel starting at the given file position.
This method does not modify readerIndex or writerIndex of
this buffer. This method does not modify the channel's position.getBytes in class io.netty.buffer.ByteBufposition - the file position at which the transfer is to beginlength - the maximum number of bytes to transferjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
if index + length is greater than
this.capacityjava.io.IOException - if the specified channel threw an exception during I/Opublic java.lang.CharSequence getCharSequence(int index,
int length,
java.nio.charset.Charset charset)
CharSequence with the given length at the given index.getCharSequence in class io.netty.buffer.ByteBuflength - the length to readcharset - that should be usedjava.lang.IndexOutOfBoundsException - if length is greater than this.readableBytespublic io.netty.buffer.ByteBuf setBoolean(int index,
boolean value)
index in this
buffer.
This method does not modify readerIndex or writerIndex of
this buffer.setBoolean in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 1 is greater than this.capacitypublic io.netty.buffer.ByteBuf setByte(int index,
int value)
index in this
buffer. The 24 high-order bits of the specified value are ignored.
This method does not modify readerIndex or writerIndex of
this buffer.setByte in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 1 is greater than this.capacitypublic io.netty.buffer.ByteBuf setShort(int index,
int value)
index in this buffer. The 16 high-order bits of the specified
value are ignored.
This method does not modify readerIndex or writerIndex of
this buffer.setShort in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 2 is greater than this.capacitypublic io.netty.buffer.ByteBuf setShortLE(int index,
int value)
index in this buffer with the Little Endian Byte Order.
The 16 high-order bits of the specified value are ignored.
This method does not modify readerIndex or writerIndex of
this buffer.setShortLE in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 2 is greater than this.capacitypublic io.netty.buffer.ByteBuf setMedium(int index,
int value)
index in this buffer. Please note that the most significant
byte is ignored in the specified value.
This method does not modify readerIndex or writerIndex of
this buffer.setMedium in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 3 is greater than this.capacitypublic io.netty.buffer.ByteBuf setMediumLE(int index,
int value)
index in this buffer in the Little Endian Byte Order.
Please note that the most significant byte is ignored in the
specified value.
This method does not modify readerIndex or writerIndex of
this buffer.setMediumLE in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 3 is greater than this.capacitypublic io.netty.buffer.ByteBuf setInt(int index,
int value)
index in this buffer.
This method does not modify readerIndex or writerIndex of
this buffer.setInt in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 4 is greater than this.capacitypublic io.netty.buffer.ByteBuf setIntLE(int index,
int value)
index in this buffer with Little Endian byte order
.
This method does not modify readerIndex or writerIndex of
this buffer.setIntLE in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 4 is greater than this.capacitypublic io.netty.buffer.ByteBuf setLong(int index,
long value)
index in this buffer.
This method does not modify readerIndex or writerIndex of
this buffer.setLong in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 8 is greater than this.capacitypublic io.netty.buffer.ByteBuf setLongLE(int index,
long value)
index in this buffer in Little Endian Byte Order.
This method does not modify readerIndex or writerIndex of
this buffer.setLongLE in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 8 is greater than this.capacitypublic io.netty.buffer.ByteBuf setChar(int index,
int value)
index in this buffer.
The 16 high-order bits of the specified value are ignored.
This method does not modify readerIndex or writerIndex of
this buffer.setChar in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 2 is greater than this.capacitypublic io.netty.buffer.ByteBuf setFloat(int index,
float value)
index in this buffer.
This method does not modify readerIndex or writerIndex of
this buffer.setFloat in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 4 is greater than this.capacitypublic io.netty.buffer.ByteBuf setDouble(int index,
double value)
index in this buffer.
This method does not modify readerIndex or writerIndex of
this buffer.setDouble in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
index + 8 is greater than this.capacitypublic io.netty.buffer.ByteBuf setBytes(int index,
io.netty.buffer.ByteBuf src)
index until the source buffer becomes
unreadable. This method is basically same with
setBytes(int, ByteBuf, int, int), except that this
method increases the readerIndex of the source buffer by
the number of the transferred bytes while
setBytes(int, ByteBuf, int, int) does not.
This method does not modify readerIndex or writerIndex of
this buffer (i.e. this).setBytes in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
if index + src.readableBytes is greater than
this.capacitypublic io.netty.buffer.ByteBuf setBytes(int index,
io.netty.buffer.ByteBuf src,
int length)
index. This method is basically same
with setBytes(int, ByteBuf, int, int), except that this
method increases the readerIndex of the source buffer by
the number of the transferred bytes while
setBytes(int, ByteBuf, int, int) does not.
This method does not modify readerIndex or writerIndex of
this buffer (i.e. this).setBytes in class io.netty.buffer.ByteBuflength - the number of bytes to transferjava.lang.IndexOutOfBoundsException - if the specified index is less than 0,
if index + length is greater than
this.capacity, or
if length is greater than src.readableBytespublic io.netty.buffer.ByteBuf setBytes(int index,
io.netty.buffer.ByteBuf src,
int srcIndex,
int length)
index.
This method does not modify readerIndex or writerIndex
of both the source (i.e. this) and the destination.setBytes in class io.netty.buffer.ByteBufsrcIndex - the first index of the sourcelength - the number of bytes to transferjava.lang.IndexOutOfBoundsException - if the specified index is less than 0,
if the specified srcIndex is less than 0,
if index + length is greater than
this.capacity, or
if srcIndex + length is greater than
src.capacitypublic io.netty.buffer.ByteBuf setBytes(int index,
byte[] src)
index.
This method does not modify readerIndex or writerIndex of
this buffer.setBytes in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
if index + src.length is greater than
this.capacitypublic io.netty.buffer.ByteBuf setBytes(int index,
byte[] src,
int srcIndex,
int length)
index.
This method does not modify readerIndex or writerIndex of
this buffer.setBytes in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0,
if the specified srcIndex is less than 0,
if index + length is greater than
this.capacity, or
if srcIndex + length is greater than src.lengthpublic io.netty.buffer.ByteBuf setBytes(int index,
java.nio.ByteBuffer src)
index until the source buffer's position
reaches its limit.
This method does not modify readerIndex or writerIndex of
this buffer.setBytes in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
if index + src.remaining() is greater than
this.capacitypublic int setBytes(int index,
java.io.InputStream in,
int length)
throws java.io.IOException
index.
This method does not modify readerIndex or writerIndex of
this buffer.setBytes in class io.netty.buffer.ByteBuflength - the number of bytes to transfer-1 if the specified channel is closed.java.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
if index + length is greater than this.capacityjava.io.IOException - if the specified stream threw an exception during I/Opublic int setBytes(int index,
java.nio.channels.ScatteringByteChannel in,
int length)
throws java.io.IOException
index.
This method does not modify readerIndex or writerIndex of
this buffer.setBytes in class io.netty.buffer.ByteBuflength - the maximum number of bytes to transfer-1 if the specified channel is closed.java.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
if index + length is greater than this.capacityjava.io.IOException - if the specified channel threw an exception during I/Opublic int setBytes(int index,
java.nio.channels.FileChannel in,
long position,
int length)
throws java.io.IOException
index.
This method does not modify readerIndex or writerIndex of
this buffer. This method does not modify the channel's position.setBytes in class io.netty.buffer.ByteBufposition - the file position at which the transfer is to beginlength - the maximum number of bytes to transfer-1 if the specified channel is closed.java.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
if index + length is greater than this.capacityjava.io.IOException - if the specified channel threw an exception during I/Opublic io.netty.buffer.ByteBuf setZero(int index,
int length)
index.
This method does not modify readerIndex or writerIndex of
this buffer.setZero in class io.netty.buffer.ByteBuflength - the number of NULs to write to the bufferjava.lang.IndexOutOfBoundsException - if the specified index is less than 0 or
if index + length is greater than this.capacitypublic int setCharSequence(int index,
java.lang.CharSequence sequence,
java.nio.charset.Charset charset)
CharSequence at the current writerIndex and increases
the writerIndex by the written bytes.setCharSequence in class io.netty.buffer.ByteBufindex - on which the sequence should be writtensequence - to writecharset - that should be used.java.lang.IndexOutOfBoundsException - if this.writableBytes is not large enough to write the whole sequencepublic boolean readBoolean()
readerIndex and increases
the readerIndex by 1 in this buffer.readBoolean in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 1public byte readByte()
readerIndex and increases
the readerIndex by 1 in this buffer.readByte in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 1public short readUnsignedByte()
readerIndex and increases
the readerIndex by 1 in this buffer.readUnsignedByte in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 1public short readShort()
readerIndex
and increases the readerIndex by 2 in this buffer.readShort in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 2public short readShortLE()
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 2 in this buffer.readShortLE in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 2public int readUnsignedShort()
readerIndex
and increases the readerIndex by 2 in this buffer.readUnsignedShort in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 2public int readUnsignedShortLE()
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 2 in this buffer.readUnsignedShortLE in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 2public int readMedium()
readerIndex
and increases the readerIndex by 3 in this buffer.readMedium in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 3public int readMediumLE()
readerIndex
in the Little Endian Byte Order and increases the
readerIndex by 3 in this buffer.readMediumLE in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 3public int readUnsignedMedium()
readerIndex
and increases the readerIndex by 3 in this buffer.readUnsignedMedium in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 3public int readUnsignedMediumLE()
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 3 in this buffer.readUnsignedMediumLE in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 3public int readInt()
readerIndex
and increases the readerIndex by 4 in this buffer.readInt in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 4public int readIntLE()
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 4 in this buffer.readIntLE in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 4public long readUnsignedInt()
readerIndex
and increases the readerIndex by 4 in this buffer.readUnsignedInt in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 4public long readUnsignedIntLE()
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 4 in this buffer.readUnsignedIntLE in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 4public long readLong()
readerIndex
and increases the readerIndex by 8 in this buffer.readLong in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 8public long readLongLE()
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 8 in this buffer.readLongLE in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 8public char readChar()
readerIndex
and increases the readerIndex by 2 in this buffer.readChar in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 2public float readFloat()
readerIndex
and increases the readerIndex by 4 in this buffer.readFloat in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 4public double readDouble()
readerIndex
and increases the readerIndex by 8 in this buffer.readDouble in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if this.readableBytes is less than 8public io.netty.buffer.ByteBuf readBytes(int length)
readerIndex and increases the readerIndex
by the number of the transferred bytes (= length).
The returned buffer's readerIndex and writerIndex are
0 and length respectively.readBytes in class io.netty.buffer.ByteBuflength - the number of bytes to transferjava.lang.IndexOutOfBoundsException - if length is greater than this.readableBytespublic io.netty.buffer.ByteBuf readSlice(int length)
readerIndex and increases the readerIndex by the size
of the new slice (= length).
Also be aware that this method will NOT call retain() and so the
reference count will NOT be increased.
readSlice in class io.netty.buffer.ByteBuflength - the size of the new slicejava.lang.IndexOutOfBoundsException - if length is greater than this.readableBytespublic io.netty.buffer.ByteBuf readRetainedSlice(int length)
readerIndex and increases the readerIndex by the size
of the new slice (= length).
Note that this method returns a retained buffer unlike readSlice(int).
This method behaves similarly to readSlice(...).retain() except that this method may return
a buffer implementation that produces less garbage.
readRetainedSlice in class io.netty.buffer.ByteBuflength - the size of the new slicejava.lang.IndexOutOfBoundsException - if length is greater than this.readableBytespublic io.netty.buffer.ByteBuf readBytes(io.netty.buffer.ByteBuf dst)
readerIndex until the destination becomes
non-writable, and increases the readerIndex by the number of the
transferred bytes. This method is basically same with
readBytes(ByteBuf, int, int), except that this method
increases the writerIndex of the destination by the number of
the transferred bytes while readBytes(ByteBuf, int, int)
does not.readBytes in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if dst.writableBytes is greater than
this.readableBytespublic io.netty.buffer.ByteBuf readBytes(io.netty.buffer.ByteBuf dst,
int length)
readerIndex and increases the readerIndex
by the number of the transferred bytes (= length). This method
is basically same with readBytes(ByteBuf, int, int),
except that this method increases the writerIndex of the
destination by the number of the transferred bytes (= length)
while readBytes(ByteBuf, int, int) does not.readBytes in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if length is greater than this.readableBytes or
if length is greater than dst.writableBytespublic io.netty.buffer.ByteBuf readBytes(io.netty.buffer.ByteBuf dst,
int dstIndex,
int length)
readerIndex and increases the readerIndex
by the number of the transferred bytes (= length).readBytes in class io.netty.buffer.ByteBufdstIndex - the first index of the destinationlength - the number of bytes to transferjava.lang.IndexOutOfBoundsException - if the specified dstIndex is less than 0,
if length is greater than this.readableBytes, or
if dstIndex + length is greater than
dst.capacitypublic io.netty.buffer.ByteBuf readBytes(byte[] dst)
readerIndex and increases the readerIndex
by the number of the transferred bytes (= dst.length).readBytes in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if dst.length is greater than this.readableBytespublic io.netty.buffer.ByteBuf readBytes(byte[] dst,
int dstIndex,
int length)
readerIndex and increases the readerIndex
by the number of the transferred bytes (= length).readBytes in class io.netty.buffer.ByteBufdstIndex - the first index of the destinationlength - the number of bytes to transferjava.lang.IndexOutOfBoundsException - if the specified dstIndex is less than 0,
if length is greater than this.readableBytes, or
if dstIndex + length is greater than dst.lengthpublic io.netty.buffer.ByteBuf readBytes(java.nio.ByteBuffer dst)
readerIndex until the destination's position
reaches its limit, and increases the readerIndex by the
number of the transferred bytes.readBytes in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if dst.remaining() is greater than
this.readableBytespublic io.netty.buffer.ByteBuf readBytes(java.io.OutputStream out,
int length)
throws java.io.IOException
readerIndex.readBytes in class io.netty.buffer.ByteBuflength - the number of bytes to transferjava.lang.IndexOutOfBoundsException - if length is greater than this.readableBytesjava.io.IOException - if the specified stream threw an exception during I/Opublic int readBytes(java.nio.channels.GatheringByteChannel out,
int length)
throws java.io.IOException
readerIndex.readBytes in class io.netty.buffer.ByteBuflength - the maximum number of bytes to transferjava.lang.IndexOutOfBoundsException - if length is greater than this.readableBytesjava.io.IOException - if the specified channel threw an exception during I/Opublic java.lang.CharSequence readCharSequence(int length,
java.nio.charset.Charset charset)
CharSequence with the given length at the current readerIndex
and increases the readerIndex by the given length.readCharSequence in class io.netty.buffer.ByteBuflength - the length to readcharset - that should be usedjava.lang.IndexOutOfBoundsException - if length is greater than this.readableBytespublic int readBytes(java.nio.channels.FileChannel out,
long position,
int length)
throws java.io.IOException
readerIndex
to the specified channel starting at the given file position.
This method does not modify the channel's position.readBytes in class io.netty.buffer.ByteBufposition - the file position at which the transfer is to beginlength - the maximum number of bytes to transferjava.lang.IndexOutOfBoundsException - if length is greater than this.readableBytesjava.io.IOException - if the specified channel threw an exception during I/Opublic io.netty.buffer.ByteBuf skipBytes(int length)
readerIndex by the specified
length in this buffer.skipBytes in class io.netty.buffer.ByteBufjava.lang.IndexOutOfBoundsException - if length is greater than this.readableBytespublic io.netty.buffer.ByteBuf writeBoolean(boolean value)
writerIndex
and increases the writerIndex by 1 in this buffer.
If this.writableBytes is less than 1, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeBoolean in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf writeByte(int value)
writerIndex
and increases the writerIndex by 1 in this buffer.
The 24 high-order bits of the specified value are ignored.
If this.writableBytes is less than 1, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeByte in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf writeShort(int value)
writerIndex and increases the writerIndex by 2
in this buffer. The 16 high-order bits of the specified value are ignored.
If this.writableBytes is less than 2, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeShort in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf writeShortLE(int value)
writerIndex and increases the
writerIndex by 2 in this buffer.
The 16 high-order bits of the specified value are ignored.
If this.writableBytes is less than 2, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeShortLE in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf writeMedium(int value)
writerIndex and increases the writerIndex by 3
in this buffer.
If this.writableBytes is less than 3, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeMedium in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf writeMediumLE(int value)
writerIndex in the Little Endian Byte Order and
increases the writerIndex by 3 in this
buffer.
If this.writableBytes is less than 3, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeMediumLE in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf writeInt(int value)
writerIndex
and increases the writerIndex by 4 in this buffer.
If this.writableBytes is less than 4, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeInt in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf writeIntLE(int value)
writerIndex
in the Little Endian Byte Order and increases the writerIndex
by 4 in this buffer.
If this.writableBytes is less than 4, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeIntLE in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf writeLong(long value)
writerIndex and increases the writerIndex by 8
in this buffer.
If this.writableBytes is less than 8, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeLong in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf writeLongLE(long value)
writerIndex in the Little Endian Byte Order and
increases the writerIndex by 8
in this buffer.
If this.writableBytes is less than 8, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeLongLE in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf writeChar(int value)
writerIndex and increases the writerIndex by 2
in this buffer. The 16 high-order bits of the specified value are ignored.
If this.writableBytes is less than 2, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeChar in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf writeFloat(float value)
writerIndex and increases the writerIndex by 4
in this buffer.
If this.writableBytes is less than 4, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeFloat in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf writeDouble(double value)
writerIndex and increases the writerIndex by 8
in this buffer.
If this.writableBytes is less than 8, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeDouble in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf writeBytes(io.netty.buffer.ByteBuf src)
writerIndex until the source buffer becomes
unreadable, and increases the writerIndex by the number of
the transferred bytes. This method is basically same with
writeBytes(ByteBuf, int, int), except that this method
increases the readerIndex of the source buffer by the number of
the transferred bytes while writeBytes(ByteBuf, int, int)
does not.
If this.writableBytes is less than src.readableBytes,
ensureWritable(int) will be called in an attempt to expand
capacity to accommodate.writeBytes in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf writeBytes(io.netty.buffer.ByteBuf src,
int length)
writerIndex and increases the writerIndex
by the number of the transferred bytes (= length). This method
is basically same with writeBytes(ByteBuf, int, int),
except that this method increases the readerIndex of the source
buffer by the number of the transferred bytes (= length) while
writeBytes(ByteBuf, int, int) does not.
If this.writableBytes is less than length, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeBytes in class io.netty.buffer.ByteBuflength - the number of bytes to transferjava.lang.IndexOutOfBoundsException - if length is greater then src.readableBytespublic io.netty.buffer.ByteBuf writeBytes(io.netty.buffer.ByteBuf src,
int srcIndex,
int length)
writerIndex and increases the writerIndex
by the number of the transferred bytes (= length).
If this.writableBytes is less than length, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeBytes in class io.netty.buffer.ByteBufsrcIndex - the first index of the sourcelength - the number of bytes to transferjava.lang.IndexOutOfBoundsException - if the specified srcIndex is less than 0, or
if srcIndex + length is greater than src.capacitypublic io.netty.buffer.ByteBuf writeBytes(byte[] src)
writerIndex and increases the writerIndex
by the number of the transferred bytes (= src.length).
If this.writableBytes is less than src.length, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeBytes in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf writeBytes(byte[] src,
int srcIndex,
int length)
writerIndex and increases the writerIndex
by the number of the transferred bytes (= length).
If this.writableBytes is less than length, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeBytes in class io.netty.buffer.ByteBufsrcIndex - the first index of the sourcelength - the number of bytes to transferjava.lang.IndexOutOfBoundsException - if the specified srcIndex is less than 0, or
if srcIndex + length is greater than src.lengthpublic io.netty.buffer.ByteBuf writeBytes(java.nio.ByteBuffer src)
writerIndex until the source buffer's position
reaches its limit, and increases the writerIndex by the
number of the transferred bytes.
If this.writableBytes is less than src.remaining(),
ensureWritable(int) will be called in an attempt to expand
capacity to accommodate.writeBytes in class io.netty.buffer.ByteBufpublic int writeBytes(java.io.InputStream in,
int length)
throws java.io.IOException
writerIndex and increases the
writerIndex by the number of the transferred bytes.
If this.writableBytes is less than length, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeBytes in class io.netty.buffer.ByteBuflength - the number of bytes to transferjava.io.IOException - if the specified stream threw an exception during I/Opublic int writeBytes(java.nio.channels.ScatteringByteChannel in,
int length)
throws java.io.IOException
writerIndex and increases the
writerIndex by the number of the transferred bytes.
If this.writableBytes is less than length, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeBytes in class io.netty.buffer.ByteBuflength - the maximum number of bytes to transferjava.io.IOException - if the specified channel threw an exception during I/Opublic int writeBytes(java.nio.channels.FileChannel in,
long position,
int length)
throws java.io.IOException
writerIndex and increases the
writerIndex by the number of the transferred bytes.
This method does not modify the channel's position.
If this.writableBytes is less than length, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeBytes in class io.netty.buffer.ByteBufposition - the file position at which the transfer is to beginlength - the maximum number of bytes to transferjava.io.IOException - if the specified channel threw an exception during I/Opublic io.netty.buffer.ByteBuf writeZero(int length)
writerIndex and increases the writerIndex by the
specified length.
If this.writableBytes is less than length, ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeZero in class io.netty.buffer.ByteBuflength - the number of NULs to write to the bufferpublic int writeCharSequence(java.lang.CharSequence sequence,
java.nio.charset.Charset charset)
CharSequence at the current writerIndex and increases
the writerIndex by the written bytes.
in this buffer.
If this.writableBytes is not large enough to write the whole sequence,
ensureWritable(int) will be called in an attempt to expand capacity to accommodate.writeCharSequence in class io.netty.buffer.ByteBufsequence - to writecharset - that should be usedpublic int indexOf(int fromIndex,
int toIndex,
byte value)
value in this
buffer. The search takes place from the specified fromIndex
(inclusive) to the specified toIndex (exclusive).
If fromIndex is greater than toIndex, the search is
performed in a reversed order from fromIndex (exclusive)
down to toIndex (inclusive).
Note that the lower index is always included and higher always excluded.
This method does not modify readerIndex or writerIndex of
this buffer.
indexOf in class io.netty.buffer.ByteBuf-1 otherwise.public int bytesBefore(byte value)
value in this
buffer. The search takes place from the current readerIndex
(inclusive) to the current writerIndex (exclusive).
This method does not modify readerIndex or writerIndex of
this buffer.
bytesBefore in class io.netty.buffer.ByteBufreaderIndex
and the first occurrence if found. -1 otherwise.public int bytesBefore(int length,
byte value)
value in this
buffer. The search starts from the current readerIndex
(inclusive) and lasts for the specified length.
This method does not modify readerIndex or writerIndex of
this buffer.
bytesBefore in class io.netty.buffer.ByteBufreaderIndex
and the first occurrence if found. -1 otherwise.java.lang.IndexOutOfBoundsException - if length is greater than this.readableBytespublic int bytesBefore(int index,
int length,
byte value)
value in this
buffer. The search starts from the specified index (inclusive)
and lasts for the specified length.
This method does not modify readerIndex or writerIndex of
this buffer.
bytesBefore in class io.netty.buffer.ByteBufindex
and the first occurrence if found. -1 otherwise.java.lang.IndexOutOfBoundsException - if index + length is greater than this.capacitypublic int forEachByte(io.netty.util.ByteProcessor processor)
processor in ascending order.forEachByte in class io.netty.buffer.ByteBuf-1 if the processor iterated to or beyond the end of the readable bytes.
The last-visited index If the ByteProcessor.process(byte) returned false.public int forEachByte(int index,
int length,
io.netty.util.ByteProcessor processor)
processor in ascending order.
(i.e. index, (index + 1), .. (index + length - 1))forEachByte in class io.netty.buffer.ByteBuf-1 if the processor iterated to or beyond the end of the specified area.
The last-visited index If the ByteProcessor.process(byte) returned false.public int forEachByteDesc(io.netty.util.ByteProcessor processor)
processor in descending order.forEachByteDesc in class io.netty.buffer.ByteBuf-1 if the processor iterated to or beyond the beginning of the readable bytes.
The last-visited index If the ByteProcessor.process(byte) returned false.public int forEachByteDesc(int index,
int length,
io.netty.util.ByteProcessor processor)
processor in descending order.
(i.e. (index + length - 1), (index + length - 2), ... index)forEachByteDesc in class io.netty.buffer.ByteBuf-1 if the processor iterated to or beyond the beginning of the specified area.
The last-visited index If the ByteProcessor.process(byte) returned false.public io.netty.buffer.ByteBuf copy()
buf.copy(buf.readerIndex(), buf.readableBytes()).
This method does not modify readerIndex or writerIndex of
this buffer.copy in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf copy(int index,
int length)
readerIndex or writerIndex of
this buffer.copy in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf slice()
buf.slice(buf.readerIndex(), buf.readableBytes()).
This method does not modify readerIndex or writerIndex of
this buffer.
Also be aware that this method will NOT call retain() and so the
reference count will NOT be increased.
slice in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf retainedSlice()
buf.slice(buf.readerIndex(), buf.readableBytes()).
This method does not modify readerIndex or writerIndex of
this buffer.
Note that this method returns a retained buffer unlike slice().
This method behaves similarly to slice().retain() except that this method may return
a buffer implementation that produces less garbage.
retainedSlice in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf slice(int index,
int length)
readerIndex or writerIndex of
this buffer.
Also be aware that this method will NOT call retain() and so the
reference count will NOT be increased.
slice in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf retainedSlice(int index,
int length)
readerIndex or writerIndex of
this buffer.
Note that this method returns a retained buffer unlike slice(int, int).
This method behaves similarly to slice(...).retain() except that this method may return
a buffer implementation that produces less garbage.
retainedSlice in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf duplicate()
readerIndex or writerIndex of
this buffer.
The reader and writer marks will not be duplicated. Also be aware that this method will
NOT call retain() and so the reference count will NOT be increased.
duplicate in class io.netty.buffer.ByteBufslice().
However this buffer will share the capacity of the underlying buffer, and therefore allows access to all of the
underlying content if necessary.public io.netty.buffer.ByteBuf retainedDuplicate()
buf.slice(0, buf.capacity()).
This method does not modify readerIndex or writerIndex of
this buffer.
Note that this method returns a retained buffer unlike slice(int, int).
This method behaves similarly to duplicate().retain() except that this method may return
a buffer implementation that produces less garbage.
retainedDuplicate in class io.netty.buffer.ByteBufpublic int nioBufferCount()
ByteBuffers that consist this buffer. Note that nioBuffers()
or nioBuffers(int, int) might return a less number of ByteBuffers.nioBufferCount in class io.netty.buffer.ByteBuf-1 if this buffer has no underlying ByteBuffer.
the number of the underlying ByteBuffers if this buffer has at least one underlying
ByteBuffer. Note that this method does not return 0 to avoid confusion.nioBuffer(),
nioBuffer(int, int),
nioBuffers(),
nioBuffers(int, int)public java.nio.ByteBuffer nioBuffer()
ByteBuffer. The returned buffer
either share or contains the copied content of this buffer, while changing the position
and limit of the returned NIO buffer does not affect the indexes and marks of this buffer.
This method is identical to buf.nioBuffer(buf.readerIndex(), buf.readableBytes()).
This method does not modify readerIndex or writerIndex of this buffer.
Please note that the returned NIO buffer will not see the changes of this buffer if this buffer
is a dynamic buffer and it adjusted its capacity.nioBuffer in class io.netty.buffer.ByteBufjava.lang.UnsupportedOperationException - if this buffer cannot create a ByteBuffer that shares the content with itselfnioBufferCount(),
nioBuffers(),
nioBuffers(int, int)public java.nio.ByteBuffer nioBuffer(int index,
int length)
ByteBuffer. The returned buffer
either share or contains the copied content of this buffer, while changing the position
and limit of the returned NIO buffer does not affect the indexes and marks of this buffer.
This method does not modify readerIndex or writerIndex of this buffer.
Please note that the returned NIO buffer will not see the changes of this buffer if this buffer
is a dynamic buffer and it adjusted its capacity.nioBuffer in class io.netty.buffer.ByteBufjava.lang.UnsupportedOperationException - if this buffer cannot create a ByteBuffer that shares the content with itselfnioBufferCount(),
nioBuffers(),
nioBuffers(int, int)public java.nio.ByteBuffer internalNioBuffer(int index,
int length)
internalNioBuffer in class io.netty.buffer.ByteBufpublic java.nio.ByteBuffer[] nioBuffers()
ByteBuffer's. The returned buffer
either share or contains the copied content of this buffer, while changing the position
and limit of the returned NIO buffer does not affect the indexes and marks of this buffer.
This method does not modify readerIndex or writerIndex of this buffer.
Please note that the returned NIO buffer will not see the changes of this buffer if this buffer
is a dynamic buffer and it adjusted its capacity.nioBuffers in class io.netty.buffer.ByteBufjava.lang.UnsupportedOperationException - if this buffer cannot create a ByteBuffer that shares the content with itselfnioBufferCount(),
nioBuffer(),
nioBuffer(int, int)public java.nio.ByteBuffer[] nioBuffers(int index,
int length)
ByteBuffer's for the specified index and length
The returned buffer either share or contains the copied content of this buffer, while changing
the position and limit of the returned NIO buffer does not affect the indexes and marks of this buffer.
This method does not modify readerIndex or writerIndex of this buffer. Please note that the
returned NIO buffer will not see the changes of this buffer if this buffer is a dynamic
buffer and it adjusted its capacity.nioBuffers in class io.netty.buffer.ByteBufjava.lang.UnsupportedOperationException - if this buffer cannot create a ByteBuffer that shares the content with itselfnioBufferCount(),
nioBuffer(),
nioBuffer(int, int)public boolean hasArray()
true if and only if this buffer has a backing byte array.
If this method returns true, you can safely call array() and
arrayOffset().hasArray in class io.netty.buffer.ByteBufpublic byte[] array()
array in class io.netty.buffer.ByteBufjava.lang.UnsupportedOperationException - if there no accessible backing byte arraypublic int arrayOffset()
arrayOffset in class io.netty.buffer.ByteBufjava.lang.UnsupportedOperationException - if there no accessible backing byte arraypublic boolean hasMemoryAddress()
true if and only if this buffer has a reference to the low-level memory address that points
to the backing data.hasMemoryAddress in class io.netty.buffer.ByteBufpublic long memoryAddress()
memoryAddress in class io.netty.buffer.ByteBufjava.lang.UnsupportedOperationException - if this buffer does not support accessing the low-level memory addresspublic java.lang.String toString(java.nio.charset.Charset charset)
buf.toString(buf.readerIndex(), buf.readableBytes(), charsetName).
This method does not modify readerIndex or writerIndex of
this buffer.toString in class io.netty.buffer.ByteBufjava.nio.charset.UnsupportedCharsetException - if the specified character set name is not supported by the
current VMpublic java.lang.String toString(int index,
int length,
java.nio.charset.Charset charset)
readerIndex or
writerIndex of this buffer.toString in class io.netty.buffer.ByteBufpublic int hashCode()
hashCode in class io.netty.buffer.ByteBufpublic boolean equals(java.lang.Object obj)
readerIndex() nor
writerIndex(). This method also returns false for
null and an object which is not an instance of
ByteBuf type.equals in class io.netty.buffer.ByteBufpublic int compareTo(io.netty.buffer.ByteBuf buffer)
strcmp,
memcmp and String.compareTo(String).compareTo in interface java.lang.Comparable<io.netty.buffer.ByteBuf>compareTo in class io.netty.buffer.ByteBufpublic java.lang.String toString()
readerIndex(),
writerIndex() and capacity().toString in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf retain(int increment)
retain in interface io.netty.util.ReferenceCountedretain in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf retain()
retain in interface io.netty.util.ReferenceCountedretain in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf touch()
touch in interface io.netty.util.ReferenceCountedtouch in class io.netty.buffer.ByteBufpublic io.netty.buffer.ByteBuf touch(java.lang.Object hint)
touch in interface io.netty.util.ReferenceCountedtouch in class io.netty.buffer.ByteBufpublic int refCnt()
0, it means this object has been deallocated.public boolean release()
1 and deallocates this object if the reference count reaches at
0.true if and only if the reference count became 0 and this object has been deallocatedpublic boolean release(int decrement)
decrement and deallocates this object if the reference
count reaches at 0.true if and only if the reference count became 0 and this object has been deallocatedpublic byte[] readReadableBytes()