public class CompositeByteBuf extends AbstractReferenceCountedByteBuf implements Iterable<ByteBuf>
ByteBufAllocator.compositeBuffer()
or Unpooled.wrappedBuffer(ByteBuf...)
instead of calling the
constructor explicitly.Constructor and Description |
---|
CompositeByteBuf(ByteBufAllocator alloc,
boolean direct,
int maxNumComponents) |
CompositeByteBuf(ByteBufAllocator alloc,
boolean direct,
int maxNumComponents,
ByteBuf... buffers) |
CompositeByteBuf(ByteBufAllocator alloc,
boolean direct,
int maxNumComponents,
Iterable<ByteBuf> buffers) |
Modifier and Type | Method and Description |
---|---|
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,
Iterable<ByteBuf> buffers)
|
CompositeByteBuf |
addComponents(ByteBuf... buffers)
Add the given
ByteBuf s. |
CompositeByteBuf |
addComponents(int cIndex,
ByteBuf... buffers)
Add the given
ByteBuf s on the specific index
Be aware that this method does not increase the writerIndex of the CompositeByteBuf . |
CompositeByteBuf |
addComponents(int cIndex,
Iterable<ByteBuf> buffers)
Add the given
ByteBuf s on the specific index
Be aware that this method does not increase the writerIndex of the CompositeByteBuf . |
CompositeByteBuf |
addComponents(Iterable<ByteBuf> buffers)
Add the given
ByteBuf s. |
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
ByteBuf s |
CompositeByteBuf |
consolidate(int cIndex,
int numComponents)
Consolidate the composed
ByteBuf s |
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. |
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
ByteBuf s 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,
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,
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,
GatheringByteChannel out,
int length)
Transfers this buffer's data to the specified channel starting at the
specified absolute
index . |
CompositeByteBuf |
getBytes(int index,
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. |
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. |
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.
|
ByteBuffer |
nioBuffer(int index,
int length)
Exposes this buffer's sub-region as an NIO
ByteBuffer . |
int |
nioBufferCount()
Returns the maximum number of NIO
ByteBuffer s that consist this buffer. |
ByteBuffer[] |
nioBuffers()
Exposes this buffer's readable bytes as an NIO
ByteBuffer 's. |
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 |
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(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(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
ByteBuf s 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,
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,
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,
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,
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
|
String |
toString()
Returns the string representation of this buffer.
|
CompositeByteBuf |
touch()
Records the current access location of this object for debugging purposes.
|
CompositeByteBuf |
touch(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(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, setRefCnt
adjustMarkers, 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, writeShortLE
asByteBuf, getDoubleLE, getFloatLE, isContiguous, maxFastWritableBytes, readDoubleLE, readFloatLE, setDoubleLE, setFloatLE, writeDoubleLE, writeFloatLE
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public 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, 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)
ByteBuf
s.
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 ByteBuf
s to add. ReferenceCounted.release()
ownership of all ReferenceCounted.release()
ownership of all ByteBuf
objects is transferred to this CompositeByteBuf
.public CompositeByteBuf addComponents(Iterable<ByteBuf> buffers)
ByteBuf
s.
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 ByteBuf
s 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)
ByteBuf
s and increase the writerIndex
if increaseWriterIndex
is
true
.
ReferenceCounted.release()
ownership of all ByteBuf
objects in buffers
is transferred to this
CompositeByteBuf
.buffers
- the ByteBuf
s to add. ReferenceCounted.release()
ownership of all ReferenceCounted.release()
ownership of all ByteBuf
objects is transferred to this CompositeByteBuf
.public CompositeByteBuf addComponents(boolean increaseWriterIndex, Iterable<ByteBuf> buffers)
ByteBuf
s and increase the writerIndex
if increaseWriterIndex
is
true
.
ReferenceCounted.release()
ownership of all ByteBuf
objects in buffers
is transferred to this
CompositeByteBuf
.buffers
- the ByteBuf
s 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)
ByteBuf
s 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 ByteBuf
s to add. ReferenceCounted.release()
ownership of all ReferenceCounted.release()
ownership of all ByteBuf
objects is transferred to this CompositeByteBuf
.public CompositeByteBuf addComponents(int cIndex, Iterable<ByteBuf> buffers)
ByteBuf
s 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 ByteBuf
s 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)
ByteBuf
s starting from the given index.cIndex
- the index on which the ByteBuf
s will be started to removednumComponents
- the number of components to removeprotected int forEachByteAsc0(int start, int end, ByteProcessor processor) throws Exception
Exception
protected int forEachByteDesc0(int rStart, int rEnd, ByteProcessor processor) throws Exception
Exception
public List<ByteBuf> decompose(int offset, int length)
AbstractByteBuf.slice(int, int)
except that this method returns a list.public boolean isDirect()
ByteBuf
true
if and only if this buffer is backed by an
NIO direct buffer.public boolean hasArray()
ByteBuf
true
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()
ByteBuf
public int arrayOffset()
ByteBuf
arrayOffset
in class ByteBuf
public boolean hasMemoryAddress()
ByteBuf
true
if and only if this buffer has a reference to the low-level memory address that points
to the backing data.hasMemoryAddress
in class ByteBuf
public long memoryAddress()
ByteBuf
memoryAddress
in class ByteBuf
public int capacity()
ByteBuf
public CompositeByteBuf capacity(int newCapacity)
ByteBuf
newCapacity
is less than the current
capacity, the content of this buffer is truncated. If the newCapacity
is greater
than the current capacity, the buffer is appended with unspecified data whose length is
(newCapacity - currentCapacity)
.public ByteBufAllocator alloc()
ByteBuf
ByteBufAllocator
which created this buffer.public ByteOrder order()
ByteBuf
public 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)
ByteBuf
index
in this buffer.
This method does not modify readerIndex
or writerIndex
of
this buffer.getByte
in class AbstractByteBuf
protected byte _getByte(int index)
_getByte
in class AbstractByteBuf
protected short _getShort(int index)
_getShort
in class AbstractByteBuf
protected short _getShortLE(int index)
_getShortLE
in class AbstractByteBuf
protected int _getUnsignedMedium(int index)
_getUnsignedMedium
in class AbstractByteBuf
protected int _getUnsignedMediumLE(int index)
_getUnsignedMediumLE
in class AbstractByteBuf
protected int _getInt(int index)
_getInt
in class AbstractByteBuf
protected int _getIntLE(int index)
_getIntLE
in class AbstractByteBuf
protected long _getLong(int index)
_getLong
in class AbstractByteBuf
protected long _getLongLE(int index)
_getLongLE
in class AbstractByteBuf
public CompositeByteBuf getBytes(int index, byte[] dst, int dstIndex, int length)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of this buffer.public CompositeByteBuf getBytes(int index, ByteBuffer dst)
ByteBuf
index
until the destination's position
reaches its limit.
This method does not modify readerIndex
or writerIndex
of
this buffer while the destination's position
will be increased.public CompositeByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of both the source (i.e. this
) and the destination.public int getBytes(int index, GatheringByteChannel out, int length) throws IOException
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.getBytes
in class ByteBuf
length
- the maximum number of bytes to transferIOException
- if the specified channel threw an exception during I/Opublic int getBytes(int index, FileChannel out, long position, int length) throws IOException
ByteBuf
index
to the specified channel starting at the given file position.
This method does not modify readerIndex
or writerIndex
of
this buffer. This method does not modify the channel's position.getBytes
in class ByteBuf
position
- the file position at which the transfer is to beginlength
- the maximum number of bytes to transferIOException
- if the specified channel threw an exception during I/Opublic CompositeByteBuf getBytes(int index, OutputStream out, int length) throws IOException
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.getBytes
in class ByteBuf
length
- the number of bytes to transferIOException
- if the specified stream threw an exception during I/Opublic CompositeByteBuf setByte(int index, int value)
ByteBuf
index
in this
buffer. The 24 high-order bits of the specified value are ignored.
This method does not modify readerIndex
or writerIndex
of
this buffer.setByte
in class AbstractByteBuf
protected void _setByte(int index, int value)
_setByte
in class AbstractByteBuf
public CompositeByteBuf setShort(int index, int value)
ByteBuf
index
in this buffer. The 16 high-order bits of the specified
value are ignored.
This method does not modify readerIndex
or writerIndex
of
this buffer.setShort
in class AbstractByteBuf
protected void _setShort(int index, int value)
_setShort
in class AbstractByteBuf
protected void _setShortLE(int index, int value)
_setShortLE
in class AbstractByteBuf
public CompositeByteBuf setMedium(int index, int value)
ByteBuf
index
in this buffer. Please note that the most significant
byte is ignored in the specified value.
This method does not modify readerIndex
or writerIndex
of
this buffer.setMedium
in class AbstractByteBuf
protected void _setMedium(int index, int value)
_setMedium
in class AbstractByteBuf
protected void _setMediumLE(int index, int value)
_setMediumLE
in class AbstractByteBuf
public CompositeByteBuf setInt(int index, int value)
ByteBuf
index
in this buffer.
This method does not modify readerIndex
or writerIndex
of
this buffer.setInt
in class AbstractByteBuf
protected void _setInt(int index, int value)
_setInt
in class AbstractByteBuf
protected void _setIntLE(int index, int value)
_setIntLE
in class AbstractByteBuf
public CompositeByteBuf setLong(int index, long value)
ByteBuf
index
in this buffer.
This method does not modify readerIndex
or writerIndex
of
this buffer.setLong
in class AbstractByteBuf
protected void _setLong(int index, long value)
_setLong
in class AbstractByteBuf
protected void _setLongLE(int index, long value)
_setLongLE
in class AbstractByteBuf
public CompositeByteBuf setBytes(int index, byte[] src, int srcIndex, int length)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.public CompositeByteBuf setBytes(int index, ByteBuffer src)
ByteBuf
index
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)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of both the source (i.e. this
) and the destination.public int setBytes(int index, InputStream in, int length) throws IOException
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.setBytes
in class ByteBuf
length
- the number of bytes to transfer-1
if the specified InputStream
reached EOF.IOException
- if the specified stream threw an exception during I/Opublic int setBytes(int index, ScatteringByteChannel in, int length) throws IOException
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.setBytes
in class ByteBuf
length
- the maximum number of bytes to transfer-1
if the specified channel is closed or it reached EOF.IOException
- if the specified channel threw an exception during I/Opublic int setBytes(int index, FileChannel in, long position, int length) throws IOException
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer. This method does not modify the channel's position.setBytes
in class ByteBuf
position
- 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.IOException
- if the specified channel threw an exception during I/Opublic ByteBuf copy(int index, int length)
ByteBuf
readerIndex
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()
ByteBuf
ByteBuffer
s that consist this buffer. Note that ByteBuf.nioBuffers()
or ByteBuf.nioBuffers(int, int)
might return a less number of ByteBuffer
s.nioBufferCount
in class ByteBuf
-1
if this buffer has no underlying ByteBuffer
.
the number of the underlying ByteBuffer
s 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 ByteBuffer internalNioBuffer(int index, int length)
ByteBuf
internalNioBuffer
in class ByteBuf
public ByteBuffer nioBuffer(int index, int length)
ByteBuf
ByteBuffer
. The returned buffer
either share or contains the copied content of this buffer, while changing the position
and limit of the returned NIO buffer does not affect the indexes and marks of this buffer.
This method does not modify readerIndex
or writerIndex
of this buffer.
Please note that the returned NIO buffer will not see the changes of this buffer if this buffer
is a dynamic buffer and it adjusted its capacity.nioBuffer
in class ByteBuf
ByteBuf.nioBufferCount()
,
ByteBuf.nioBuffers()
,
ByteBuf.nioBuffers(int, int)
public ByteBuffer[] nioBuffers(int index, int length)
ByteBuf
ByteBuffer
's for the specified index and length
The returned buffer either share or contains the copied content of this buffer, while changing
the position and limit of the returned NIO buffer does not affect the indexes and marks of this buffer.
This method does not modify readerIndex
or writerIndex
of this buffer. Please note that the
returned NIO buffer will not see the changes of this buffer if this buffer is a dynamic
buffer and it adjusted its capacity.nioBuffers
in class ByteBuf
ByteBuf.nioBufferCount()
,
ByteBuf.nioBuffer()
,
ByteBuf.nioBuffer(int, int)
public CompositeByteBuf consolidate()
ByteBuf
spublic CompositeByteBuf consolidate(int cIndex, int numComponents)
ByteBuf
scIndex
- the index on which to start to composenumComponents
- the number of components to composepublic CompositeByteBuf discardReadComponents()
ByteBuf
s which are read.public CompositeByteBuf discardReadBytes()
ByteBuf
readerIndex
.
It moves the bytes between readerIndex
and writerIndex
to the 0th index, and sets readerIndex
and writerIndex
to 0
and oldWriterIndex - oldReaderIndex
respectively.
Please refer to the class documentation for more detailed explanation.
discardReadBytes
in class AbstractByteBuf
public String toString()
ByteBuf
ByteBuf.readerIndex()
,
ByteBuf.writerIndex()
and ByteBuf.capacity()
.toString
in class AbstractByteBuf
public CompositeByteBuf readerIndex(int readerIndex)
ByteBuf
readerIndex
of this buffer.readerIndex
in class AbstractByteBuf
public CompositeByteBuf writerIndex(int writerIndex)
ByteBuf
writerIndex
of this buffer.writerIndex
in class AbstractByteBuf
public CompositeByteBuf setIndex(int readerIndex, int writerIndex)
ByteBuf
readerIndex
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:ByteBuf
buf =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 anByteBuf
buf =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
in class AbstractByteBuf
public CompositeByteBuf clear()
ByteBuf
readerIndex
and writerIndex
of this buffer to
0
.
This method is identical to setIndex(0, 0)
.
Please note that the behavior of this method is different
from that of NIO buffer, which sets the limit
to
the capacity
of the buffer.
clear
in class AbstractByteBuf
public CompositeByteBuf markReaderIndex()
ByteBuf
readerIndex
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
in class AbstractByteBuf
public CompositeByteBuf resetReaderIndex()
ByteBuf
readerIndex
to the marked
readerIndex
in this buffer.resetReaderIndex
in class AbstractByteBuf
public CompositeByteBuf markWriterIndex()
ByteBuf
writerIndex
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
in class AbstractByteBuf
public CompositeByteBuf resetWriterIndex()
ByteBuf
writerIndex
to the marked
writerIndex
in this buffer.resetWriterIndex
in class AbstractByteBuf
public CompositeByteBuf ensureWritable(int minWritableBytes)
ByteBuf
ByteBuf.capacity()
to make sure the number of
writable bytes is equal to or greater than the
specified value. If there are enough writable bytes in this buffer, this method
returns with no side effect.ensureWritable
in class AbstractByteBuf
minWritableBytes
- the expected minimum number of writable bytesByteBuf.capacity(int)
public CompositeByteBuf getBytes(int index, ByteBuf dst)
ByteBuf
index
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
in class AbstractByteBuf
public CompositeByteBuf getBytes(int index, ByteBuf dst, int length)
ByteBuf
index
. 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
in class AbstractByteBuf
length
- the number of bytes to transferpublic CompositeByteBuf getBytes(int index, byte[] dst)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffergetBytes
in class AbstractByteBuf
public CompositeByteBuf setBoolean(int index, boolean value)
ByteBuf
index
in this
buffer.
This method does not modify readerIndex
or writerIndex
of
this buffer.setBoolean
in class AbstractByteBuf
public CompositeByteBuf setChar(int index, int value)
ByteBuf
index
in this buffer.
The 16 high-order bits of the specified value are ignored.
This method does not modify readerIndex
or writerIndex
of
this buffer.setChar
in class AbstractByteBuf
public CompositeByteBuf setFloat(int index, float value)
ByteBuf
index
in this buffer.
This method does not modify readerIndex
or writerIndex
of
this buffer.setFloat
in class AbstractByteBuf
public CompositeByteBuf setDouble(int index, double value)
ByteBuf
index
in this buffer.
This method does not modify readerIndex
or writerIndex
of
this buffer.setDouble
in class AbstractByteBuf
public CompositeByteBuf setBytes(int index, ByteBuf src)
ByteBuf
index
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
in class AbstractByteBuf
public CompositeByteBuf setBytes(int index, ByteBuf src, int length)
ByteBuf
index
. 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
in class AbstractByteBuf
length
- the number of bytes to transferpublic CompositeByteBuf setBytes(int index, byte[] src)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.setBytes
in class AbstractByteBuf
public CompositeByteBuf setZero(int index, int length)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.setZero
in class AbstractByteBuf
length
- the number of NULs to write to the bufferpublic CompositeByteBuf readBytes(ByteBuf dst)
ByteBuf
readerIndex
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
in class AbstractByteBuf
public CompositeByteBuf readBytes(ByteBuf dst, int length)
ByteBuf
readerIndex
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
in class AbstractByteBuf
public CompositeByteBuf readBytes(ByteBuf dst, int dstIndex, int length)
ByteBuf
readerIndex
and increases the readerIndex
by the number of the transferred bytes (= length
).readBytes
in class AbstractByteBuf
dstIndex
- the first index of the destinationlength
- the number of bytes to transferpublic CompositeByteBuf readBytes(byte[] dst)
ByteBuf
readerIndex
and increases the readerIndex
by the number of the transferred bytes (= dst.length
).readBytes
in class AbstractByteBuf
public CompositeByteBuf readBytes(byte[] dst, int dstIndex, int length)
ByteBuf
readerIndex
and increases the readerIndex
by the number of the transferred bytes (= length
).readBytes
in class AbstractByteBuf
dstIndex
- the first index of the destinationlength
- the number of bytes to transferpublic CompositeByteBuf readBytes(ByteBuffer dst)
ByteBuf
readerIndex
until the destination's position
reaches its limit, and increases the readerIndex
by the
number of the transferred bytes.readBytes
in class AbstractByteBuf
public CompositeByteBuf readBytes(OutputStream out, int length) throws IOException
ByteBuf
readerIndex
.readBytes
in class AbstractByteBuf
length
- the number of bytes to transferIOException
- if the specified stream threw an exception during I/Opublic CompositeByteBuf skipBytes(int length)
ByteBuf
readerIndex
by the specified
length
in this buffer.skipBytes
in class AbstractByteBuf
public CompositeByteBuf writeBoolean(boolean value)
ByteBuf
writerIndex
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
in class AbstractByteBuf
public CompositeByteBuf writeByte(int value)
ByteBuf
writerIndex
and increases the writerIndex
by 1
in this buffer.
The 24 high-order bits of the specified value are ignored.
If this.writableBytes
is less than 1
, ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeByte
in class AbstractByteBuf
public CompositeByteBuf writeShort(int value)
ByteBuf
writerIndex
and increases the writerIndex
by 2
in this buffer. The 16 high-order bits of the specified value are ignored.
If this.writableBytes
is less than 2
, ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeShort
in class AbstractByteBuf
public CompositeByteBuf writeMedium(int value)
ByteBuf
writerIndex
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
in class AbstractByteBuf
public CompositeByteBuf writeInt(int value)
ByteBuf
writerIndex
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
in class AbstractByteBuf
public CompositeByteBuf writeLong(long value)
ByteBuf
writerIndex
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
in class AbstractByteBuf
public CompositeByteBuf writeChar(int value)
ByteBuf
writerIndex
and increases the writerIndex
by 2
in this buffer. The 16 high-order bits of the specified value are ignored.
If this.writableBytes
is less than 2
, ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeChar
in class AbstractByteBuf
public CompositeByteBuf writeFloat(float value)
ByteBuf
writerIndex
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
in class AbstractByteBuf
public CompositeByteBuf writeDouble(double value)
ByteBuf
writerIndex
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
in class AbstractByteBuf
public CompositeByteBuf writeBytes(ByteBuf src)
ByteBuf
writerIndex
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
in class AbstractByteBuf
public CompositeByteBuf writeBytes(ByteBuf src, int length)
ByteBuf
writerIndex
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
in class AbstractByteBuf
length
- the number of bytes to transferpublic CompositeByteBuf writeBytes(ByteBuf src, int srcIndex, int length)
ByteBuf
writerIndex
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
in class AbstractByteBuf
srcIndex
- the first index of the sourcelength
- the number of bytes to transferpublic CompositeByteBuf writeBytes(byte[] src)
ByteBuf
writerIndex
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
in class AbstractByteBuf
public CompositeByteBuf writeBytes(byte[] src, int srcIndex, int length)
ByteBuf
writerIndex
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
in class AbstractByteBuf
srcIndex
- the first index of the sourcelength
- the number of bytes to transferpublic CompositeByteBuf writeBytes(ByteBuffer src)
ByteBuf
writerIndex
until the source buffer's position
reaches its limit, and increases the writerIndex
by the
number of the transferred bytes.
If this.writableBytes
is less than src.remaining()
,
ByteBuf.ensureWritable(int)
will be called in an attempt to expand
capacity to accommodate.writeBytes
in class AbstractByteBuf
public CompositeByteBuf writeZero(int length)
ByteBuf
writerIndex
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
in class AbstractByteBuf
length
- the number of NULs to write to the bufferpublic CompositeByteBuf retain(int increment)
ReferenceCounted
increment
.retain
in interface ReferenceCounted
retain
in class AbstractReferenceCountedByteBuf
public CompositeByteBuf retain()
ReferenceCounted
1
.retain
in interface ReferenceCounted
retain
in class AbstractReferenceCountedByteBuf
public CompositeByteBuf touch()
ReferenceCounted
ResourceLeakDetector
. This method is a shortcut to touch(null)
.touch
in interface ReferenceCounted
touch
in class AbstractReferenceCountedByteBuf
public CompositeByteBuf touch(Object hint)
ReferenceCounted
ResourceLeakDetector
.touch
in interface ReferenceCounted
touch
in class AbstractReferenceCountedByteBuf
public ByteBuffer[] nioBuffers()
ByteBuf
ByteBuffer
's. The returned buffer
either share or contains the copied content of this buffer, while changing the position
and limit of the returned NIO buffer does not affect the indexes and marks of this buffer.
This method does not modify readerIndex
or writerIndex
of this buffer.
Please note that the returned NIO buffer will not see the changes of this buffer if this buffer
is a dynamic buffer and it adjusted its capacity.nioBuffers
in class AbstractByteBuf
ByteBuf.nioBufferCount()
,
ByteBuf.nioBuffer()
,
ByteBuf.nioBuffer(int, int)
public CompositeByteBuf discardSomeReadBytes()
ByteBuf
ByteBuf.discardReadBytes()
except that this method might discard
some, all, or none of read bytes depending on its internal implementation to reduce
overall memory bandwidth consumption at the cost of potentially additional memory
consumption.discardSomeReadBytes
in class AbstractByteBuf
protected void deallocate()
AbstractReferenceCountedByteBuf
AbstractReferenceCountedByteBuf.refCnt()
is equals 0.deallocate
in class AbstractReferenceCountedByteBuf
Copyright © 2008–2024 The Netty Project. All rights reserved.