public class CompositeByteBuf extends AbstractReferenceCountedByteBuf implements java.lang.Iterable<ByteBuf>
ByteBufAllocator.compositeBuffer() or Unpooled.wrappedBuffer(ByteBuf...) instead of calling the
constructor explicitly.| 构造器和说明 |
|---|
CompositeByteBuf(ByteBufAllocator alloc,
boolean direct,
int maxNumComponents) |
CompositeByteBuf(ByteBufAllocator alloc,
boolean direct,
int maxNumComponents,
ByteBuf... buffers) |
CompositeByteBuf(ByteBufAllocator alloc,
boolean direct,
int maxNumComponents,
java.lang.Iterable<ByteBuf> buffers) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected byte |
_getByte(int index) |
protected int |
_getInt(int index) |
protected int |
_getIntLE(int index) |
protected long |
_getLong(int index) |
protected long |
_getLongLE(int index) |
protected short |
_getShort(int index) |
protected short |
_getShortLE(int index) |
protected int |
_getUnsignedMedium(int index) |
protected int |
_getUnsignedMediumLE(int index) |
protected void |
_setByte(int index,
int value) |
protected void |
_setInt(int index,
int value) |
protected void |
_setIntLE(int index,
int value) |
protected void |
_setLong(int index,
long value) |
protected void |
_setLongLE(int index,
long value) |
protected void |
_setMedium(int index,
int value) |
protected void |
_setMediumLE(int index,
int value) |
protected void |
_setShort(int index,
int value) |
protected void |
_setShortLE(int index,
int value) |
CompositeByteBuf |
addComponent(boolean increaseWriterIndex,
ByteBuf buffer)
|
CompositeByteBuf |
addComponent(boolean increaseWriterIndex,
int cIndex,
ByteBuf buffer)
Add the given
ByteBuf on the specific index and increase the writerIndex
if increaseWriterIndex is true. |
CompositeByteBuf |
addComponent(ByteBuf buffer)
Add the given
ByteBuf. |
CompositeByteBuf |
addComponent(int cIndex,
ByteBuf buffer)
Add the given
ByteBuf on the specific index. |
CompositeByteBuf |
addComponents(boolean increaseWriterIndex,
ByteBuf... buffers)
|
CompositeByteBuf |
addComponents(boolean increaseWriterIndex,
java.lang.Iterable<ByteBuf> buffers)
|
CompositeByteBuf |
addComponents(ByteBuf... buffers)
Add the given
ByteBufs. |
CompositeByteBuf |
addComponents(int cIndex,
ByteBuf... buffers)
Add the given
ByteBufs on the specific index
Be aware that this method does not increase the writerIndex of the CompositeByteBuf. |
CompositeByteBuf |
addComponents(int cIndex,
java.lang.Iterable<ByteBuf> buffers)
Add the given
ByteBufs on the specific index
Be aware that this method does not increase the writerIndex of the CompositeByteBuf. |
CompositeByteBuf |
addComponents(java.lang.Iterable<ByteBuf> buffers)
Add the given
ByteBufs. |
CompositeByteBuf |
addFlattenedComponents(boolean increaseWriterIndex,
ByteBuf 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.
|
int |
capacity()
Returns the number of bytes (octets) this buffer can contain.
|
CompositeByteBuf |
capacity(int newCapacity)
Adjusts the capacity of this buffer.
|
CompositeByteBuf |
clear()
Sets the
readerIndex and writerIndex of this buffer to
0. |
ByteBuf |
component(int cIndex)
Return the
ByteBuf on the specified index |
ByteBuf |
componentAtOffset(int offset)
Return the
ByteBuf on the specified index |
CompositeByteBuf |
consolidate()
Consolidate the composed
ByteBufs |
CompositeByteBuf |
consolidate(int cIndex,
int numComponents)
Consolidate the composed
ByteBufs |
ByteBuf |
copy(int index,
int length)
Returns a copy of this buffer's sub-region.
|
protected void |
deallocate()
Called once
AbstractReferenceCountedByteBuf.refCnt() is equals 0. |
java.util.List<ByteBuf> |
decompose(int offset,
int length)
Same with
AbstractByteBuf.slice(int, int) except that this method returns a list. |
CompositeByteBuf |
discardReadBytes()
Discards the bytes between the 0th index and
readerIndex. |
CompositeByteBuf |
discardReadComponents()
Discard all
ByteBufs which are read. |
CompositeByteBuf |
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. |
CompositeByteBuf |
ensureWritable(int minWritableBytes)
Expands the buffer
ByteBuf.capacity() to make sure the number of
writable bytes is equal to or greater than the
specified value. |
protected int |
forEachByteAsc0(int start,
int end,
ByteProcessor processor) |
protected int |
forEachByteDesc0(int rStart,
int rEnd,
ByteProcessor processor) |
byte |
getByte(int index)
Gets a byte at the specified absolute
index in this buffer. |
CompositeByteBuf |
getBytes(int index,
byte[] dst)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index. |
CompositeByteBuf |
getBytes(int index,
byte[] dst,
int dstIndex,
int length)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index. |
CompositeByteBuf |
getBytes(int index,
ByteBuf dst)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index until the destination becomes
non-writable. |
CompositeByteBuf |
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. |
CompositeByteBuf |
getBytes(int index,
ByteBuf dst,
int length)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index. |
CompositeByteBuf |
getBytes(int index,
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. |
CompositeByteBuf |
getBytes(int index,
java.io.OutputStream out,
int length)
Transfers this buffer's data to the specified stream starting at the
specified absolute
index. |
boolean |
hasArray()
Returns
true if and only if this buffer has a backing byte array. |
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. |
ByteBuf |
internalComponent(int cIndex)
Return the internal
ByteBuf on the specified index. |
ByteBuf |
internalComponentAtOffset(int offset)
Return the internal
ByteBuf on the specified offset. |
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. |
java.util.Iterator<ByteBuf> |
iterator() |
CompositeByteBuf |
markReaderIndex()
Marks the current
readerIndex in this buffer. |
CompositeByteBuf |
markWriterIndex()
Marks the current
writerIndex in this buffer. |
int |
maxNumComponents()
Return the max number of
ByteBuf's that are composed in this instance |
long |
memoryAddress()
Returns the low-level memory address that point to the first byte of ths backing data.
|
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. |
int |
numComponents()
Return the current number of
ByteBuf's that are composed in this instance |
java.nio.ByteOrder |
order()
Returns the endianness
of this buffer.
|
CompositeByteBuf |
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). |
CompositeByteBuf |
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). |
CompositeByteBuf |
readBytes(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. |
CompositeByteBuf |
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. |
CompositeByteBuf |
readBytes(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). |
CompositeByteBuf |
readBytes(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). |
CompositeByteBuf |
readBytes(java.io.OutputStream out,
int length)
Transfers this buffer's data to the specified stream starting at the
current
readerIndex. |
CompositeByteBuf |
readerIndex(int readerIndex)
Sets the
readerIndex of this buffer. |
CompositeByteBuf |
removeComponent(int cIndex)
Remove the
ByteBuf from the given index. |
CompositeByteBuf |
removeComponents(int cIndex,
int numComponents)
Remove the number of
ByteBufs starting from the given index. |
CompositeByteBuf |
resetReaderIndex()
Repositions the current
readerIndex to the marked
readerIndex in this buffer. |
CompositeByteBuf |
resetWriterIndex()
Repositions the current
writerIndex to the marked
writerIndex in this buffer. |
CompositeByteBuf |
retain()
Increases the reference count by
1. |
CompositeByteBuf |
retain(int increment)
Increases the reference count by the specified
increment. |
CompositeByteBuf |
setBoolean(int index,
boolean value)
Sets the specified boolean at the specified absolute
index in this
buffer. |
CompositeByteBuf |
setByte(int index,
int value)
Sets the specified byte at the specified absolute
index in this
buffer. |
CompositeByteBuf |
setBytes(int index,
byte[] src)
Transfers the specified source array's data to this buffer starting at
the specified absolute
index. |
CompositeByteBuf |
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. |
CompositeByteBuf |
setBytes(int index,
ByteBuf src)
Transfers the specified source buffer's data to this buffer starting at
the specified absolute
index until the source buffer becomes
unreadable. |
CompositeByteBuf |
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. |
CompositeByteBuf |
setBytes(int index,
ByteBuf src,
int length)
Transfers the specified source buffer's data to this buffer starting at
the specified absolute
index. |
CompositeByteBuf |
setBytes(int index,
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. |
CompositeByteBuf |
setChar(int index,
int value)
Sets the specified 2-byte UTF-16 character at the specified absolute
index in this buffer. |
CompositeByteBuf |
setDouble(int index,
double value)
Sets the specified 64-bit floating-point number at the specified
absolute
index in this buffer. |
CompositeByteBuf |
setFloat(int index,
float value)
Sets the specified 32-bit floating-point number at the specified
absolute
index in this buffer. |
CompositeByteBuf |
setIndex(int readerIndex,
int writerIndex)
Sets the
readerIndex and writerIndex of this buffer
in one shot. |
CompositeByteBuf |
setInt(int index,
int value)
Sets the specified 32-bit integer at the specified absolute
index in this buffer. |
CompositeByteBuf |
setLong(int index,
long value)
Sets the specified 64-bit long integer at the specified absolute
index in this buffer. |
CompositeByteBuf |
setMedium(int index,
int value)
Sets the specified 24-bit medium integer at the specified absolute
index in this buffer. |
CompositeByteBuf |
setShort(int index,
int value)
Sets the specified 16-bit short integer at the specified absolute
index in this buffer. |
CompositeByteBuf |
setZero(int index,
int length)
Fills this buffer with NUL (0x00) starting at the specified
absolute
index. |
CompositeByteBuf |
skipBytes(int length)
Increases the current
readerIndex by the specified
length in this buffer. |
int |
toByteIndex(int cIndex) |
int |
toComponentIndex(int offset)
Return the index for the given offset
|
java.lang.String |
toString()
Returns the string representation of this buffer.
|
CompositeByteBuf |
touch()
Records the current access location of this object for debugging purposes.
|
CompositeByteBuf |
touch(java.lang.Object hint)
Records the current access location of this object with an additional arbitrary information for debugging
purposes.
|
ByteBuf |
unwrap()
Return the underlying buffer instance if this buffer is a wrapper of another buffer.
|
CompositeByteBuf |
writeBoolean(boolean value)
Sets the specified boolean at the current
writerIndex
and increases the writerIndex by 1 in this buffer. |
CompositeByteBuf |
writeByte(int value)
Sets the specified byte at the current
writerIndex
and increases the writerIndex by 1 in this buffer. |
CompositeByteBuf |
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). |
CompositeByteBuf |
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). |
CompositeByteBuf |
writeBytes(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. |
CompositeByteBuf |
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. |
CompositeByteBuf |
writeBytes(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). |
CompositeByteBuf |
writeBytes(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). |
CompositeByteBuf |
writeChar(int value)
Sets the specified 2-byte UTF-16 character at the current
writerIndex and increases the writerIndex by 2
in this buffer. |
CompositeByteBuf |
writeDouble(double value)
Sets the specified 64-bit floating point number at the current
writerIndex and increases the writerIndex by 8
in this buffer. |
CompositeByteBuf |
writeFloat(float value)
Sets the specified 32-bit floating point number at the current
writerIndex and increases the writerIndex by 4
in this buffer. |
CompositeByteBuf |
writeInt(int value)
Sets the specified 32-bit integer at the current
writerIndex
and increases the writerIndex by 4 in this buffer. |
CompositeByteBuf |
writeLong(long value)
Sets the specified 64-bit long integer at the current
writerIndex and increases the writerIndex by 8
in this buffer. |
CompositeByteBuf |
writeMedium(int value)
Sets the specified 24-bit medium integer at the current
writerIndex and increases the writerIndex by 3
in this buffer. |
CompositeByteBuf |
writerIndex(int writerIndex)
Sets the
writerIndex of this buffer. |
CompositeByteBuf |
writeShort(int value)
Sets the specified 16-bit short integer at the current
writerIndex and increases the writerIndex by 2
in this buffer. |
CompositeByteBuf |
writeZero(int length)
Fills this buffer with NUL (0x00) starting at the current
writerIndex and increases the writerIndex by the
specified length. |
refCnt, release, release, resetRefCnt, setRefCntadjustMarkers, asReadOnly, bytesBefore, bytesBefore, bytesBefore, checkDstIndex, checkDstIndex, checkIndex, checkIndex, checkNewCapacity, checkReadableBytes, checkSrcIndex, compareTo, copy, duplicate, ensureAccessible, ensureWritable, equals, forEachByte, forEachByte, forEachByteDesc, forEachByteDesc, getBoolean, getChar, getCharSequence, getDouble, getFloat, getInt, getIntLE, getLong, getLongLE, getMedium, getMediumLE, getShort, getShortLE, getUnsignedByte, getUnsignedInt, getUnsignedIntLE, getUnsignedMedium, getUnsignedMediumLE, getUnsignedShort, getUnsignedShortLE, hashCode, indexOf, isReadable, isReadable, isReadOnly, isWritable, isWritable, maxCapacity, maxCapacity, maxWritableBytes, newSwappedByteBuf, nioBuffer, order, readableBytes, readBoolean, readByte, readBytes, readBytes, readBytes, readChar, readCharSequence, readDouble, readerIndex, readFloat, readInt, readIntLE, readLong, readLongLE, readMedium, readMediumLE, readRetainedSlice, readShort, readShortLE, readSlice, readUnsignedByte, readUnsignedInt, readUnsignedIntLE, readUnsignedMedium, readUnsignedMediumLE, readUnsignedShort, readUnsignedShortLE, retainedDuplicate, retainedSlice, retainedSlice, setCharSequence, setIntLE, setLongLE, setMediumLE, setShortLE, slice, slice, toString, toString, trimIndicesToCapacity, writableBytes, writeBytes, writeBytes, writeBytes, writeCharSequence, writeIntLE, writeLongLE, writeMediumLE, writerIndex, writeShortLEasByteBuf, getDoubleLE, getFloatLE, isContiguous, maxFastWritableBytes, readDoubleLE, readFloatLE, setDoubleLE, setFloatLE, writeDoubleLE, writeFloatLEpublic CompositeByteBuf(ByteBufAllocator alloc, boolean direct, int maxNumComponents)
public CompositeByteBuf(ByteBufAllocator alloc, boolean direct, int maxNumComponents, ByteBuf... buffers)
public CompositeByteBuf(ByteBufAllocator alloc, boolean direct, int maxNumComponents, java.lang.Iterable<ByteBuf> buffers)
public CompositeByteBuf addComponent(ByteBuf buffer)
ByteBuf.
Be aware that this method does not increase the writerIndex of the CompositeByteBuf.
If you need to have it increased use addComponent(boolean, ByteBuf).
ReferenceCounted.release() ownership of buffer is transferred to this CompositeByteBuf.
buffer - the ByteBuf to add. ReferenceCounted.release() ownership is transferred to this
CompositeByteBuf.public CompositeByteBuf addComponents(ByteBuf... buffers)
ByteBufs.
Be aware that this method does not increase the writerIndex of the CompositeByteBuf.
If you need to have it increased use addComponents(boolean, ByteBuf[]).
ReferenceCounted.release() ownership of all ByteBuf objects in buffers is transferred to this
CompositeByteBuf.
buffers - the ByteBufs to add. ReferenceCounted.release() ownership of all ReferenceCounted.release()
ownership of all ByteBuf objects is transferred to this CompositeByteBuf.public CompositeByteBuf addComponents(java.lang.Iterable<ByteBuf> buffers)
ByteBufs.
Be aware that this method does not increase the writerIndex of the CompositeByteBuf.
If you need to have it increased use addComponents(boolean, Iterable).
ReferenceCounted.release() ownership of all ByteBuf objects in buffers is transferred to this
CompositeByteBuf.
buffers - the ByteBufs to add. ReferenceCounted.release() ownership of all ReferenceCounted.release()
ownership of all ByteBuf objects is transferred to this CompositeByteBuf.public CompositeByteBuf addComponent(int cIndex, ByteBuf buffer)
ByteBuf on the specific index.
Be aware that this method does not increase the writerIndex of the CompositeByteBuf.
If you need to have it increased use addComponent(boolean, int, ByteBuf).
ReferenceCounted.release() ownership of buffer is transferred to this CompositeByteBuf.
cIndex - the index on which the ByteBuf will be added.buffer - the ByteBuf to add. ReferenceCounted.release() ownership is transferred to this
CompositeByteBuf.public CompositeByteBuf addComponent(boolean increaseWriterIndex, ByteBuf buffer)
ByteBuf and increase the writerIndex if increaseWriterIndex is
true.
ReferenceCounted.release() ownership of buffer is transferred to this CompositeByteBuf.buffer - the ByteBuf to add. ReferenceCounted.release() ownership is transferred to this
CompositeByteBuf.public CompositeByteBuf addComponents(boolean increaseWriterIndex, ByteBuf... buffers)
ByteBufs and increase the writerIndex if increaseWriterIndex is
true.
ReferenceCounted.release() ownership of all ByteBuf objects in buffers is transferred to this
CompositeByteBuf.buffers - the ByteBufs to add. ReferenceCounted.release() ownership of all ReferenceCounted.release()
ownership of all ByteBuf objects is transferred to this CompositeByteBuf.public CompositeByteBuf addComponents(boolean increaseWriterIndex, java.lang.Iterable<ByteBuf> buffers)
ByteBufs and increase the writerIndex if increaseWriterIndex is
true.
ReferenceCounted.release() ownership of all ByteBuf objects in buffers is transferred to this
CompositeByteBuf.buffers - the ByteBufs to add. ReferenceCounted.release() ownership of all ReferenceCounted.release()
ownership of all ByteBuf objects is transferred to this CompositeByteBuf.public CompositeByteBuf addComponent(boolean increaseWriterIndex, int cIndex, ByteBuf buffer)
ByteBuf on the specific index and increase the writerIndex
if increaseWriterIndex is true.
ReferenceCounted.release() ownership of buffer is transferred to this CompositeByteBuf.cIndex - the index on which the ByteBuf will be added.buffer - the ByteBuf to add. ReferenceCounted.release() ownership is transferred to this
CompositeByteBuf.public CompositeByteBuf addComponents(int cIndex, ByteBuf... buffers)
ByteBufs on the specific index
Be aware that this method does not increase the writerIndex of the CompositeByteBuf.
If you need to have it increased you need to handle it by your own.
ReferenceCounted.release() ownership of all ByteBuf objects in buffers is transferred to this
CompositeByteBuf.
cIndex - the index on which the ByteBuf will be added. ReferenceCounted.release() ownership of all
ReferenceCounted.release() ownership of all ByteBuf objects is transferred to this
CompositeByteBuf.buffers - the ByteBufs to add. ReferenceCounted.release() ownership of all ReferenceCounted.release()
ownership of all ByteBuf objects is transferred to this CompositeByteBuf.public CompositeByteBuf addComponents(int cIndex, java.lang.Iterable<ByteBuf> buffers)
ByteBufs on the specific index
Be aware that this method does not increase the writerIndex of the CompositeByteBuf.
If you need to have it increased you need to handle it by your own.
ReferenceCounted.release() ownership of all ByteBuf objects in buffers is transferred to this
CompositeByteBuf.
cIndex - the index on which the ByteBuf will be added.buffers - the ByteBufs to add. ReferenceCounted.release() ownership of all
ReferenceCounted.release() ownership of all ByteBuf objects is transferred to this
CompositeByteBuf.public CompositeByteBuf addFlattenedComponents(boolean increaseWriterIndex, ByteBuf buffer)
ByteBuf and increase the writerIndex if increaseWriterIndex is
true. If the provided buffer is a CompositeByteBuf itself, a "shallow copy" of its
readable components will be performed. Thus the actual number of new components added may vary
and in particular will be zero if the provided buffer is not readable.
ReferenceCounted.release() ownership of buffer is transferred to this CompositeByteBuf.
buffer - the ByteBuf to add. ReferenceCounted.release() ownership is transferred to this
CompositeByteBuf.public CompositeByteBuf removeComponent(int cIndex)
ByteBuf from the given index.cIndex - the index on from which the ByteBuf will be removepublic CompositeByteBuf removeComponents(int cIndex, int numComponents)
ByteBufs starting from the given index.cIndex - the index on which the ByteBufs will be started to removednumComponents - the number of components to removepublic java.util.Iterator<ByteBuf> iterator()
iterator 在接口中 java.lang.Iterable<ByteBuf>protected int forEachByteAsc0(int start,
int end,
ByteProcessor processor)
throws java.lang.Exception
java.lang.Exceptionprotected int forEachByteDesc0(int rStart,
int rEnd,
ByteProcessor processor)
throws java.lang.Exception
java.lang.Exceptionpublic java.util.List<ByteBuf> decompose(int offset, int length)
AbstractByteBuf.slice(int, int) except that this method returns a list.public boolean isDirect()
ByteBuftrue if and only if this buffer is backed by an
NIO direct buffer.public boolean hasArray()
ByteBuftrue if and only if this buffer has a backing byte array.
If this method returns true, you can safely call ByteBuf.array() and
ByteBuf.arrayOffset().public byte[] array()
ByteBufpublic int arrayOffset()
ByteBufarrayOffset 在类中 ByteBufpublic boolean hasMemoryAddress()
ByteBuftrue if and only if this buffer has a reference to the low-level memory address that points
to the backing data.hasMemoryAddress 在类中 ByteBufpublic long memoryAddress()
ByteBufmemoryAddress 在类中 ByteBufpublic int capacity()
ByteBufpublic CompositeByteBuf capacity(int newCapacity)
ByteBufnewCapacity 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 ByteBufAllocator alloc()
ByteBufByteBufAllocator which created this buffer.public java.nio.ByteOrder order()
ByteBufpublic int numComponents()
ByteBuf's that are composed in this instancepublic int maxNumComponents()
ByteBuf's that are composed in this instancepublic int toComponentIndex(int offset)
public int toByteIndex(int cIndex)
public byte getByte(int index)
ByteBufindex in this buffer.
This method does not modify readerIndex or writerIndex of
this buffer.getByte 在类中 AbstractByteBufprotected byte _getByte(int index)
_getByte 在类中 AbstractByteBufprotected short _getShort(int index)
_getShort 在类中 AbstractByteBufprotected short _getShortLE(int index)
_getShortLE 在类中 AbstractByteBufprotected int _getUnsignedMedium(int index)
_getUnsignedMedium 在类中 AbstractByteBufprotected int _getUnsignedMediumLE(int index)
_getUnsignedMediumLE 在类中 AbstractByteBufprotected int _getInt(int index)
_getInt 在类中 AbstractByteBufprotected int _getIntLE(int index)
_getIntLE 在类中 AbstractByteBufprotected long _getLong(int index)
_getLong 在类中 AbstractByteBufprotected long _getLongLE(int index)
_getLongLE 在类中 AbstractByteBufpublic CompositeByteBuf getBytes(int index, byte[] dst, int dstIndex, int length)
ByteBufindex.
This method does not modify readerIndex or writerIndex
of this buffer.public CompositeByteBuf getBytes(int index, java.nio.ByteBuffer dst)
ByteBufindex 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 CompositeByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length)
ByteBufindex.
This method does not modify readerIndex or writerIndex
of both the source (i.e. this) and the destination.public int getBytes(int index,
java.nio.channels.GatheringByteChannel out,
int length)
throws java.io.IOException
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer.public int getBytes(int index,
java.nio.channels.FileChannel out,
long position,
int length)
throws java.io.IOException
ByteBufindex
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.public CompositeByteBuf getBytes(int index, java.io.OutputStream out, int length) throws java.io.IOException
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer.public CompositeByteBuf setByte(int index, int value)
ByteBufindex 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 在类中 AbstractByteBufprotected void _setByte(int index,
int value)
_setByte 在类中 AbstractByteBufpublic CompositeByteBuf setShort(int index, int value)
ByteBufindex 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 在类中 AbstractByteBufprotected void _setShort(int index,
int value)
_setShort 在类中 AbstractByteBufprotected void _setShortLE(int index,
int value)
_setShortLE 在类中 AbstractByteBufpublic CompositeByteBuf setMedium(int index, int value)
ByteBufindex 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 在类中 AbstractByteBufprotected void _setMedium(int index,
int value)
_setMedium 在类中 AbstractByteBufprotected void _setMediumLE(int index,
int value)
_setMediumLE 在类中 AbstractByteBufpublic CompositeByteBuf setInt(int index, int value)
ByteBufindex in this buffer.
This method does not modify readerIndex or writerIndex of
this buffer.setInt 在类中 AbstractByteBufprotected void _setInt(int index,
int value)
_setInt 在类中 AbstractByteBufprotected void _setIntLE(int index,
int value)
_setIntLE 在类中 AbstractByteBufpublic CompositeByteBuf setLong(int index, long value)
ByteBufindex in this buffer.
This method does not modify readerIndex or writerIndex of
this buffer.setLong 在类中 AbstractByteBufprotected void _setLong(int index,
long value)
_setLong 在类中 AbstractByteBufprotected void _setLongLE(int index,
long value)
_setLongLE 在类中 AbstractByteBufpublic CompositeByteBuf setBytes(int index, byte[] src, int srcIndex, int length)
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer.public CompositeByteBuf setBytes(int index, java.nio.ByteBuffer src)
ByteBufindex until the source buffer's position
reaches its limit.
This method does not modify readerIndex or writerIndex of
this buffer.public CompositeByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length)
ByteBufindex.
This method does not modify readerIndex or writerIndex
of both the source (i.e. this) and the destination.public int setBytes(int index,
java.io.InputStream in,
int length)
throws java.io.IOException
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer.public int setBytes(int index,
java.nio.channels.ScatteringByteChannel in,
int length)
throws java.io.IOException
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer.public int setBytes(int index,
java.nio.channels.FileChannel in,
long position,
int length)
throws java.io.IOException
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer. This method does not modify the channel's position.setBytes 在类中 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 or it reached EOF.java.io.IOException - if the specified channel threw an exception during I/Opublic ByteBuf copy(int index, int length)
ByteBufreaderIndex or writerIndex of
this buffer.public ByteBuf componentAtOffset(int offset)
ByteBuf on the specified indexpublic ByteBuf internalComponent(int cIndex)
ByteBuf on the specified index. Note that updating the indexes of the returned
buffer will lead to an undefined behavior of this buffer.cIndex - the index for which the ByteBuf should be returnedpublic ByteBuf internalComponentAtOffset(int offset)
ByteBuf on the specified offset. Note that updating the indexes of the returned
buffer will lead to an undefined behavior of this buffer.offset - the offset for which the ByteBuf should be returnedpublic int nioBufferCount()
ByteBufByteBuffers that consist this buffer. Note that ByteBuf.nioBuffers()
or ByteBuf.nioBuffers(int, int) might return a less number of ByteBuffers.nioBufferCount 在类中 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.ByteBuf.nioBuffer(),
ByteBuf.nioBuffer(int, int),
ByteBuf.nioBuffers(),
ByteBuf.nioBuffers(int, int)public java.nio.ByteBuffer internalNioBuffer(int index,
int length)
ByteBufinternalNioBuffer 在类中 ByteBufpublic java.nio.ByteBuffer nioBuffer(int index,
int length)
ByteBufByteBuffer. 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.public java.nio.ByteBuffer[] nioBuffers(int index,
int length)
ByteBufByteBuffer'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.public CompositeByteBuf consolidate()
ByteBufspublic CompositeByteBuf consolidate(int cIndex, int numComponents)
ByteBufscIndex - the index on which to start to composenumComponents - the number of components to composepublic CompositeByteBuf discardReadComponents()
ByteBufs which are read.public CompositeByteBuf discardReadBytes()
ByteBufreaderIndex.
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 在类中 AbstractByteBufpublic java.lang.String toString()
ByteBufByteBuf.readerIndex(),
ByteBuf.writerIndex() and ByteBuf.capacity().toString 在类中 AbstractByteBufpublic CompositeByteBuf readerIndex(int readerIndex)
ByteBufreaderIndex of this buffer.readerIndex 在类中 AbstractByteBufpublic CompositeByteBuf writerIndex(int writerIndex)
ByteBufwriterIndex of this buffer.writerIndex 在类中 AbstractByteBufpublic CompositeByteBuf setIndex(int readerIndex, int writerIndex)
ByteBufreaderIndex and writerIndex of this buffer
in one shot. This method is useful when you have to worry about the
invocation order of ByteBuf.readerIndex(int) and ByteBuf.writerIndex(int)
methods. For example, the following code will fail:
// Create a buffer whose readerIndex, writerIndex and capacity are // 0, 0 and 8 respectively.The following code will also fail: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);
// Create a buffer whose readerIndex, writerIndex and capacity are // 0, 8 and 8 respectively.By contrast, this method guarantees that it never throws anByteBufbuf =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);
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 在类中 AbstractByteBufpublic CompositeByteBuf clear()
ByteBufreaderIndex 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 在类中 AbstractByteBufpublic CompositeByteBuf markReaderIndex()
ByteBufreaderIndex in this buffer. You can
reposition the current readerIndex to the marked
readerIndex by calling ByteBuf.resetReaderIndex().
The initial value of the marked readerIndex is 0.markReaderIndex 在类中 AbstractByteBufpublic CompositeByteBuf resetReaderIndex()
ByteBufreaderIndex to the marked
readerIndex in this buffer.resetReaderIndex 在类中 AbstractByteBufpublic CompositeByteBuf markWriterIndex()
ByteBufwriterIndex in this buffer. You can
reposition the current writerIndex to the marked
writerIndex by calling ByteBuf.resetWriterIndex().
The initial value of the marked writerIndex is 0.markWriterIndex 在类中 AbstractByteBufpublic CompositeByteBuf resetWriterIndex()
ByteBufwriterIndex to the marked
writerIndex in this buffer.resetWriterIndex 在类中 AbstractByteBufpublic CompositeByteBuf ensureWritable(int minWritableBytes)
ByteBufByteBuf.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 在类中 AbstractByteBufminWritableBytes - the expected minimum number of writable bytesByteBuf.capacity(int)public CompositeByteBuf getBytes(int index, ByteBuf dst)
ByteBufindex until the destination becomes
non-writable. This method is basically same with
ByteBuf.getBytes(int, ByteBuf, int, int), except that this
method increases the writerIndex of the destination by the
number of the transferred bytes while
ByteBuf.getBytes(int, ByteBuf, int, int) does not.
This method does not modify readerIndex or writerIndex of
the source buffer (i.e. this).getBytes 在类中 AbstractByteBufpublic CompositeByteBuf getBytes(int index, ByteBuf dst, int length)
ByteBufindex. This method is basically same
with ByteBuf.getBytes(int, ByteBuf, int, int), except that this
method increases the writerIndex of the destination by the
number of the transferred bytes while
ByteBuf.getBytes(int, ByteBuf, int, int) does not.
This method does not modify readerIndex or writerIndex of
the source buffer (i.e. this).getBytes 在类中 AbstractByteBuflength - the number of bytes to transferpublic CompositeByteBuf getBytes(int index, byte[] dst)
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffergetBytes 在类中 AbstractByteBufpublic CompositeByteBuf setBoolean(int index, boolean value)
ByteBufindex in this
buffer.
This method does not modify readerIndex or writerIndex of
this buffer.setBoolean 在类中 AbstractByteBufpublic CompositeByteBuf setChar(int index, int value)
ByteBufindex 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 在类中 AbstractByteBufpublic CompositeByteBuf setFloat(int index, float value)
ByteBufindex in this buffer.
This method does not modify readerIndex or writerIndex of
this buffer.setFloat 在类中 AbstractByteBufpublic CompositeByteBuf setDouble(int index, double value)
ByteBufindex in this buffer.
This method does not modify readerIndex or writerIndex of
this buffer.setDouble 在类中 AbstractByteBufpublic CompositeByteBuf setBytes(int index, ByteBuf src)
ByteBufindex until the source buffer becomes
unreadable. This method is basically same with
ByteBuf.setBytes(int, ByteBuf, int, int), except that this
method increases the readerIndex of the source buffer by
the number of the transferred bytes while
ByteBuf.setBytes(int, ByteBuf, int, int) does not.
This method does not modify readerIndex or writerIndex of
this buffer (i.e. this).setBytes 在类中 AbstractByteBufpublic CompositeByteBuf setBytes(int index, ByteBuf src, int length)
ByteBufindex. This method is basically same
with ByteBuf.setBytes(int, ByteBuf, int, int), except that this
method increases the readerIndex of the source buffer by
the number of the transferred bytes while
ByteBuf.setBytes(int, ByteBuf, int, int) does not.
This method does not modify readerIndex or writerIndex of
this buffer (i.e. this).setBytes 在类中 AbstractByteBuflength - the number of bytes to transferpublic CompositeByteBuf setBytes(int index, byte[] src)
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer.setBytes 在类中 AbstractByteBufpublic CompositeByteBuf setZero(int index, int length)
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer.setZero 在类中 AbstractByteBuflength - the number of NULs to write to the bufferpublic CompositeByteBuf readBytes(ByteBuf dst)
ByteBufreaderIndex until the destination becomes
non-writable, and increases the readerIndex by the number of the
transferred bytes. This method is basically same with
ByteBuf.readBytes(ByteBuf, int, int), except that this method
increases the writerIndex of the destination by the number of
the transferred bytes while ByteBuf.readBytes(ByteBuf, int, int)
does not.readBytes 在类中 AbstractByteBufpublic CompositeByteBuf readBytes(ByteBuf dst, int length)
ByteBufreaderIndex and increases the readerIndex
by the number of the transferred bytes (= length). This method
is basically same with ByteBuf.readBytes(ByteBuf, int, int),
except that this method increases the writerIndex of the
destination by the number of the transferred bytes (= length)
while ByteBuf.readBytes(ByteBuf, int, int) does not.readBytes 在类中 AbstractByteBufpublic CompositeByteBuf readBytes(ByteBuf dst, int dstIndex, int length)
ByteBufreaderIndex and increases the readerIndex
by the number of the transferred bytes (= length).readBytes 在类中 AbstractByteBufdstIndex - the first index of the destinationlength - the number of bytes to transferpublic CompositeByteBuf readBytes(byte[] dst)
ByteBufreaderIndex and increases the readerIndex
by the number of the transferred bytes (= dst.length).readBytes 在类中 AbstractByteBufpublic CompositeByteBuf readBytes(byte[] dst, int dstIndex, int length)
ByteBufreaderIndex and increases the readerIndex
by the number of the transferred bytes (= length).readBytes 在类中 AbstractByteBufdstIndex - the first index of the destinationlength - the number of bytes to transferpublic CompositeByteBuf readBytes(java.nio.ByteBuffer dst)
ByteBufreaderIndex until the destination's position
reaches its limit, and increases the readerIndex by the
number of the transferred bytes.readBytes 在类中 AbstractByteBufpublic CompositeByteBuf readBytes(java.io.OutputStream out, int length) throws java.io.IOException
ByteBufreaderIndex.readBytes 在类中 AbstractByteBuflength - the number of bytes to transferjava.io.IOException - if the specified stream threw an exception during I/Opublic CompositeByteBuf skipBytes(int length)
ByteBufreaderIndex by the specified
length in this buffer.skipBytes 在类中 AbstractByteBufpublic CompositeByteBuf writeBoolean(boolean value)
ByteBufwriterIndex
and increases the writerIndex by 1 in this buffer.
If this.writableBytes is less than 1, ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeBoolean 在类中 AbstractByteBufpublic CompositeByteBuf writeByte(int value)
ByteBufwriterIndex
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, ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeByte 在类中 AbstractByteBufpublic CompositeByteBuf writeShort(int value)
ByteBufwriterIndex 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, ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeShort 在类中 AbstractByteBufpublic CompositeByteBuf writeMedium(int value)
ByteBufwriterIndex and increases the writerIndex by 3
in this buffer.
If this.writableBytes is less than 3, ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeMedium 在类中 AbstractByteBufpublic CompositeByteBuf writeInt(int value)
ByteBufwriterIndex
and increases the writerIndex by 4 in this buffer.
If this.writableBytes is less than 4, ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeInt 在类中 AbstractByteBufpublic CompositeByteBuf writeLong(long value)
ByteBufwriterIndex and increases the writerIndex by 8
in this buffer.
If this.writableBytes is less than 8, ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeLong 在类中 AbstractByteBufpublic CompositeByteBuf writeChar(int value)
ByteBufwriterIndex 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, ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeChar 在类中 AbstractByteBufpublic CompositeByteBuf writeFloat(float value)
ByteBufwriterIndex and increases the writerIndex by 4
in this buffer.
If this.writableBytes is less than 4, ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeFloat 在类中 AbstractByteBufpublic CompositeByteBuf writeDouble(double value)
ByteBufwriterIndex and increases the writerIndex by 8
in this buffer.
If this.writableBytes is less than 8, ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeDouble 在类中 AbstractByteBufpublic CompositeByteBuf writeBytes(ByteBuf src)
ByteBufwriterIndex until the source buffer becomes
unreadable, and increases the writerIndex by the number of
the transferred bytes. This method is basically same with
ByteBuf.writeBytes(ByteBuf, int, int), except that this method
increases the readerIndex of the source buffer by the number of
the transferred bytes while ByteBuf.writeBytes(ByteBuf, int, int)
does not.
If this.writableBytes is less than src.readableBytes,
ByteBuf.ensureWritable(int) will be called in an attempt to expand
capacity to accommodate.writeBytes 在类中 AbstractByteBufpublic CompositeByteBuf writeBytes(ByteBuf src, int length)
ByteBufwriterIndex and increases the writerIndex
by the number of the transferred bytes (= length). This method
is basically same with ByteBuf.writeBytes(ByteBuf, int, int),
except that this method increases the readerIndex of the source
buffer by the number of the transferred bytes (= length) while
ByteBuf.writeBytes(ByteBuf, int, int) does not.
If this.writableBytes is less than length, ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeBytes 在类中 AbstractByteBuflength - the number of bytes to transferpublic CompositeByteBuf writeBytes(ByteBuf src, int srcIndex, int length)
ByteBufwriterIndex and increases the writerIndex
by the number of the transferred bytes (= length).
If this.writableBytes is less than length, ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeBytes 在类中 AbstractByteBufsrcIndex - the first index of the sourcelength - the number of bytes to transferpublic CompositeByteBuf writeBytes(byte[] src)
ByteBufwriterIndex and increases the writerIndex
by the number of the transferred bytes (= src.length).
If this.writableBytes is less than src.length, ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeBytes 在类中 AbstractByteBufpublic CompositeByteBuf writeBytes(byte[] src, int srcIndex, int length)
ByteBufwriterIndex and increases the writerIndex
by the number of the transferred bytes (= length).
If this.writableBytes is less than length, ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeBytes 在类中 AbstractByteBufsrcIndex - the first index of the sourcelength - the number of bytes to transferpublic CompositeByteBuf writeBytes(java.nio.ByteBuffer src)
ByteBufwriterIndex 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(),
ByteBuf.ensureWritable(int) will be called in an attempt to expand
capacity to accommodate.writeBytes 在类中 AbstractByteBufpublic CompositeByteBuf writeZero(int length)
ByteBufwriterIndex and increases the writerIndex by the
specified length.
If this.writableBytes is less than length, ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeZero 在类中 AbstractByteBuflength - the number of NULs to write to the bufferpublic CompositeByteBuf retain(int increment)
ReferenceCountedincrement.retain 在接口中 ReferenceCountedretain 在类中 AbstractReferenceCountedByteBufpublic CompositeByteBuf retain()
ReferenceCounted1.retain 在接口中 ReferenceCountedretain 在类中 AbstractReferenceCountedByteBufpublic CompositeByteBuf touch()
ReferenceCountedResourceLeakDetector. This method is a shortcut to touch(null).touch 在接口中 ReferenceCountedtouch 在类中 AbstractReferenceCountedByteBufpublic CompositeByteBuf touch(java.lang.Object hint)
ReferenceCountedResourceLeakDetector.touch 在接口中 ReferenceCountedtouch 在类中 AbstractReferenceCountedByteBufpublic java.nio.ByteBuffer[] nioBuffers()
ByteBufByteBuffer'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.public CompositeByteBuf discardSomeReadBytes()
ByteBufByteBuf.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 在类中 AbstractByteBufprotected void deallocate()
AbstractReferenceCountedByteBufAbstractReferenceCountedByteBuf.refCnt() is equals 0.