Class CompositeByteBuf
- java.lang.Object
-
- io.netty.buffer.ByteBuf
-
- io.netty.buffer.AbstractByteBuf
-
- io.netty.buffer.AbstractReferenceCountedByteBuf
-
- io.netty.buffer.CompositeByteBuf
-
- All Implemented Interfaces:
ByteBufConvertible
,ReferenceCounted
,java.lang.Comparable<ByteBuf>
,java.lang.Iterable<ByteBuf>
public class CompositeByteBuf extends AbstractReferenceCountedByteBuf implements java.lang.Iterable<ByteBuf>
A virtual buffer which shows multiple buffers as a single merged buffer. It is recommended to useByteBufAllocator.compositeBuffer()
orUnpooled.wrappedBuffer(ByteBuf...)
instead of calling the constructor explicitly.
-
-
Constructor Summary
Constructors Constructor Description 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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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, int cIndex, ByteBuf buffer)
Add the givenByteBuf
on the specific index and increase thewriterIndex
ifincreaseWriterIndex
istrue
.CompositeByteBuf
addComponent(boolean increaseWriterIndex, ByteBuf buffer)
CompositeByteBuf
addComponent(int cIndex, ByteBuf buffer)
Add the givenByteBuf
on the specific index.CompositeByteBuf
addComponent(ByteBuf buffer)
Add the givenByteBuf
.CompositeByteBuf
addComponents(boolean increaseWriterIndex, ByteBuf... buffers)
CompositeByteBuf
addComponents(boolean increaseWriterIndex, java.lang.Iterable<ByteBuf> buffers)
CompositeByteBuf
addComponents(int cIndex, ByteBuf... buffers)
Add the givenByteBuf
s on the specific indexCompositeByteBuf
addComponents(int cIndex, java.lang.Iterable<ByteBuf> buffers)
Add the givenByteBuf
s on the specific index Be aware that this method does not increase thewriterIndex
of theCompositeByteBuf
.CompositeByteBuf
addComponents(ByteBuf... buffers)
Add the givenByteBuf
s.CompositeByteBuf
addComponents(java.lang.Iterable<ByteBuf> buffers)
Add the givenByteBuf
s.CompositeByteBuf
addFlattenedComponents(boolean increaseWriterIndex, ByteBuf buffer)
ByteBufAllocator
alloc()
Returns theByteBufAllocator
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 thereaderIndex
andwriterIndex
of this buffer to0
.ByteBuf
component(int cIndex)
Return theByteBuf
on the specified indexByteBuf
componentAtOffset(int offset)
Return theByteBuf
on the specified indexCompositeByteBuf
consolidate()
Consolidate the composedByteBuf
sCompositeByteBuf
consolidate(int cIndex, int numComponents)
Consolidate the composedByteBuf
sByteBuf
copy(int index, int length)
Returns a copy of this buffer's sub-region.protected void
deallocate()
Called onceAbstractReferenceCountedByteBuf.refCnt()
is equals 0.java.util.List<ByteBuf>
decompose(int offset, int length)
Same withAbstractByteBuf.slice(int, int)
except that this method returns a list.CompositeByteBuf
discardReadBytes()
Discards the bytes between the 0th index andreaderIndex
.CompositeByteBuf
discardReadComponents()
Discard allByteBuf
s which are read.CompositeByteBuf
discardSomeReadBytes()
Similar toByteBuf.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 bufferByteBuf.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 absoluteindex
in this buffer.CompositeByteBuf
getBytes(int index, byte[] dst)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.CompositeByteBuf
getBytes(int index, byte[] dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.CompositeByteBuf
getBytes(int index, ByteBuf dst)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
until the destination becomes non-writable.CompositeByteBuf
getBytes(int index, ByteBuf dst, int length)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.CompositeByteBuf
getBytes(int index, ByteBuf dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.CompositeByteBuf
getBytes(int index, java.io.OutputStream out, int length)
Transfers this buffer's data to the specified stream starting at the specified absoluteindex
.CompositeByteBuf
getBytes(int index, java.nio.ByteBuffer dst)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
until the destination's position reaches its limit.int
getBytes(int index, java.nio.channels.FileChannel out, long position, int length)
Transfers this buffer's data starting at the specified absoluteindex
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 absoluteindex
.boolean
hasArray()
Returnstrue
if and only if this buffer has a backing byte array.boolean
hasMemoryAddress()
Returnstrue
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 internalByteBuf
on the specified index.ByteBuf
internalComponentAtOffset(int offset)
Return the internalByteBuf
on the specified offset.java.nio.ByteBuffer
internalNioBuffer(int index, int length)
Internal use only: Exposes the internal NIO buffer.boolean
isDirect()
Returnstrue
if and only if this buffer is backed by an NIO direct buffer.java.util.Iterator<ByteBuf>
iterator()
CompositeByteBuf
markReaderIndex()
Marks the currentreaderIndex
in this buffer.CompositeByteBuf
markWriterIndex()
Marks the currentwriterIndex
in this buffer.int
maxNumComponents()
Return the max number ofByteBuf
's that are composed in this instancelong
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 NIOByteBuffer
.int
nioBufferCount()
Returns the maximum number of NIOByteBuffer
s that consist this buffer.java.nio.ByteBuffer[]
nioBuffers()
Exposes this buffer's readable bytes as an NIOByteBuffer
's.java.nio.ByteBuffer[]
nioBuffers(int index, int length)
Exposes this buffer's bytes as an NIOByteBuffer
'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 ofByteBuf
's that are composed in this instancejava.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 currentreaderIndex
and increases thereaderIndex
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 currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).CompositeByteBuf
readBytes(ByteBuf dst)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
until the destination becomes non-writable, and increases thereaderIndex
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 currentreaderIndex
and increases thereaderIndex
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 currentreaderIndex
and increases thereaderIndex
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 currentreaderIndex
.CompositeByteBuf
readBytes(java.nio.ByteBuffer dst)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
until the destination's position reaches its limit, and increases thereaderIndex
by the number of the transferred bytes.CompositeByteBuf
readerIndex(int readerIndex)
Sets thereaderIndex
of this buffer.CompositeByteBuf
removeComponent(int cIndex)
Remove theByteBuf
from the given index.CompositeByteBuf
removeComponents(int cIndex, int numComponents)
Remove the number ofByteBuf
s starting from the given index.CompositeByteBuf
resetReaderIndex()
Repositions the currentreaderIndex
to the markedreaderIndex
in this buffer.CompositeByteBuf
resetWriterIndex()
Repositions the currentwriterIndex
to the markedwriterIndex
in this buffer.CompositeByteBuf
retain()
Increases the reference count by1
.CompositeByteBuf
retain(int increment)
Increases the reference count by the specifiedincrement
.CompositeByteBuf
setBoolean(int index, boolean value)
Sets the specified boolean at the specified absoluteindex
in this buffer.CompositeByteBuf
setByte(int index, int value)
Sets the specified byte at the specified absoluteindex
in this buffer.CompositeByteBuf
setBytes(int index, byte[] src)
Transfers the specified source array's data to this buffer starting at the specified absoluteindex
.CompositeByteBuf
setBytes(int index, byte[] src, int srcIndex, int length)
Transfers the specified source array's data to this buffer starting at the specified absoluteindex
.CompositeByteBuf
setBytes(int index, ByteBuf src)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
until the source buffer becomes unreadable.CompositeByteBuf
setBytes(int index, ByteBuf src, int length)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
.CompositeByteBuf
setBytes(int index, ByteBuf src, int srcIndex, int length)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
.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 absoluteindex
.CompositeByteBuf
setBytes(int index, java.nio.ByteBuffer src)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
until the source buffer's position reaches its limit.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 absoluteindex
.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 absoluteindex
.CompositeByteBuf
setChar(int index, int value)
Sets the specified 2-byte UTF-16 character at the specified absoluteindex
in this buffer.CompositeByteBuf
setDouble(int index, double value)
Sets the specified 64-bit floating-point number at the specified absoluteindex
in this buffer.CompositeByteBuf
setFloat(int index, float value)
Sets the specified 32-bit floating-point number at the specified absoluteindex
in this buffer.CompositeByteBuf
setIndex(int readerIndex, int writerIndex)
Sets thereaderIndex
andwriterIndex
of this buffer in one shot.CompositeByteBuf
setInt(int index, int value)
Sets the specified 32-bit integer at the specified absoluteindex
in this buffer.CompositeByteBuf
setLong(int index, long value)
Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer.CompositeByteBuf
setMedium(int index, int value)
Sets the specified 24-bit medium integer at the specified absoluteindex
in this buffer.CompositeByteBuf
setShort(int index, int value)
Sets the specified 16-bit short integer at the specified absoluteindex
in this buffer.CompositeByteBuf
setZero(int index, int length)
Fills this buffer with NUL (0x00) starting at the specified absoluteindex
.CompositeByteBuf
skipBytes(int length)
Increases the currentreaderIndex
by the specifiedlength
in this buffer.int
toByteIndex(int cIndex)
int
toComponentIndex(int offset)
Return the index for the given offsetjava.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 currentwriterIndex
and increases thewriterIndex
by1
in this buffer.CompositeByteBuf
writeByte(int value)
Sets the specified byte at the currentwriterIndex
and increases thewriterIndex
by1
in this buffer.CompositeByteBuf
writeBytes(byte[] src)
Transfers the specified source array's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
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 currentwriterIndex
and increases thewriterIndex
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 currentwriterIndex
until the source buffer becomes unreadable, and increases thewriterIndex
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 currentwriterIndex
and increases thewriterIndex
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 currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
).CompositeByteBuf
writeBytes(java.nio.ByteBuffer src)
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
until the source buffer's position reaches its limit, and increases thewriterIndex
by the number of the transferred bytes.CompositeByteBuf
writeChar(int value)
Sets the specified 2-byte UTF-16 character at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer.CompositeByteBuf
writeDouble(double value)
Sets the specified 64-bit floating point number at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer.CompositeByteBuf
writeFloat(float value)
Sets the specified 32-bit floating point number at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer.CompositeByteBuf
writeInt(int value)
Sets the specified 32-bit integer at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer.CompositeByteBuf
writeLong(long value)
Sets the specified 64-bit long integer at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer.CompositeByteBuf
writeMedium(int value)
Sets the specified 24-bit medium integer at the currentwriterIndex
and increases thewriterIndex
by3
in this buffer.CompositeByteBuf
writerIndex(int writerIndex)
Sets thewriterIndex
of this buffer.CompositeByteBuf
writeShort(int value)
Sets the specified 16-bit short integer at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer.CompositeByteBuf
writeZero(int length)
Fills this buffer with NUL (0x00) starting at the currentwriterIndex
and increases thewriterIndex
by the specifiedlength
.-
Methods inherited from class io.netty.buffer.AbstractReferenceCountedByteBuf
refCnt, release, release, resetRefCnt, setRefCnt
-
Methods inherited from class io.netty.buffer.AbstractByteBuf
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
-
Methods inherited from class io.netty.buffer.ByteBuf
asByteBuf, getDoubleLE, getFloatLE, isContiguous, maxFastWritableBytes, readDoubleLE, readFloatLE, setDoubleLE, setFloatLE, writeDoubleLE, writeFloatLE
-
-
-
-
Constructor Detail
-
CompositeByteBuf
public CompositeByteBuf(ByteBufAllocator alloc, boolean direct, int maxNumComponents)
-
CompositeByteBuf
public CompositeByteBuf(ByteBufAllocator alloc, boolean direct, int maxNumComponents, ByteBuf... buffers)
-
CompositeByteBuf
public CompositeByteBuf(ByteBufAllocator alloc, boolean direct, int maxNumComponents, java.lang.Iterable<ByteBuf> buffers)
-
-
Method Detail
-
addComponent
public CompositeByteBuf addComponent(ByteBuf buffer)
Add the givenByteBuf
.Be aware that this method does not increase the
writerIndex
of theCompositeByteBuf
. If you need to have it increased useaddComponent(boolean, ByteBuf)
.ReferenceCounted.release()
ownership ofbuffer
is transferred to thisCompositeByteBuf
.- Parameters:
buffer
- theByteBuf
to add.ReferenceCounted.release()
ownership is transferred to thisCompositeByteBuf
.
-
addComponents
public CompositeByteBuf addComponents(ByteBuf... buffers)
Add the givenByteBuf
s.Be aware that this method does not increase the
writerIndex
of theCompositeByteBuf
. If you need to have it increased useaddComponents(boolean, ByteBuf[])
.ReferenceCounted.release()
ownership of allByteBuf
objects inbuffers
is transferred to thisCompositeByteBuf
.- Parameters:
buffers
- theByteBuf
s to add.ReferenceCounted.release()
ownership of allReferenceCounted.release()
ownership of allByteBuf
objects is transferred to thisCompositeByteBuf
.
-
addComponents
public CompositeByteBuf addComponents(java.lang.Iterable<ByteBuf> buffers)
Add the givenByteBuf
s.Be aware that this method does not increase the
writerIndex
of theCompositeByteBuf
. If you need to have it increased useaddComponents(boolean, Iterable)
.ReferenceCounted.release()
ownership of allByteBuf
objects inbuffers
is transferred to thisCompositeByteBuf
.- Parameters:
buffers
- theByteBuf
s to add.ReferenceCounted.release()
ownership of allReferenceCounted.release()
ownership of allByteBuf
objects is transferred to thisCompositeByteBuf
.
-
addComponent
public CompositeByteBuf addComponent(int cIndex, ByteBuf buffer)
Add the givenByteBuf
on the specific index.Be aware that this method does not increase the
writerIndex
of theCompositeByteBuf
. If you need to have it increased useaddComponent(boolean, int, ByteBuf)
.ReferenceCounted.release()
ownership ofbuffer
is transferred to thisCompositeByteBuf
.- Parameters:
cIndex
- the index on which theByteBuf
will be added.buffer
- theByteBuf
to add.ReferenceCounted.release()
ownership is transferred to thisCompositeByteBuf
.
-
addComponent
public CompositeByteBuf addComponent(boolean increaseWriterIndex, ByteBuf buffer)
Add the givenByteBuf
and increase thewriterIndex
ifincreaseWriterIndex
istrue
.ReferenceCounted.release()
ownership ofbuffer
is transferred to thisCompositeByteBuf
.- Parameters:
buffer
- theByteBuf
to add.ReferenceCounted.release()
ownership is transferred to thisCompositeByteBuf
.
-
addComponents
public CompositeByteBuf addComponents(boolean increaseWriterIndex, ByteBuf... buffers)
Add the givenByteBuf
s and increase thewriterIndex
ifincreaseWriterIndex
istrue
.ReferenceCounted.release()
ownership of allByteBuf
objects inbuffers
is transferred to thisCompositeByteBuf
.- Parameters:
buffers
- theByteBuf
s to add.ReferenceCounted.release()
ownership of allReferenceCounted.release()
ownership of allByteBuf
objects is transferred to thisCompositeByteBuf
.
-
addComponents
public CompositeByteBuf addComponents(boolean increaseWriterIndex, java.lang.Iterable<ByteBuf> buffers)
Add the givenByteBuf
s and increase thewriterIndex
ifincreaseWriterIndex
istrue
.ReferenceCounted.release()
ownership of allByteBuf
objects inbuffers
is transferred to thisCompositeByteBuf
.- Parameters:
buffers
- theByteBuf
s to add.ReferenceCounted.release()
ownership of allReferenceCounted.release()
ownership of allByteBuf
objects is transferred to thisCompositeByteBuf
.
-
addComponent
public CompositeByteBuf addComponent(boolean increaseWriterIndex, int cIndex, ByteBuf buffer)
Add the givenByteBuf
on the specific index and increase thewriterIndex
ifincreaseWriterIndex
istrue
.ReferenceCounted.release()
ownership ofbuffer
is transferred to thisCompositeByteBuf
.- Parameters:
cIndex
- the index on which theByteBuf
will be added.buffer
- theByteBuf
to add.ReferenceCounted.release()
ownership is transferred to thisCompositeByteBuf
.
-
addComponents
public CompositeByteBuf addComponents(int cIndex, ByteBuf... buffers)
Add the givenByteBuf
s on the specific indexBe aware that this method does not increase the
writerIndex
of theCompositeByteBuf
. If you need to have it increased you need to handle it by your own.ReferenceCounted.release()
ownership of allByteBuf
objects inbuffers
is transferred to thisCompositeByteBuf
.- Parameters:
cIndex
- the index on which theByteBuf
will be added.ReferenceCounted.release()
ownership of allReferenceCounted.release()
ownership of allByteBuf
objects is transferred to thisCompositeByteBuf
.buffers
- theByteBuf
s to add.ReferenceCounted.release()
ownership of allReferenceCounted.release()
ownership of allByteBuf
objects is transferred to thisCompositeByteBuf
.
-
addComponents
public CompositeByteBuf addComponents(int cIndex, java.lang.Iterable<ByteBuf> buffers)
Add the givenByteBuf
s on the specific index Be aware that this method does not increase thewriterIndex
of theCompositeByteBuf
. If you need to have it increased you need to handle it by your own.ReferenceCounted.release()
ownership of allByteBuf
objects inbuffers
is transferred to thisCompositeByteBuf
.- Parameters:
cIndex
- the index on which theByteBuf
will be added.buffers
- theByteBuf
s to add.ReferenceCounted.release()
ownership of allReferenceCounted.release()
ownership of allByteBuf
objects is transferred to thisCompositeByteBuf
.
-
addFlattenedComponents
public CompositeByteBuf addFlattenedComponents(boolean increaseWriterIndex, ByteBuf buffer)
Add the givenByteBuf
and increase thewriterIndex
ifincreaseWriterIndex
istrue
. If the provided buffer is aCompositeByteBuf
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 ofbuffer
is transferred to thisCompositeByteBuf
.- Parameters:
buffer
- theByteBuf
to add.ReferenceCounted.release()
ownership is transferred to thisCompositeByteBuf
.
-
removeComponent
public CompositeByteBuf removeComponent(int cIndex)
Remove theByteBuf
from the given index.- Parameters:
cIndex
- the index on from which theByteBuf
will be remove
-
removeComponents
public CompositeByteBuf removeComponents(int cIndex, int numComponents)
Remove the number ofByteBuf
s starting from the given index.- Parameters:
cIndex
- the index on which theByteBuf
s will be started to removednumComponents
- the number of components to remove
-
iterator
public java.util.Iterator<ByteBuf> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<ByteBuf>
-
forEachByteAsc0
protected int forEachByteAsc0(int start, int end, ByteProcessor processor) throws java.lang.Exception
- Throws:
java.lang.Exception
-
forEachByteDesc0
protected int forEachByteDesc0(int rStart, int rEnd, ByteProcessor processor) throws java.lang.Exception
- Throws:
java.lang.Exception
-
decompose
public java.util.List<ByteBuf> decompose(int offset, int length)
Same withAbstractByteBuf.slice(int, int)
except that this method returns a list.
-
isDirect
public boolean isDirect()
Description copied from class:ByteBuf
Returnstrue
if and only if this buffer is backed by an NIO direct buffer.
-
hasArray
public boolean hasArray()
Description copied from class:ByteBuf
Returnstrue
if and only if this buffer has a backing byte array. If this method returns true, you can safely callByteBuf.array()
andByteBuf.arrayOffset()
.
-
array
public byte[] array()
Description copied from class:ByteBuf
Returns the backing byte array of this buffer.
-
arrayOffset
public int arrayOffset()
Description copied from class:ByteBuf
Returns the offset of the first byte within the backing byte array of this buffer.- Specified by:
arrayOffset
in classByteBuf
-
hasMemoryAddress
public boolean hasMemoryAddress()
Description copied from class:ByteBuf
Returnstrue
if and only if this buffer has a reference to the low-level memory address that points to the backing data.- Specified by:
hasMemoryAddress
in classByteBuf
-
memoryAddress
public long memoryAddress()
Description copied from class:ByteBuf
Returns the low-level memory address that point to the first byte of ths backing data.- Specified by:
memoryAddress
in classByteBuf
-
capacity
public int capacity()
Description copied from class:ByteBuf
Returns the number of bytes (octets) this buffer can contain.
-
capacity
public CompositeByteBuf capacity(int newCapacity)
Description copied from class:ByteBuf
Adjusts the capacity of this buffer. If thenewCapacity
is less than the current capacity, the content of this buffer is truncated. If thenewCapacity
is greater than the current capacity, the buffer is appended with unspecified data whose length is(newCapacity - currentCapacity)
.
-
alloc
public ByteBufAllocator alloc()
Description copied from class:ByteBuf
Returns theByteBufAllocator
which created this buffer.
-
order
public java.nio.ByteOrder order()
Description copied from class:ByteBuf
Returns the endianness of this buffer.
-
numComponents
public int numComponents()
Return the current number ofByteBuf
's that are composed in this instance
-
maxNumComponents
public int maxNumComponents()
Return the max number ofByteBuf
's that are composed in this instance
-
toComponentIndex
public int toComponentIndex(int offset)
Return the index for the given offset
-
toByteIndex
public int toByteIndex(int cIndex)
-
getByte
public byte getByte(int index)
Description copied from class:ByteBuf
Gets a byte at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
getByte
in classAbstractByteBuf
-
_getByte
protected byte _getByte(int index)
- Specified by:
_getByte
in classAbstractByteBuf
-
_getShort
protected short _getShort(int index)
- Specified by:
_getShort
in classAbstractByteBuf
-
_getShortLE
protected short _getShortLE(int index)
- Specified by:
_getShortLE
in classAbstractByteBuf
-
_getUnsignedMedium
protected int _getUnsignedMedium(int index)
- Specified by:
_getUnsignedMedium
in classAbstractByteBuf
-
_getUnsignedMediumLE
protected int _getUnsignedMediumLE(int index)
- Specified by:
_getUnsignedMediumLE
in classAbstractByteBuf
-
_getInt
protected int _getInt(int index)
- Specified by:
_getInt
in classAbstractByteBuf
-
_getIntLE
protected int _getIntLE(int index)
- Specified by:
_getIntLE
in classAbstractByteBuf
-
_getLong
protected long _getLong(int index)
- Specified by:
_getLong
in classAbstractByteBuf
-
_getLongLE
protected long _getLongLE(int index)
- Specified by:
_getLongLE
in classAbstractByteBuf
-
getBytes
public CompositeByteBuf getBytes(int index, byte[] dst, int dstIndex, int length)
Description copied from class:ByteBuf
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
getBytes
public CompositeByteBuf getBytes(int index, java.nio.ByteBuffer dst)
Description copied from class:ByteBuf
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
until the destination's position reaches its limit. This method does not modifyreaderIndex
orwriterIndex
of this buffer while the destination'sposition
will be increased.
-
getBytes
public CompositeByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length)
Description copied from class:ByteBuf
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of both the source (i.e.this
) and the destination.
-
getBytes
public int getBytes(int index, java.nio.channels.GatheringByteChannel out, int length) throws java.io.IOException
Description copied from class:ByteBuf
Transfers this buffer's data to the specified channel starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
getBytes
public int getBytes(int index, java.nio.channels.FileChannel out, long position, int length) throws java.io.IOException
Description copied from class:ByteBuf
Transfers this buffer's data starting at the specified absoluteindex
to the specified channel starting at the given file position. This method does not modifyreaderIndex
orwriterIndex
of this buffer. This method does not modify the channel's position.- Specified by:
getBytes
in classByteBuf
position
- the file position at which the transfer is to beginlength
- the maximum number of bytes to transfer- Returns:
- the actual number of bytes written out to the specified channel
- Throws:
java.io.IOException
- if the specified channel threw an exception during I/O
-
getBytes
public CompositeByteBuf getBytes(int index, java.io.OutputStream out, int length) throws java.io.IOException
Description copied from class:ByteBuf
Transfers this buffer's data to the specified stream starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
setByte
public CompositeByteBuf setByte(int index, int value)
Description copied from class:ByteBuf
Sets the specified byte at the specified absoluteindex
in this buffer. The 24 high-order bits of the specified value are ignored. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setByte
in classAbstractByteBuf
-
_setByte
protected void _setByte(int index, int value)
- Specified by:
_setByte
in classAbstractByteBuf
-
setShort
public CompositeByteBuf setShort(int index, int value)
Description copied from class:ByteBuf
Sets the specified 16-bit short integer at the specified absoluteindex
in this buffer. The 16 high-order bits of the specified value are ignored. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setShort
in classAbstractByteBuf
-
_setShort
protected void _setShort(int index, int value)
- Specified by:
_setShort
in classAbstractByteBuf
-
_setShortLE
protected void _setShortLE(int index, int value)
- Specified by:
_setShortLE
in classAbstractByteBuf
-
setMedium
public CompositeByteBuf setMedium(int index, int value)
Description copied from class:ByteBuf
Sets the specified 24-bit medium integer at the specified absoluteindex
in this buffer. Please note that the most significant byte is ignored in the specified value. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setMedium
in classAbstractByteBuf
-
_setMedium
protected void _setMedium(int index, int value)
- Specified by:
_setMedium
in classAbstractByteBuf
-
_setMediumLE
protected void _setMediumLE(int index, int value)
- Specified by:
_setMediumLE
in classAbstractByteBuf
-
setInt
public CompositeByteBuf setInt(int index, int value)
Description copied from class:ByteBuf
Sets the specified 32-bit integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setInt
in classAbstractByteBuf
-
_setInt
protected void _setInt(int index, int value)
- Specified by:
_setInt
in classAbstractByteBuf
-
_setIntLE
protected void _setIntLE(int index, int value)
- Specified by:
_setIntLE
in classAbstractByteBuf
-
setLong
public CompositeByteBuf setLong(int index, long value)
Description copied from class:ByteBuf
Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setLong
in classAbstractByteBuf
-
_setLong
protected void _setLong(int index, long value)
- Specified by:
_setLong
in classAbstractByteBuf
-
_setLongLE
protected void _setLongLE(int index, long value)
- Specified by:
_setLongLE
in classAbstractByteBuf
-
setBytes
public CompositeByteBuf setBytes(int index, byte[] src, int srcIndex, int length)
Description copied from class:ByteBuf
Transfers the specified source array's data to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
setBytes
public CompositeByteBuf setBytes(int index, java.nio.ByteBuffer src)
Description copied from class:ByteBuf
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
until the source buffer's position reaches its limit. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
setBytes
public CompositeByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length)
Description copied from class:ByteBuf
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of both the source (i.e.this
) and the destination.
-
setBytes
public int setBytes(int index, java.io.InputStream in, int length) throws java.io.IOException
Description copied from class:ByteBuf
Transfers the content of the specified source stream to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
setBytes
public int setBytes(int index, java.nio.channels.ScatteringByteChannel in, int length) throws java.io.IOException
Description copied from class:ByteBuf
Transfers the content of the specified source channel to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
setBytes
in classByteBuf
length
- the maximum number of bytes to transfer- Returns:
- the actual number of bytes read in from the specified channel.
-1
if the specified channel is closed or it reached EOF. - Throws:
java.io.IOException
- if the specified channel threw an exception during I/O
-
setBytes
public int setBytes(int index, java.nio.channels.FileChannel in, long position, int length) throws java.io.IOException
Description copied from class:ByteBuf
Transfers the content of the specified source channel starting at the given file position to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer. This method does not modify the channel's position.- Specified by:
setBytes
in classByteBuf
position
- the file position at which the transfer is to beginlength
- the maximum number of bytes to transfer- Returns:
- the actual number of bytes read in from the specified channel.
-1
if the specified channel is closed or it reached EOF. - Throws:
java.io.IOException
- if the specified channel threw an exception during I/O
-
copy
public ByteBuf copy(int index, int length)
Description copied from class:ByteBuf
Returns a copy of this buffer's sub-region. Modifying the content of the returned buffer or this buffer does not affect each other at all. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
componentAtOffset
public ByteBuf componentAtOffset(int offset)
Return theByteBuf
on the specified index
-
internalComponent
public ByteBuf internalComponent(int cIndex)
Return the internalByteBuf
on the specified index. Note that updating the indexes of the returned buffer will lead to an undefined behavior of this buffer.- Parameters:
cIndex
- the index for which theByteBuf
should be returned
-
internalComponentAtOffset
public ByteBuf internalComponentAtOffset(int offset)
Return the internalByteBuf
on the specified offset. Note that updating the indexes of the returned buffer will lead to an undefined behavior of this buffer.- Parameters:
offset
- the offset for which theByteBuf
should be returned
-
nioBufferCount
public int nioBufferCount()
Description copied from class:ByteBuf
Returns the maximum number of NIOByteBuffer
s that consist this buffer. Note thatByteBuf.nioBuffers()
orByteBuf.nioBuffers(int, int)
might return a less number ofByteBuffer
s.- Specified by:
nioBufferCount
in classByteBuf
- Returns:
-1
if this buffer has no underlyingByteBuffer
. the number of the underlyingByteBuffer
s if this buffer has at least one underlyingByteBuffer
. Note that this method does not return0
to avoid confusion.- See Also:
ByteBuf.nioBuffer()
,ByteBuf.nioBuffer(int, int)
,ByteBuf.nioBuffers()
,ByteBuf.nioBuffers(int, int)
-
internalNioBuffer
public java.nio.ByteBuffer internalNioBuffer(int index, int length)
Description copied from class:ByteBuf
Internal use only: Exposes the internal NIO buffer.- Specified by:
internalNioBuffer
in classByteBuf
-
nioBuffer
public java.nio.ByteBuffer nioBuffer(int index, int length)
Description copied from class:ByteBuf
Exposes this buffer's sub-region as an NIOByteBuffer
. 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 modifyreaderIndex
orwriterIndex
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.- Specified by:
nioBuffer
in classByteBuf
- See Also:
ByteBuf.nioBufferCount()
,ByteBuf.nioBuffers()
,ByteBuf.nioBuffers(int, int)
-
nioBuffers
public java.nio.ByteBuffer[] nioBuffers(int index, int length)
Description copied from class:ByteBuf
Exposes this buffer's bytes as an NIOByteBuffer
'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 modifyreaderIndex
orwriterIndex
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.- Specified by:
nioBuffers
in classByteBuf
- See Also:
ByteBuf.nioBufferCount()
,ByteBuf.nioBuffer()
,ByteBuf.nioBuffer(int, int)
-
consolidate
public CompositeByteBuf consolidate()
Consolidate the composedByteBuf
s
-
consolidate
public CompositeByteBuf consolidate(int cIndex, int numComponents)
Consolidate the composedByteBuf
s- Parameters:
cIndex
- the index on which to start to composenumComponents
- the number of components to compose
-
discardReadComponents
public CompositeByteBuf discardReadComponents()
Discard allByteBuf
s which are read.
-
discardReadBytes
public CompositeByteBuf discardReadBytes()
Description copied from class:ByteBuf
Discards the bytes between the 0th index andreaderIndex
. It moves the bytes betweenreaderIndex
andwriterIndex
to the 0th index, and setsreaderIndex
andwriterIndex
to0
andoldWriterIndex - oldReaderIndex
respectively.Please refer to the class documentation for more detailed explanation.
- Overrides:
discardReadBytes
in classAbstractByteBuf
-
toString
public java.lang.String toString()
Description copied from class:ByteBuf
Returns the string representation of this buffer. This method does not necessarily return the whole content of the buffer but returns the values of the key properties such asByteBuf.readerIndex()
,ByteBuf.writerIndex()
andByteBuf.capacity()
.- Overrides:
toString
in classAbstractByteBuf
-
readerIndex
public CompositeByteBuf readerIndex(int readerIndex)
Description copied from class:ByteBuf
Sets thereaderIndex
of this buffer.- Overrides:
readerIndex
in classAbstractByteBuf
-
writerIndex
public CompositeByteBuf writerIndex(int writerIndex)
Description copied from class:ByteBuf
Sets thewriterIndex
of this buffer.- Overrides:
writerIndex
in classAbstractByteBuf
-
setIndex
public CompositeByteBuf setIndex(int readerIndex, int writerIndex)
Description copied from class:ByteBuf
Sets thereaderIndex
andwriterIndex
of this buffer in one shot. This method is useful when you have to worry about the invocation order ofByteBuf.readerIndex(int)
andByteBuf.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);
- Overrides:
setIndex
in classAbstractByteBuf
-
clear
public CompositeByteBuf clear()
Description copied from class:ByteBuf
Sets thereaderIndex
andwriterIndex
of this buffer to0
. This method is identical tosetIndex(0, 0)
.Please note that the behavior of this method is different from that of NIO buffer, which sets the
limit
to thecapacity
of the buffer.- Overrides:
clear
in classAbstractByteBuf
-
markReaderIndex
public CompositeByteBuf markReaderIndex()
Description copied from class:ByteBuf
Marks the currentreaderIndex
in this buffer. You can reposition the currentreaderIndex
to the markedreaderIndex
by callingByteBuf.resetReaderIndex()
. The initial value of the markedreaderIndex
is0
.- Overrides:
markReaderIndex
in classAbstractByteBuf
-
resetReaderIndex
public CompositeByteBuf resetReaderIndex()
Description copied from class:ByteBuf
Repositions the currentreaderIndex
to the markedreaderIndex
in this buffer.- Overrides:
resetReaderIndex
in classAbstractByteBuf
-
markWriterIndex
public CompositeByteBuf markWriterIndex()
Description copied from class:ByteBuf
Marks the currentwriterIndex
in this buffer. You can reposition the currentwriterIndex
to the markedwriterIndex
by callingByteBuf.resetWriterIndex()
. The initial value of the markedwriterIndex
is0
.- Overrides:
markWriterIndex
in classAbstractByteBuf
-
resetWriterIndex
public CompositeByteBuf resetWriterIndex()
Description copied from class:ByteBuf
Repositions the currentwriterIndex
to the markedwriterIndex
in this buffer.- Overrides:
resetWriterIndex
in classAbstractByteBuf
-
ensureWritable
public CompositeByteBuf ensureWritable(int minWritableBytes)
Description copied from class:ByteBuf
Expands the bufferByteBuf.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.- Overrides:
ensureWritable
in classAbstractByteBuf
- Parameters:
minWritableBytes
- the expected minimum number of writable bytes- See Also:
ByteBuf.capacity(int)
-
getBytes
public CompositeByteBuf getBytes(int index, ByteBuf dst)
Description copied from class:ByteBuf
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
until the destination becomes non-writable. This method is basically same withByteBuf.getBytes(int, ByteBuf, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes whileByteBuf.getBytes(int, ByteBuf, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of the source buffer (i.e.this
).- Overrides:
getBytes
in classAbstractByteBuf
-
getBytes
public CompositeByteBuf getBytes(int index, ByteBuf dst, int length)
Description copied from class:ByteBuf
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method is basically same withByteBuf.getBytes(int, ByteBuf, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes whileByteBuf.getBytes(int, ByteBuf, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of the source buffer (i.e.this
).- Overrides:
getBytes
in classAbstractByteBuf
length
- the number of bytes to transfer
-
getBytes
public CompositeByteBuf getBytes(int index, byte[] dst)
Description copied from class:ByteBuf
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer- Overrides:
getBytes
in classAbstractByteBuf
-
setBoolean
public CompositeByteBuf setBoolean(int index, boolean value)
Description copied from class:ByteBuf
Sets the specified boolean at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setBoolean
in classAbstractByteBuf
-
setChar
public CompositeByteBuf setChar(int index, int value)
Description copied from class:ByteBuf
Sets the specified 2-byte UTF-16 character at the specified absoluteindex
in this buffer. The 16 high-order bits of the specified value are ignored. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setChar
in classAbstractByteBuf
-
setFloat
public CompositeByteBuf setFloat(int index, float value)
Description copied from class:ByteBuf
Sets the specified 32-bit floating-point number at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setFloat
in classAbstractByteBuf
-
setDouble
public CompositeByteBuf setDouble(int index, double value)
Description copied from class:ByteBuf
Sets the specified 64-bit floating-point number at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setDouble
in classAbstractByteBuf
-
setBytes
public CompositeByteBuf setBytes(int index, ByteBuf src)
Description copied from class:ByteBuf
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
until the source buffer becomes unreadable. This method is basically same withByteBuf.setBytes(int, ByteBuf, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes whileByteBuf.setBytes(int, ByteBuf, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of this buffer (i.e.this
).- Overrides:
setBytes
in classAbstractByteBuf
-
setBytes
public CompositeByteBuf setBytes(int index, ByteBuf src, int length)
Description copied from class:ByteBuf
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
. This method is basically same withByteBuf.setBytes(int, ByteBuf, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes whileByteBuf.setBytes(int, ByteBuf, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of this buffer (i.e.this
).- Overrides:
setBytes
in classAbstractByteBuf
length
- the number of bytes to transfer
-
setBytes
public CompositeByteBuf setBytes(int index, byte[] src)
Description copied from class:ByteBuf
Transfers the specified source array's data to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setBytes
in classAbstractByteBuf
-
setZero
public CompositeByteBuf setZero(int index, int length)
Description copied from class:ByteBuf
Fills this buffer with NUL (0x00) starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setZero
in classAbstractByteBuf
length
- the number of NULs to write to the buffer
-
readBytes
public CompositeByteBuf readBytes(ByteBuf dst)
Description copied from class:ByteBuf
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
until the destination becomes non-writable, and increases thereaderIndex
by the number of the transferred bytes. This method is basically same withByteBuf.readBytes(ByteBuf, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes whileByteBuf.readBytes(ByteBuf, int, int)
does not.- Overrides:
readBytes
in classAbstractByteBuf
-
readBytes
public CompositeByteBuf readBytes(ByteBuf dst, int length)
Description copied from class:ByteBuf
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
). This method is basically same withByteBuf.readBytes(ByteBuf, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes (=length
) whileByteBuf.readBytes(ByteBuf, int, int)
does not.- Overrides:
readBytes
in classAbstractByteBuf
-
readBytes
public CompositeByteBuf readBytes(ByteBuf dst, int dstIndex, int length)
Description copied from class:ByteBuf
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).- Overrides:
readBytes
in classAbstractByteBuf
dstIndex
- the first index of the destinationlength
- the number of bytes to transfer
-
readBytes
public CompositeByteBuf readBytes(byte[] dst)
Description copied from class:ByteBuf
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=dst.length
).- Overrides:
readBytes
in classAbstractByteBuf
-
readBytes
public CompositeByteBuf readBytes(byte[] dst, int dstIndex, int length)
Description copied from class:ByteBuf
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).- Overrides:
readBytes
in classAbstractByteBuf
dstIndex
- the first index of the destinationlength
- the number of bytes to transfer
-
readBytes
public CompositeByteBuf readBytes(java.nio.ByteBuffer dst)
Description copied from class:ByteBuf
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
until the destination's position reaches its limit, and increases thereaderIndex
by the number of the transferred bytes.- Overrides:
readBytes
in classAbstractByteBuf
-
readBytes
public CompositeByteBuf readBytes(java.io.OutputStream out, int length) throws java.io.IOException
Description copied from class:ByteBuf
Transfers this buffer's data to the specified stream starting at the currentreaderIndex
.- Overrides:
readBytes
in classAbstractByteBuf
length
- the number of bytes to transfer- Throws:
java.io.IOException
- if the specified stream threw an exception during I/O
-
skipBytes
public CompositeByteBuf skipBytes(int length)
Description copied from class:ByteBuf
Increases the currentreaderIndex
by the specifiedlength
in this buffer.- Overrides:
skipBytes
in classAbstractByteBuf
-
writeBoolean
public CompositeByteBuf writeBoolean(boolean value)
Description copied from class:ByteBuf
Sets the specified boolean at the currentwriterIndex
and increases thewriterIndex
by1
in this buffer. Ifthis.writableBytes
is less than1
,ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Overrides:
writeBoolean
in classAbstractByteBuf
-
writeByte
public CompositeByteBuf writeByte(int value)
Description copied from class:ByteBuf
Sets the specified byte at the currentwriterIndex
and increases thewriterIndex
by1
in this buffer. The 24 high-order bits of the specified value are ignored. Ifthis.writableBytes
is less than1
,ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Overrides:
writeByte
in classAbstractByteBuf
-
writeShort
public CompositeByteBuf writeShort(int value)
Description copied from class:ByteBuf
Sets the specified 16-bit short integer at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer. The 16 high-order bits of the specified value are ignored. Ifthis.writableBytes
is less than2
,ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Overrides:
writeShort
in classAbstractByteBuf
-
writeMedium
public CompositeByteBuf writeMedium(int value)
Description copied from class:ByteBuf
Sets the specified 24-bit medium integer at the currentwriterIndex
and increases thewriterIndex
by3
in this buffer. Ifthis.writableBytes
is less than3
,ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Overrides:
writeMedium
in classAbstractByteBuf
-
writeInt
public CompositeByteBuf writeInt(int value)
Description copied from class:ByteBuf
Sets the specified 32-bit integer at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer. Ifthis.writableBytes
is less than4
,ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Overrides:
writeInt
in classAbstractByteBuf
-
writeLong
public CompositeByteBuf writeLong(long value)
Description copied from class:ByteBuf
Sets the specified 64-bit long integer at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer. Ifthis.writableBytes
is less than8
,ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Overrides:
writeLong
in classAbstractByteBuf
-
writeChar
public CompositeByteBuf writeChar(int value)
Description copied from class:ByteBuf
Sets the specified 2-byte UTF-16 character at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer. The 16 high-order bits of the specified value are ignored. Ifthis.writableBytes
is less than2
,ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Overrides:
writeChar
in classAbstractByteBuf
-
writeFloat
public CompositeByteBuf writeFloat(float value)
Description copied from class:ByteBuf
Sets the specified 32-bit floating point number at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer. Ifthis.writableBytes
is less than4
,ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Overrides:
writeFloat
in classAbstractByteBuf
-
writeDouble
public CompositeByteBuf writeDouble(double value)
Description copied from class:ByteBuf
Sets the specified 64-bit floating point number at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer. Ifthis.writableBytes
is less than8
,ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Overrides:
writeDouble
in classAbstractByteBuf
-
writeBytes
public CompositeByteBuf writeBytes(ByteBuf src)
Description copied from class:ByteBuf
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
until the source buffer becomes unreadable, and increases thewriterIndex
by the number of the transferred bytes. This method is basically same withByteBuf.writeBytes(ByteBuf, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes whileByteBuf.writeBytes(ByteBuf, int, int)
does not. Ifthis.writableBytes
is less thansrc.readableBytes
,ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Overrides:
writeBytes
in classAbstractByteBuf
-
writeBytes
public CompositeByteBuf writeBytes(ByteBuf src, int length)
Description copied from class:ByteBuf
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
). This method is basically same withByteBuf.writeBytes(ByteBuf, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes (=length
) whileByteBuf.writeBytes(ByteBuf, int, int)
does not. Ifthis.writableBytes
is less thanlength
,ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Overrides:
writeBytes
in classAbstractByteBuf
length
- the number of bytes to transfer
-
writeBytes
public CompositeByteBuf writeBytes(ByteBuf src, int srcIndex, int length)
Description copied from class:ByteBuf
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
). Ifthis.writableBytes
is less thanlength
,ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Overrides:
writeBytes
in classAbstractByteBuf
srcIndex
- the first index of the sourcelength
- the number of bytes to transfer
-
writeBytes
public CompositeByteBuf writeBytes(byte[] src)
Description copied from class:ByteBuf
Transfers the specified source array's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=src.length
). Ifthis.writableBytes
is less thansrc.length
,ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Overrides:
writeBytes
in classAbstractByteBuf
-
writeBytes
public CompositeByteBuf writeBytes(byte[] src, int srcIndex, int length)
Description copied from class:ByteBuf
Transfers the specified source array's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
). Ifthis.writableBytes
is less thanlength
,ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Overrides:
writeBytes
in classAbstractByteBuf
srcIndex
- the first index of the sourcelength
- the number of bytes to transfer
-
writeBytes
public CompositeByteBuf writeBytes(java.nio.ByteBuffer src)
Description copied from class:ByteBuf
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
until the source buffer's position reaches its limit, and increases thewriterIndex
by the number of the transferred bytes. Ifthis.writableBytes
is less thansrc.remaining()
,ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Overrides:
writeBytes
in classAbstractByteBuf
-
writeZero
public CompositeByteBuf writeZero(int length)
Description copied from class:ByteBuf
Fills this buffer with NUL (0x00) starting at the currentwriterIndex
and increases thewriterIndex
by the specifiedlength
. Ifthis.writableBytes
is less thanlength
,ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Overrides:
writeZero
in classAbstractByteBuf
- Parameters:
length
- the number of NULs to write to the buffer
-
retain
public CompositeByteBuf retain(int increment)
Description copied from interface:ReferenceCounted
Increases the reference count by the specifiedincrement
.- Specified by:
retain
in interfaceReferenceCounted
- Overrides:
retain
in classAbstractReferenceCountedByteBuf
-
retain
public CompositeByteBuf retain()
Description copied from interface:ReferenceCounted
Increases the reference count by1
.- Specified by:
retain
in interfaceReferenceCounted
- Overrides:
retain
in classAbstractReferenceCountedByteBuf
-
touch
public CompositeByteBuf touch()
Description copied from interface:ReferenceCounted
Records the current access location of this object for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector
. This method is a shortcut totouch(null)
.- Specified by:
touch
in interfaceReferenceCounted
- Overrides:
touch
in classAbstractReferenceCountedByteBuf
-
touch
public CompositeByteBuf touch(java.lang.Object hint)
Description copied from interface:ReferenceCounted
Records the current access location of this object with an additional arbitrary information for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector
.- Specified by:
touch
in interfaceReferenceCounted
- Overrides:
touch
in classAbstractReferenceCountedByteBuf
-
nioBuffers
public java.nio.ByteBuffer[] nioBuffers()
Description copied from class:ByteBuf
Exposes this buffer's readable bytes as an NIOByteBuffer
'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 modifyreaderIndex
orwriterIndex
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.- Overrides:
nioBuffers
in classAbstractByteBuf
- See Also:
ByteBuf.nioBufferCount()
,ByteBuf.nioBuffer()
,ByteBuf.nioBuffer(int, int)
-
discardSomeReadBytes
public CompositeByteBuf discardSomeReadBytes()
Description copied from class:ByteBuf
Similar toByteBuf.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.- Overrides:
discardSomeReadBytes
in classAbstractByteBuf
-
deallocate
protected void deallocate()
Description copied from class:AbstractReferenceCountedByteBuf
Called onceAbstractReferenceCountedByteBuf.refCnt()
is equals 0.- Specified by:
deallocate
in classAbstractReferenceCountedByteBuf
-
-