| Modifier and Type | Field and Description |
|---|---|
static EmptyBuffer |
EMPTY_BUFFER
An instance of
EmptyBuffer that can be shared. |
| Modifier and Type | Method and Description |
|---|---|
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.
|
Buffer |
asReadOnly()
Create a read-only view for 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.
|
Buffer |
capacity(int newCapacity)
Sets the capacity of this buffer.
|
Buffer |
clear()
Sets the
readerIndex and writerIndex of this buffer to
0. |
Buffer |
copy()
Returns a copy of this buffer's readable bytes.
|
Buffer |
copy(int index,
int length)
Returns a copy of this buffer's sub-region.
|
Buffer |
duplicate()
Returns a buffer which shares the whole region of this buffer.
|
Buffer |
ensureWritable(int minWritableBytes)
Expands the buffer
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
Buffer.capacity() to make sure the number of
writable bytes is equal to or greater than the
specified value. |
boolean |
equals(Object obj)
Determines if the content of the specified buffer is identical to the
content of this array.
|
int |
forEachByte(ByteProcessor processor)
Iterates over the readable bytes of this buffer with the specified
processor in ascending order. |
int |
forEachByte(int index,
int length,
ByteProcessor processor)
Iterates over the specified area of this buffer with the specified
processor in ascending order. |
int |
forEachByteDesc(ByteProcessor processor)
Iterates over the readable bytes of this buffer with the specified
processor in descending order. |
int |
forEachByteDesc(int index,
int length,
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. |
Buffer |
getBytes(int index,
Buffer dst)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index until the destination becomes
non-writable. |
Buffer |
getBytes(int index,
Buffer dst,
int length)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index. |
Buffer |
getBytes(int index,
Buffer dst,
int dstIndex,
int length)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index. |
Buffer |
getBytes(int index,
byte[] dst)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index. |
Buffer |
getBytes(int index,
byte[] dst,
int dstIndex,
int length)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index. |
Buffer |
getBytes(int index,
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. |
char |
getChar(int index)
Gets a 2-byte UTF-16 character at the specified absolute
index in this buffer. |
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. |
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.
|
int |
indexOf(int fromIndex,
int toIndex,
byte value)
Locates the first occurrence of the specified
value in this
buffer. |
boolean |
isDirect()
Returns
true if the buffer is direct and so not allocated on the heap. |
boolean |
isReadOnly()
Determine if this buffer is read-only.
|
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). |
int |
nioBufferCount()
Returns the maximum number of NIO
ByteBuffers that consist this buffer. |
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. |
Buffer |
readBytes(Buffer 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. |
Buffer |
readBytes(Buffer 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). |
Buffer |
readBytes(Buffer 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). |
Buffer |
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). |
Buffer |
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). |
Buffer |
readBytes(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. |
Buffer |
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). |
char |
readChar()
Gets a 2-byte UTF-16 character at the current
readerIndex
and increases the readerIndex by 2 in this buffer. |
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. |
Buffer |
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 |
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 |
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. |
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. |
Buffer |
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). |
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. |
Buffer |
setBoolean(int index,
boolean value)
Sets the specified boolean at the specified absolute
index in this
buffer. |
Buffer |
setByte(int index,
int value)
Sets the specified byte at the specified absolute
index in this
buffer. |
Buffer |
setBytes(int index,
Buffer src)
Transfers the specified source buffer's data to this buffer starting at
the specified absolute
index until the source buffer becomes
unreadable. |
Buffer |
setBytes(int index,
Buffer src,
int length)
Transfers the specified source buffer's data to this buffer starting at
the specified absolute
index. |
Buffer |
setBytes(int index,
Buffer src,
int srcIndex,
int length)
Transfers the specified source buffer's data to this buffer starting at
the specified absolute
index. |
Buffer |
setBytes(int index,
byte[] src)
Transfers the specified source array's data to this buffer starting at
the specified absolute
index. |
Buffer |
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. |
Buffer |
setBytes(int index,
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. |
int |
setBytes(int index,
InputStream src,
int length)
Transfers a fixed amount from the specified source InputStream's data to this buffer starting at
the specified absolute
index until length bytes have been read, the end of stream
is reached, or an exception is thrown. |
int |
setBytesUntilEndStream(int index,
InputStream src,
int chunkSize)
Transfers all the specified source InputStream's data to this buffer starting at
the specified absolute
index until the end of stream is reached or an exception is thrown. |
Buffer |
setChar(int index,
int value)
Sets the specified 2-byte UTF-16 character at the specified absolute
index in this buffer. |
Buffer |
setDouble(int index,
double value)
Sets the specified 64-bit floating-point number at the specified
absolute
index in this buffer. |
Buffer |
setFloat(int index,
float value)
Sets the specified 32-bit floating-point number at the specified
absolute
index in this buffer. |
Buffer |
setInt(int index,
int value)
Sets the specified 32-bit integer at the specified absolute
index in this buffer. |
Buffer |
setIntLE(int index,
int value)
Sets the specified 32-bit integer at the specified absolute
index in this buffer with Little Endian byte order
. |
Buffer |
setLong(int index,
long value)
Sets the specified 64-bit long integer at the specified absolute
index in this buffer. |
Buffer |
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. |
Buffer |
setMedium(int index,
int value)
Sets the specified 24-bit medium integer at the specified absolute
index in this buffer. |
Buffer |
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. |
Buffer |
setShort(int index,
int value)
Sets the specified 16-bit short integer at the specified absolute
index in this buffer. |
Buffer |
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. |
Buffer |
skipBytes(int length)
Increases the current
readerIndex by the specified
length in this buffer. |
Buffer |
slice()
Returns a slice of this buffer's readable bytes.
|
Buffer |
slice(int index,
int length)
Returns a slice of this buffer's sub-region.
|
ByteBuffer |
toNioBuffer()
Exposes this buffer's readable bytes as an NIO
ByteBuffer. |
ByteBuffer |
toNioBuffer(int index,
int length)
Exposes this buffer's sub-region as an NIO
ByteBuffer. |
ByteBuffer[] |
toNioBuffers()
Exposes this buffer's readable bytes as an NIO
ByteBuffer's. |
ByteBuffer[] |
toNioBuffers(int index,
int length)
Exposes this buffer's bytes as an NIO
ByteBuffer's for the specified index and length
The returned buffer shares the content with this buffer, while changing the position and limit
of the returned NIO buffer does not affect the indexes of this buffer. |
String |
toString()
Returns the string representation of this buffer.
|
String |
toString(Charset charset)
Decodes this buffer's readable bytes into a string with the specified
character set name.
|
String |
toString(int index,
int length,
Charset charset)
Decodes this buffer's sub-region into a string with the specified
character set.
|
int |
writableBytes()
Returns the number of writable bytes which is equal to
(this.capacity - this.writerIndex). |
Buffer |
writeAscii(CharSequence seq)
Encode a
CharSequence in ASCII and write it
to this buffer starting at writerIndex and increases the writerIndex by the
number of the transferred bytes. |
Buffer |
writeBoolean(boolean value)
Sets the specified boolean at the current
writerIndex
and increases the writerIndex by 1 in this buffer. |
Buffer |
writeByte(int value)
Sets the specified byte at the current
writerIndex
and increases the writerIndex by 1 in this buffer. |
Buffer |
writeBytes(Buffer 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. |
Buffer |
writeBytes(Buffer 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). |
Buffer |
writeBytes(Buffer 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). |
Buffer |
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). |
Buffer |
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). |
Buffer |
writeBytes(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. |
int |
writeBytes(InputStream src,
int length)
Transfers ta fixed amount from the specified source
InputStream's data to this buffer starting at
the current writerIndex until length bytes have been read, the end of stream
is reached, or an exception is thrown. |
int |
writeBytesUntilEndStream(InputStream src,
int chunkSize)
Transfers all the specified source
InputStream's data to this buffer starting at
the current writerIndex until the end of stream is reached or an exception is thrown. |
Buffer |
writeChar(int value)
Sets the specified 2-byte UTF-16 character at the current
writerIndex and increases the writerIndex by 2
in this buffer. |
Buffer |
writeCharSequence(CharSequence seq,
Charset charset)
Encode a
CharSequence encoded in Charset and write it to this buffer starting at
writerIndex and increases the writerIndex by the number of the transferred bytes. |
Buffer |
writeDouble(double value)
Sets the specified 64-bit floating point number at the current
writerIndex and increases the writerIndex by 8
in this buffer. |
Buffer |
writeFloat(float value)
Sets the specified 32-bit floating point number at the current
writerIndex and increases the writerIndex by 4
in this buffer. |
Buffer |
writeInt(int value)
Sets the specified 32-bit integer at the current
writerIndex
and increases the writerIndex by 4 in this buffer. |
Buffer |
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. |
Buffer |
writeLong(long value)
Sets the specified 64-bit long integer at the current
writerIndex and increases the writerIndex by 8
in this buffer. |
Buffer |
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. |
Buffer |
writeMedium(int value)
Sets the specified 24-bit medium integer at the current
writerIndex and increases the writerIndex by 3
in this buffer. |
Buffer |
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. |
Buffer |
writerIndex(int writerIndex)
Sets the
writerIndex of this buffer. |
Buffer |
writeShort(int value)
Sets the specified 16-bit short integer at the current
writerIndex and increases the writerIndex by 2
in this buffer. |
Buffer |
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. |
Buffer |
writeUtf8(CharSequence seq)
Encode a
CharSequence in UTF-8 and write it
to this buffer starting at writerIndex and increases the writerIndex by the
number of the transferred bytes. |
Buffer |
writeUtf8(CharSequence seq,
int ensureWritable)
Encode a
CharSequence in UTF-8 and write it
to this buffer starting at writerIndex and increases the writerIndex by the
number of the transferred bytes. |
asInputStream, asOutputStream, tryEnsureWritablepublic static final EmptyBuffer EMPTY_BUFFER
EmptyBuffer that can be shared.public int capacity()
Bufferpublic Buffer capacity(int newCapacity)
BuffernewCapacity 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).public int maxCapacity()
BufferBuffer.capacity().maxCapacity in interface Bufferpublic int readerIndex()
BufferreaderIndex of this buffer.readerIndex in interface BufferreaderIndex of this buffer.public Buffer readerIndex(int readerIndex)
BufferreaderIndex of this buffer.readerIndex in interface BufferreaderIndex - the new readerIndex of this buffer.public int writerIndex()
BufferwriterIndex of this buffer.writerIndex in interface BufferwriterIndex of this buffer.public Buffer writerIndex(int writerIndex)
BufferwriterIndex of this buffer.writerIndex in interface BufferwriterIndex - the new writerIndex of this buffer.public int readableBytes()
Buffer(this.writerIndex - this.readerIndex).readableBytes in interface Bufferpublic int writableBytes()
Buffer(this.capacity - this.writerIndex).writableBytes in interface Bufferpublic int maxWritableBytes()
Buffer(this.maxCapacity - this.writerIndex).maxWritableBytes in interface Bufferpublic Buffer ensureWritable(int minWritableBytes)
BufferBuffer.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 interface BufferminWritableBytes - the expected minimum number of writable bytespublic int ensureWritable(int minWritableBytes,
boolean force)
BufferBuffer.capacity() to make sure the number of
writable bytes is equal to or greater than the
specified value. Unlike Buffer.ensureWritable(int), this method returns a status code.ensureWritable in interface BufferminWritableBytes - the expected minimum number of writable bytesforce - When Buffer.writerIndex() + minWritableBytes > Buffer.maxCapacity():
true - the capacity of the buffer is expanded to Buffer.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 Buffer clear()
BufferreaderIndex and writerIndex of this buffer to
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.
public boolean getBoolean(int index)
BufferreaderIndex or writerIndex
of this buffer.getBoolean in interface Bufferindex - absolute (@code index) in this buffer.public byte getByte(int index)
Bufferindex in this buffer.
This method does not modify readerIndex or writerIndex of
this buffer.public short getUnsignedByte(int index)
Bufferindex in this
buffer. This method does not modify readerIndex or
writerIndex of this buffer.getUnsignedByte in interface Bufferindex - absolute (@code index) in this buffer.public short getShort(int index)
Bufferindex in
this buffer. This method does not modify readerIndex or
writerIndex of this buffer.public short getShortLE(int index)
Bufferindex in
this buffer in Little Endian Byte Order. This method does not modify
readerIndex or writerIndex of this buffer.getShortLE in interface Bufferindex - absolute (@code index) in this buffer.public int getUnsignedShort(int index)
Bufferindex in this buffer. This method does not modify
readerIndex or writerIndex of this buffer.getUnsignedShort in interface Bufferindex - absolute (@code index) in this buffer.public int getUnsignedShortLE(int index)
Bufferindex in this buffer in Little Endian Byte Order.
This method does not modify readerIndex or
writerIndex of this buffer.getUnsignedShortLE in interface Bufferindex - absolute (@code index) in this buffer.public int getMedium(int index)
Bufferindex in
this buffer. This method does not modify readerIndex or
writerIndex of this buffer.public int getMediumLE(int index)
Bufferindex in
this buffer in the Little Endian Byte Order. This method does not
modify readerIndex or writerIndex of this buffer.getMediumLE in interface Bufferindex - absolute (@code index) in this buffer.public int getUnsignedMedium(int index)
Bufferindex in this buffer. This method does not modify
readerIndex or writerIndex of this buffer.getUnsignedMedium in interface Bufferindex - absolute (@code index) in this buffer.public int getUnsignedMediumLE(int index)
Bufferindex in this buffer in Little Endian Byte Order.
This method does not modify readerIndex or
writerIndex of this buffer.getUnsignedMediumLE in interface Bufferindex - absolute (@code index) in this buffer.public int getInt(int index)
Bufferindex in
this buffer. This method does not modify readerIndex or
writerIndex of this buffer.public int getIntLE(int index)
Bufferindex in
this buffer with Little Endian Byte Order. This method does not
modify readerIndex or writerIndex of this buffer.public long getUnsignedInt(int index)
Bufferindex
in this buffer. This method does not modify readerIndex or
writerIndex of this buffer.getUnsignedInt in interface Bufferindex - absolute (@code index) in this buffer.public long getUnsignedIntLE(int index)
Bufferindex
in this buffer in Little Endian Byte Order. This method does not
modify readerIndex or writerIndex of this buffer.getUnsignedIntLE in interface Bufferindex - absolute (@code index) in this buffer.public long getLong(int index)
Bufferindex in
this buffer. This method does not modify readerIndex or
writerIndex of this buffer.public long getLongLE(int index)
Bufferindex in
this buffer in Little Endian Byte Order. This method does not
modify readerIndex or writerIndex of this buffer.public char getChar(int index)
Bufferindex in this buffer. This method does not modify
readerIndex or writerIndex of this buffer.public float getFloat(int index)
Bufferindex in this buffer. This method does not modify
readerIndex or writerIndex of this buffer.public double getDouble(int index)
Bufferindex in this buffer. This method does not modify
readerIndex or writerIndex of this buffer.public Buffer getBytes(int index, Buffer dst)
Bufferindex until the destination becomes
non-writable. This method is basically same with
Buffer.getBytes(int, Buffer, int, int), except that this
method increases the writerIndex of the destination by the
number of the transferred bytes while
Buffer.getBytes(int, Buffer, int, int) does not.
This method does not modify readerIndex or writerIndex of
the source buffer (i.e. this).public Buffer getBytes(int index, Buffer dst, int length)
Bufferindex. This method is basically same
with Buffer.getBytes(int, Buffer, int, int), except that this
method increases the writerIndex of the destination by the
number of the transferred bytes while
Buffer.getBytes(int, Buffer, int, int) does not.
This method does not modify readerIndex or writerIndex of
the source buffer (i.e. this).public Buffer getBytes(int index, Buffer dst, int dstIndex, int length)
Bufferindex.
This method does not modify readerIndex or writerIndex
of both the source (i.e. this) and the destination.public Buffer getBytes(int index, byte[] dst)
Bufferindex.
This method does not modify readerIndex or writerIndex of
this bufferpublic Buffer getBytes(int index, byte[] dst, int dstIndex, int length)
Bufferindex.
This method does not modify readerIndex or writerIndex
of this buffer.public Buffer getBytes(int index, ByteBuffer dst)
Bufferindex 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.public Buffer setBoolean(int index, boolean value)
Bufferindex in this
buffer.
This method does not modify readerIndex or writerIndex of
this buffer.setBoolean in interface Bufferindex - absolute (@code index) in this buffer.value - the value.public Buffer setByte(int index, int value)
Bufferindex 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.public Buffer setShort(int index, int value)
Bufferindex 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.public Buffer setShortLE(int index, int value)
Bufferindex 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 interface Bufferindex - absolute (@code index) in this buffer.value - the value.public Buffer setMedium(int index, int value)
Bufferindex 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.public Buffer setMediumLE(int index, int value)
Bufferindex 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 interface Bufferindex - absolute (@code index) in this buffer.value - the value.public Buffer setInt(int index, int value)
Bufferindex in this buffer.
This method does not modify readerIndex or writerIndex of
this buffer.public Buffer setIntLE(int index, int value)
Bufferindex in this buffer with Little Endian byte order
.
This method does not modify readerIndex or writerIndex of
this buffer.public Buffer setLong(int index, long value)
Bufferindex in this buffer.
This method does not modify readerIndex or writerIndex of
this buffer.public Buffer setLongLE(int index, long value)
Bufferindex in this buffer in Little Endian Byte Order.
This method does not modify readerIndex or writerIndex of
this buffer.public Buffer setChar(int index, int value)
Bufferindex 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.public Buffer setFloat(int index, float value)
Bufferindex in this buffer.
This method does not modify readerIndex or writerIndex of
this buffer.public Buffer setDouble(int index, double value)
Bufferindex in this buffer.
This method does not modify readerIndex or writerIndex of
this buffer.public Buffer setBytes(int index, Buffer src)
Bufferindex until the source buffer becomes
unreadable. This method is basically same with
Buffer.setBytes(int, Buffer, int, int), except that this
method increases the readerIndex of the source buffer by
the number of the transferred bytes while
Buffer.setBytes(int, Buffer, int, int) does not.
This method does not modify readerIndex or writerIndex of
the source buffer (i.e. this).public Buffer setBytes(int index, Buffer src, int length)
Bufferindex. This method is basically same
with Buffer.setBytes(int, Buffer, int, int), except that this
method increases the readerIndex of the source buffer by
the number of the transferred bytes while
Buffer.setBytes(int, Buffer, int, int) does not.
This method does not modify readerIndex or writerIndex of
the source buffer (i.e. this).public Buffer setBytes(int index, Buffer src, int srcIndex, int length)
Bufferindex.
This method does not modify readerIndex or writerIndex
of both the source (i.e. this) and the destination.public Buffer setBytes(int index, byte[] src)
Bufferindex.
This method does not modify readerIndex or writerIndex of
this buffer.public Buffer setBytes(int index, byte[] src, int srcIndex, int length)
Bufferindex.
This method does not modify readerIndex or writerIndex of
this buffer.public Buffer setBytes(int index, ByteBuffer src)
Bufferindex until the source buffer's position
reaches its limit.
This method does not modify readerIndex or writerIndex of
this buffer.public int setBytes(int index,
InputStream src,
int length)
throws IOException
Bufferindex until length bytes have been read, the end of stream
is reached, or an exception is thrown.
This method does not modify readerIndex or writerIndex of this buffer.
setBytes in interface Bufferindex - absolute (@code index) in this buffer.src - the source InputStream.length - the maximum number of bytes to transfer. The buffer may be resized to accommodate this amount of
data.src.
-1 if the specified channel is closed.IOException - if the InputStream throws an exception while being read from.public int setBytesUntilEndStream(int index,
InputStream src,
int chunkSize)
Bufferindex until the end of stream is reached or an exception is thrown.
This method does not modify readerIndex or writerIndex of this buffer.
This method may modify the underlying storage size of this array to accomidate for reading data.
setBytesUntilEndStream in interface Bufferindex - absolute (@code index) in this buffer.src - the source InputStream.chunkSize - chunkSize the amount of data that will be read from src on each read attempt.src.
-1 if no bytes were read because the specified InputStream was closed when this method was called.public boolean readBoolean()
BufferreaderIndex and increases
the readerIndex by 1 in this buffer.readBoolean in interface Bufferpublic byte readByte()
BufferreaderIndex and increases
the readerIndex by 1 in this buffer.public short readUnsignedByte()
BufferreaderIndex and increases
the readerIndex by 1 in this buffer.readUnsignedByte in interface Bufferpublic short readShort()
BufferreaderIndex
and increases the readerIndex by 2 in this buffer.public short readShortLE()
BufferreaderIndex
in the Little Endian Byte Order and increases the readerIndex
by 2 in this buffer.readShortLE in interface Bufferpublic int readUnsignedShort()
BufferreaderIndex
and increases the readerIndex by 2 in this buffer.readUnsignedShort in interface Bufferpublic int readUnsignedShortLE()
BufferreaderIndex
in the Little Endian Byte Order and increases the readerIndex
by 2 in this buffer.readUnsignedShortLE in interface Bufferpublic int readMedium()
BufferreaderIndex
and increases the readerIndex by 3 in this buffer.readMedium in interface Bufferpublic int readMediumLE()
BufferreaderIndex
in the Little Endian Byte Order and increases the
readerIndex by 3 in this buffer.readMediumLE in interface Bufferpublic int readUnsignedMedium()
BufferreaderIndex
and increases the readerIndex by 3 in this buffer.readUnsignedMedium in interface Bufferpublic int readUnsignedMediumLE()
BufferreaderIndex
in the Little Endian Byte Order and increases the readerIndex
by 3 in this buffer.readUnsignedMediumLE in interface Bufferpublic int readInt()
BufferreaderIndex
and increases the readerIndex by 4 in this buffer.public int readIntLE()
BufferreaderIndex
in the Little Endian Byte Order and increases the readerIndex
by 4 in this buffer.public long readUnsignedInt()
BufferreaderIndex
and increases the readerIndex by 4 in this buffer.readUnsignedInt in interface Bufferpublic long readUnsignedIntLE()
BufferreaderIndex
in the Little Endian Byte Order and increases the readerIndex
by 4 in this buffer.readUnsignedIntLE in interface Bufferpublic long readLong()
BufferreaderIndex
and increases the readerIndex by 8 in this buffer.public long readLongLE()
BufferreaderIndex
in the Little Endian Byte Order and increases the readerIndex
by 8 in this buffer.readLongLE in interface Bufferpublic char readChar()
BufferreaderIndex
and increases the readerIndex by 2 in this buffer.public float readFloat()
BufferreaderIndex
and increases the readerIndex by 4 in this buffer.public double readDouble()
BufferreaderIndex
and increases the readerIndex by 8 in this buffer.readDouble in interface Bufferpublic Buffer readSlice(int length)
BufferreaderIndex and increases the readerIndex by the size
of the new slice (= length).public Buffer readBytes(int length)
BufferreaderIndex and increases the readerIndex
by the number of the transferred bytes (= length).
The returned buffer's readerIndex and writerIndex are
0 and length respectively.public Buffer readBytes(Buffer dst)
BufferreaderIndex until the destination becomes
non-writable, and increases the readerIndex by the number of the
transferred bytes. This method is basically same with
Buffer.readBytes(Buffer, int, int), except that this method
increases the writerIndex of the destination by the number of
the transferred bytes while Buffer.readBytes(Buffer, int, int)
does not.public Buffer readBytes(Buffer dst, int length)
BufferreaderIndex and increases the readerIndex
by the number of the transferred bytes (= length). This method
is basically same with Buffer.readBytes(Buffer, int, int),
except that this method increases the writerIndex of the
destination by the number of the transferred bytes (= length)
while Buffer.readBytes(Buffer, int, int) does not.public Buffer readBytes(Buffer dst, int dstIndex, int length)
BufferreaderIndex and increases the readerIndex
by the number of the transferred bytes (= length).public Buffer readBytes(byte[] dst)
BufferreaderIndex and increases the readerIndex
by the number of the transferred bytes (= dst.length).public Buffer readBytes(byte[] dst, int dstIndex, int length)
BufferreaderIndex and increases the readerIndex
by the number of the transferred bytes (= length).public Buffer readBytes(ByteBuffer dst)
BufferreaderIndex until the destination's position
reaches its limit, and increases the readerIndex by the
number of the transferred bytes.public Buffer skipBytes(int length)
BufferreaderIndex by the specified
length in this buffer.public Buffer writeBoolean(boolean value)
BufferwriterIndex
and increases the writerIndex by 1 in this buffer.
If this.writableBytes is less than 1, Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeBoolean in interface Buffervalue - the value to write.public Buffer writeByte(int value)
BufferwriterIndex
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, Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.public Buffer writeShort(int value)
BufferwriterIndex 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, Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeShort in interface Buffervalue - the value to write.public Buffer writeShortLE(int value)
BufferwriterIndex 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, Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeShortLE in interface Buffervalue - the value to write.public Buffer writeMedium(int value)
BufferwriterIndex and increases the writerIndex by 3
in this buffer.
If this.writableBytes is less than 3, Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeMedium in interface Buffervalue - the value to write.public Buffer writeMediumLE(int value)
BufferwriterIndex in the Little Endian Byte Order and
increases the writerIndex by 3 in this
buffer.
If this.writableBytes is less than 3, Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeMediumLE in interface Buffervalue - the value to write.public Buffer writeInt(int value)
BufferwriterIndex
and increases the writerIndex by 4 in this buffer.
If this.writableBytes is less than 4, Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.public Buffer writeIntLE(int value)
BufferwriterIndex
in the Little Endian Byte Order and increases the writerIndex
by 4 in this buffer.
If this.writableBytes is less than 4, Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeIntLE in interface Buffervalue - the value to write.public Buffer writeLong(long value)
BufferwriterIndex and increases the writerIndex by 8
in this buffer.
If this.writableBytes is less than 8, Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.public Buffer writeLongLE(long value)
BufferwriterIndex in the Little Endian Byte Order and
increases the writerIndex by 8
in this buffer.
If this.writableBytes is less than 8, Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeLongLE in interface Buffervalue - the value to write.public Buffer writeChar(int value)
BufferwriterIndex 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, Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.public Buffer writeFloat(float value)
BufferwriterIndex and increases the writerIndex by 4
in this buffer.
If this.writableBytes is less than 4, Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeFloat in interface Buffervalue - the value to write.public Buffer writeDouble(double value)
BufferwriterIndex and increases the writerIndex by 8
in this buffer.
If this.writableBytes is less than 8, Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeDouble in interface Buffervalue - the value to write.public Buffer writeBytes(Buffer src)
BufferwriterIndex until the source buffer becomes
unreadable, and increases the writerIndex by the number of
the transferred bytes. This method is basically same with
Buffer.writeBytes(Buffer, int, int), except that this method
increases the readerIndex of the source buffer by the number of
the transferred bytes while Buffer.writeBytes(Buffer, int, int)
does not.
If this.writableBytes is less than src.readableBytes,
Buffer.ensureWritable(int) will be called in an attempt to expand
capacity to accommodate.writeBytes in interface Buffersrc - the buffer to write.public Buffer writeBytes(Buffer src, int length)
BufferwriterIndex and increases the writerIndex
by the number of the transferred bytes (= length). This method
is basically same with Buffer.writeBytes(Buffer, int, int),
except that this method increases the readerIndex of the source
buffer by the number of the transferred bytes (= length) while
Buffer.writeBytes(Buffer, int, int) does not.
If this.writableBytes is less than length, Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeBytes in interface Buffersrc - the buffer to write.length - the number of bytes to transferpublic Buffer writeBytes(Buffer src, int srcIndex, int length)
BufferwriterIndex and increases the writerIndex
by the number of the transferred bytes (= length).
If this.writableBytes is less than length, Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeBytes in interface Buffersrc - the buffer to write.srcIndex - the first index of the sourcelength - the number of bytes to transferpublic Buffer writeBytes(byte[] src)
BufferwriterIndex and increases the writerIndex
by the number of the transferred bytes (= src.length).
If this.writableBytes is less than src.length, Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeBytes in interface Buffersrc - the array to write.public Buffer writeBytes(byte[] src, int srcIndex, int length)
BufferwriterIndex and increases the writerIndex
by the number of the transferred bytes (= length).
If this.writableBytes is less than length, Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeBytes in interface Buffersrc - the array to write.srcIndex - the first index of the sourcelength - the number of bytes to transferpublic Buffer writeBytes(ByteBuffer src)
BufferwriterIndex 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(),
Buffer.ensureWritable(int) will be called in an attempt to expand
capacity to accommodate.writeBytes in interface Buffersrc - the source buffer to write.public int writeBytes(InputStream src,
int length)
BufferInputStream's data to this buffer starting at
the current writerIndex until length bytes have been read, the end of stream
is reached, or an exception is thrown.
If this.writableBytes is less than length, Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.
This method will increase the writerIndex by the number of the transferred bytes if the write operation
was successful.
writeBytes in interface Buffersrc - the source InputStream to write.length - the maximum number of bytes to transfer. The buffer may be resized to accommodate this amount of
data.src.
-1 if the specified channel is closed.public int writeBytesUntilEndStream(InputStream src,
int chunkSize)
BufferInputStream's data to this buffer starting at
the current writerIndex until the end of stream is reached or an exception is thrown.
If this.writableBytes is less than the number of bytes in the InputStream,
Buffer.ensureWritable(int) will be called in an attempt to expand capacity to accommodate.
Note that because InputStream does not provide a reliable way to get the remaining bytes,
this method may over allocate by a factor of chunkSize.
This method will increase the writerIndex by the number of the transferred bytes if the write operation
was successful.
writeBytesUntilEndStream in interface Buffersrc - the source InputStream to write.chunkSize - the amount of data that will be read from src on each read attempt.src.
-1 if no bytes were read because the specified InputStream was closed when this method
was called.public Buffer writeAscii(CharSequence seq)
BufferCharSequence in ASCII and write it
to this buffer starting at writerIndex and increases the writerIndex by the
number of the transferred bytes.
If this.writableBytes is not large enough to write the whole sequence,
Buffer.ensureWritable(int) will be called in an attempt to expand capacity to accommodate.writeAscii in interface Bufferseq - the source of the data.public Buffer writeUtf8(CharSequence seq)
BufferCharSequence in UTF-8 and write it
to this buffer starting at writerIndex and increases the writerIndex by the
number of the transferred bytes.
If this.writableBytes is not large enough to write the whole sequence,
Buffer.ensureWritable(int) will be called in an attempt to expand capacity to accommodate.public Buffer writeUtf8(CharSequence seq, int ensureWritable)
BufferCharSequence in UTF-8 and write it
to this buffer starting at writerIndex and increases the writerIndex by the
number of the transferred bytes.public Buffer writeCharSequence(CharSequence seq, Charset charset)
BufferCharSequence encoded in Charset and write it to this buffer starting at
writerIndex and increases the writerIndex by the number of the transferred bytes.writeCharSequence in interface Bufferseq - the source of the data.charset - the charset used for encoding.public int indexOf(int fromIndex,
int toIndex,
byte value)
Buffervalue 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.
This method does not modify readerIndex or writerIndex of
this buffer.
public int bytesBefore(byte value)
Buffervalue 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 interface Buffervalue - the value to search.readerIndex
and the first occurrence if found. -1 otherwise.public int bytesBefore(int length,
byte value)
Buffervalue 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 interface Bufferlength - the length.value - the value to search.readerIndex
and the first occurrence if found. -1 otherwise.public int bytesBefore(int index,
int length,
byte value)
Buffervalue 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 interface Bufferindex - the index.length - the length.value - the value to search.index
and the first occurrence if found. -1 otherwise.public Buffer copy()
Bufferbuf.copy(buf.readerIndex(), buf.readableBytes()).
This method does not modify readerIndex or writerIndex of
this buffer.public Buffer copy(int index, int length)
BufferreaderIndex or writerIndex of
this buffer.public Buffer slice()
Bufferbuf.slice(buf.readerIndex(), buf.readableBytes()).
This method does not modify readerIndex or writerIndex of
this buffer.public Buffer slice(int index, int length)
BufferreaderIndex or writerIndex of
this buffer.public Buffer duplicate()
Bufferbuf.slice(0, buf.capacity()).
This method does not modify readerIndex or writerIndex of
this buffer.public int nioBufferCount()
BufferByteBuffers that consist this buffer. Note that
Buffer.toNioBuffers() or Buffer.toNioBuffers(int, int) might return a less number of ByteBuffers.nioBufferCount in interface Buffer-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.Buffer.toNioBuffer(),
Buffer.toNioBuffer(int, int),
Buffer.toNioBuffers(),
Buffer.toNioBuffers(int, int)public ByteBuffer toNioBuffer()
BufferByteBuffer. The returned buffer
shares the content with this buffer, while changing the position and limit of the returned
NIO buffer does not affect the indexes 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.toNioBuffer in interface BufferBuffer.nioBufferCount(),
Buffer.toNioBuffers(),
Buffer.toNioBuffers(int, int)public ByteBuffer toNioBuffer(int index,
int length)
BufferByteBuffer. The returned buffer
shares the content with this buffer, while changing the position and limit of the returned
NIO buffer does not affect the indexes 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.toNioBuffer in interface Bufferindex - the start index.length - the length.Buffer.nioBufferCount(),
Buffer.toNioBuffers(),
Buffer.toNioBuffers(int, int)public ByteBuffer[] toNioBuffers()
BufferByteBuffer's. The returned buffer
shares the content with this buffer, while changing the position and limit of the returned
NIO buffer does not affect the indexes 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.toNioBuffers in interface BufferBuffer.nioBufferCount(),
Buffer.toNioBuffer(),
Buffer.toNioBuffer(int, int)public ByteBuffer[] toNioBuffers(int index,
int length)
BufferByteBuffer's for the specified index and length
The returned buffer shares the content with this buffer, while changing the position and limit
of the returned NIO buffer does not affect the indexes 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.toNioBuffers in interface Bufferindex - the start index.length - the length.Buffer.nioBufferCount(),
Buffer.toNioBuffer(),
Buffer.toNioBuffer(int, int)public boolean isReadOnly()
BufferisReadOnly in interface Buffertrue if and only if this buffer is read-only.public Buffer asReadOnly()
Buffer
The returned read-only view shares indexes and content with the original Buffer. All methods that try
to change the content will throw ReadOnlyBufferException. Modifications for indexes are allowed and will
be propagated to the original Buffer. To prevent changes of indexes for the original Buffer use
Buffer.duplicate() before converting to a read-only view.
asReadOnly in interface Bufferpublic boolean isDirect()
Buffertrue if the buffer is direct and so not allocated on the heap.public boolean hasArray()
Buffertrue if and only if this buffer has a backing byte array.
If this method returns true, you can safely call Buffer.array() and
Buffer.arrayOffset().hasArray in interface Buffertrue if backed by an byte array and is not read-onlyBuffer.array(),
Buffer.arrayOffset()public byte[] array()
Buffer
The caller must check Buffer.hasArray() returns true before calling this method or
UnsupportedOperationException maybe thrown.
Use Buffer.arrayOffset() to get the starting point of data for this buffer. The returned array maybe shared and
this Buffer's data may reside in a sub-section.
array in interface BufferBuffer.hasArray(),
Buffer.arrayOffset()public int arrayOffset()
Buffer
The caller must check Buffer.hasArray() returns true before calling this method or
UnsupportedOperationException maybe thrown.
arrayOffset in interface BufferBuffer.hasArray(),
Buffer.array()public String toString()
BufferBuffer.readerIndex(),
Buffer.writerIndex() and Buffer.capacity().public String toString(Charset charset)
Bufferbuf.toString(buf.readerIndex(), buf.readableBytes(), charsetName).
This method does not modify readerIndex or writerIndex of
this buffer.public String toString(int index,
int length,
Charset charset)
BufferreaderIndex or
writerIndex of this buffer.public int forEachByte(ByteProcessor processor)
Bufferprocessor in ascending order.forEachByte in interface Bufferprocessor - the ByteProcessor to use.-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,
ByteProcessor processor)
Bufferprocessor in ascending order.
(i.e. index, (index + 1), .. (index + length - 1))forEachByte in interface Bufferindex - The index to start iterating from.length - The amount of bytes to iterate over.processor - the ByteProcessor to use.-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(ByteProcessor processor)
Bufferprocessor in descending order.forEachByteDesc in interface Bufferprocessor - the ByteProcessor to use.-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,
ByteProcessor processor)
Bufferprocessor in descending order.
(i.e. (index + length - 1), (index + length - 2), ... index)forEachByteDesc in interface Bufferindex - The index to start iterating from.length - The amount of bytes to iterate over.processor - the ByteProcessor to use.-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 int hashCode()
Bufferpublic boolean equals(Object obj)
BufferBuffer.readerIndex() nor
Buffer.writerIndex(). This method also returns false for
null and an object which is not an instance of
Buffer type.