Class CompositeByteBuf
- All Implemented Interfaces:
ByteBufConvertible
,ReferenceCounted
,Comparable<ByteBuf>
,Iterable<ByteBuf>
- Direct Known Subclasses:
WrappedCompositeByteBuf
ByteBufAllocator.compositeBuffer()
or Unpooled.wrappedBuffer(ByteBuf...)
instead of calling the
constructor explicitly.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interface
private static final class
private final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ByteBufAllocator
(package private) static final CompositeByteBuf.ByteWrapper
<byte[]> (package private) static final CompositeByteBuf.ByteWrapper
<ByteBuffer> private int
private CompositeByteBuf.Component[]
private final boolean
private static final ByteBuffer
private boolean
private CompositeByteBuf.Component
private final int
Fields inherited from class io.netty.buffer.AbstractByteBuf
checkAccessible, leakDetector, readerIndex, writerIndex
-
Constructor Summary
ConstructorsModifierConstructorDescription(package private)
CompositeByteBuf
(ByteBufAllocator alloc) CompositeByteBuf
(ByteBufAllocator alloc, boolean direct, int maxNumComponents) private
CompositeByteBuf
(ByteBufAllocator alloc, boolean direct, int maxNumComponents, int initSize) CompositeByteBuf
(ByteBufAllocator alloc, boolean direct, int maxNumComponents, ByteBuf... buffers) (package private)
CompositeByteBuf
(ByteBufAllocator alloc, boolean direct, int maxNumComponents, ByteBuf[] buffers, int offset) (package private)
CompositeByteBuf
(ByteBufAllocator alloc, boolean direct, int maxNumComponents, CompositeByteBuf.ByteWrapper<T> wrapper, T[] buffers, int offset) CompositeByteBuf
(ByteBufAllocator alloc, boolean direct, int maxNumComponents, Iterable<ByteBuf> buffers) -
Method Summary
Modifier and TypeMethodDescriptionprotected 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) private void
addComp
(int i, CompositeByteBuf.Component c) addComponent
(boolean increaseWriterIndex, int cIndex, ByteBuf buffer) Add the givenByteBuf
on the specific index and increase thewriterIndex
ifincreaseWriterIndex
istrue
.addComponent
(boolean increaseWriterIndex, ByteBuf buffer) addComponent
(int cIndex, ByteBuf buffer) Add the givenByteBuf
on the specific index.addComponent
(ByteBuf buffer) Add the givenByteBuf
.private int
addComponent0
(boolean increaseWriterIndex, int cIndex, ByteBuf buffer) Precondition is thatbuffer != null
.private CompositeByteBuf
addComponents
(boolean increaseIndex, int cIndex, Iterable<ByteBuf> buffers) addComponents
(boolean increaseWriterIndex, ByteBuf... buffers) addComponents
(boolean increaseWriterIndex, Iterable<ByteBuf> buffers) addComponents
(int cIndex, ByteBuf... buffers) Add the givenByteBuf
s on the specific indexaddComponents
(int cIndex, Iterable<ByteBuf> buffers) Add the givenByteBuf
s on the specific index Be aware that this method does not increase thewriterIndex
of theCompositeByteBuf
.addComponents
(ByteBuf... buffers) Add the givenByteBuf
s.addComponents
(Iterable<ByteBuf> buffers) Add the givenByteBuf
s.private CompositeByteBuf
addComponents0
(boolean increaseWriterIndex, int cIndex, ByteBuf[] buffers, int arrOffset) private <T> int
addComponents0
(boolean increaseWriterIndex, int cIndex, CompositeByteBuf.ByteWrapper<T> wrapper, T[] buffers, int offset) addFlattenedComponents
(boolean increaseWriterIndex, ByteBuf buffer) alloc()
Returns theByteBufAllocator
which created this buffer.private ByteBuf
allocBuffer
(int capacity) byte[]
array()
Returns the backing byte array of this buffer.int
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.capacity
(int newCapacity) Adjusts the capacity of this buffer.private void
checkComponentIndex
(int cIndex) private void
checkComponentIndex
(int cIndex, int numComponents) private static void
checkForOverflow
(int capacity, int readableBytes) clear()
Sets thereaderIndex
andwriterIndex
of this buffer to0
.private void
component
(int cIndex) Return theByteBuf
on the specified indexcomponentAtOffset
(int offset) Return theByteBuf
on the specified indexConsolidate the composedByteBuf
sconsolidate
(int cIndex, int numComponents) Consolidate the composedByteBuf
sprivate void
consolidate0
(int cIndex, int numComponents) private void
This should only be called as last operation from a method as this may adjust the underlying array of components and so affect the index etc.copy
(int index, int length) Returns a copy of this buffer's sub-region.private void
protected void
Called onceAbstractReferenceCountedByteBuf.refCnt()
is equals 0.decompose
(int offset, int length) Same withAbstractByteBuf.slice(int, int)
except that this method returns a list.Discards the bytes between the 0th index andreaderIndex
.Discard allByteBuf
s which are read.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.private static ByteBuf
ensureAccessible
(ByteBuf buf) ensureWritable
(int minWritableBytes) Expands the bufferByteBuf.capacity()
to make sure the number of writable bytes is equal to or greater than the specified value.private CompositeByteBuf.Component
findComponent
(int offset) private CompositeByteBuf.Component
findComponent0
(int offset) private CompositeByteBuf.Component
findIt
(int offset) 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.getBytes
(int index, byte[] dst) Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.getBytes
(int index, byte[] dst, int dstIndex, int length) Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.Transfers this buffer's data to the specified destination starting at the specified absoluteindex
until the destination becomes non-writable.Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.getBytes
(int index, OutputStream out, int length) Transfers this buffer's data to the specified stream starting at the specified absoluteindex
.getBytes
(int index, 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, 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, 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
Returnstrue
if and only if this buffer has a reference to the low-level memory address that points to the backing data.internalComponent
(int cIndex) Return the internalByteBuf
on the specified index.internalComponentAtOffset
(int offset) Return the internalByteBuf
on the specified offset.internalNioBuffer
(int index, int length) Internal use only: Exposes the internal NIO buffer.(package private) boolean
Used internally byAbstractByteBuf.ensureAccessible()
to try to guard against using the buffer after it was released (best-effort).boolean
isDirect()
Returnstrue
if and only if this buffer is backed by an NIO direct buffer.iterator()
Marks the currentreaderIndex
in this buffer.Marks the currentwriterIndex
in this buffer.int
Return the max number ofByteBuf
's that are composed in this instancelong
Returns the low-level memory address that point to the first byte of ths backing data.private static CompositeByteBuf.Component[]
newCompArray
(int initComponents, int maxNumComponents) private CompositeByteBuf.Component
newComponent
(ByteBuf buf, int offset) nioBuffer
(int index, int length) Exposes this buffer's sub-region as an NIOByteBuffer
.int
Returns the maximum number of NIOByteBuffer
s that consist this buffer.Exposes this buffer's readable bytes as an NIOByteBuffer
's.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
Return the current number ofByteBuf
's that are composed in this instanceorder()
Returns the endianness of this buffer.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
).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
).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.Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=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
).readBytes
(OutputStream out, int length) Transfers this buffer's data to the specified stream starting at the currentreaderIndex
.readBytes
(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.readerIndex
(int readerIndex) Sets thereaderIndex
of this buffer.private void
removeComp
(int i) removeComponent
(int cIndex) Remove theByteBuf
from the given index.removeComponents
(int cIndex, int numComponents) Remove the number ofByteBuf
s starting from the given index.private void
removeCompRange
(int from, int to) Repositions the currentreaderIndex
to the markedreaderIndex
in this buffer.Repositions the currentwriterIndex
to the markedwriterIndex
in this buffer.retain()
Increases the reference count by1
.retain
(int increment) Increases the reference count by the specifiedincrement
.setBoolean
(int index, boolean value) Sets the specified boolean at the specified absoluteindex
in this buffer.setByte
(int index, int value) Sets the specified byte at the specified absoluteindex
in this buffer.setBytes
(int index, byte[] src) Transfers the specified source array's data to this buffer starting at the specified absoluteindex
.setBytes
(int index, byte[] src, int srcIndex, int length) Transfers the specified source array's data to this buffer starting at the specified absoluteindex
.Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
until the source buffer becomes unreadable.Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
.Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
.int
setBytes
(int index, InputStream in, int length) Transfers the content of the specified source stream to this buffer starting at the specified absoluteindex
.setBytes
(int index, 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, 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, ScatteringByteChannel in, int length) Transfers the content of the specified source channel to this buffer starting at the specified absoluteindex
.setChar
(int index, int value) Sets the specified 2-byte UTF-16 character at the specified absoluteindex
in this buffer.setDouble
(int index, double value) Sets the specified 64-bit floating-point number at the specified absoluteindex
in this buffer.setFloat
(int index, float value) Sets the specified 32-bit floating-point number at the specified absoluteindex
in this buffer.setIndex
(int readerIndex, int writerIndex) Sets thereaderIndex
andwriterIndex
of this buffer in one shot.setInt
(int index, int value) Sets the specified 32-bit integer at the specified absoluteindex
in this buffer.setLong
(int index, long value) Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer.setMedium
(int index, int value) Sets the specified 24-bit medium integer at the specified absoluteindex
in this buffer.setShort
(int index, int value) Sets the specified 16-bit short integer at the specified absoluteindex
in this buffer.setZero
(int index, int length) Fills this buffer with NUL (0x00) starting at the specified absoluteindex
.private void
shiftComps
(int i, int count) 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 offsetprivate int
toComponentIndex0
(int offset) toString()
Returns the string representation of this buffer.touch()
Records the current access location of this object for debugging purposes.Records the current access location of this object with an additional arbitrary information for debugging purposes.unwrap()
Return the underlying buffer instance if this buffer is a wrapper of another buffer.private void
updateComponentOffsets
(int cIndex) writeBoolean
(boolean value) Sets the specified boolean at the currentwriterIndex
and increases thewriterIndex
by1
in this buffer.writeByte
(int value) Sets the specified byte at the currentwriterIndex
and increases thewriterIndex
by1
in this buffer.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
).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
).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.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
).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
).writeBytes
(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.writeChar
(int value) Sets the specified 2-byte UTF-16 character at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer.writeDouble
(double value) Sets the specified 64-bit floating point number at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer.writeFloat
(float value) Sets the specified 32-bit floating point number at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer.writeInt
(int value) Sets the specified 32-bit integer at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer.writeLong
(long value) Sets the specified 64-bit long integer at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer.writeMedium
(int value) Sets the specified 24-bit medium integer at the currentwriterIndex
and increases thewriterIndex
by3
in this buffer.writerIndex
(int writerIndex) Sets thewriterIndex
of this buffer.writeShort
(int value) Sets the specified 16-bit short integer at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer.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, checkIndex0, checkNewCapacity, checkReadableBytes, checkSrcIndex, compareTo, copy, discardMarks, duplicate, ensureAccessible, ensureWritable, ensureWritable0, 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, setIndex0, 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
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
EMPTY_NIO_BUFFER
-
EMPTY_ITERATOR
-
alloc
-
direct
private final boolean direct -
maxNumComponents
private final int maxNumComponents -
componentCount
private int componentCount -
components
-
freed
private boolean freed -
BYTE_ARRAY_WRAPPER
-
BYTE_BUFFER_WRAPPER
-
lastAccessed
-
-
Constructor Details
-
CompositeByteBuf
private CompositeByteBuf(ByteBufAllocator alloc, boolean direct, int maxNumComponents, int initSize) -
CompositeByteBuf
-
CompositeByteBuf
public CompositeByteBuf(ByteBufAllocator alloc, boolean direct, int maxNumComponents, ByteBuf... buffers) -
CompositeByteBuf
CompositeByteBuf(ByteBufAllocator alloc, boolean direct, int maxNumComponents, ByteBuf[] buffers, int offset) -
CompositeByteBuf
public CompositeByteBuf(ByteBufAllocator alloc, boolean direct, int maxNumComponents, Iterable<ByteBuf> buffers) -
CompositeByteBuf
CompositeByteBuf(ByteBufAllocator alloc, boolean direct, int maxNumComponents, CompositeByteBuf.ByteWrapper<T> wrapper, T[] buffers, int offset) -
CompositeByteBuf
CompositeByteBuf(ByteBufAllocator alloc)
-
-
Method Details
-
newCompArray
-
addComponent
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
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
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
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
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
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
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
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
.
-
checkForOverflow
private static void checkForOverflow(int capacity, int readableBytes) -
addComponent0
Precondition is thatbuffer != null
. -
ensureAccessible
-
newComponent
-
addComponents
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
.
-
addComponents0
private CompositeByteBuf addComponents0(boolean increaseWriterIndex, int cIndex, ByteBuf[] buffers, int arrOffset) -
addComponents0
private <T> int addComponents0(boolean increaseWriterIndex, int cIndex, CompositeByteBuf.ByteWrapper<T> wrapper, T[] buffers, int offset) -
addComponents
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
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
.
-
addComponents
private CompositeByteBuf addComponents(boolean increaseIndex, int cIndex, Iterable<ByteBuf> buffers) -
consolidateIfNeeded
private void consolidateIfNeeded()This should only be called as last operation from a method as this may adjust the underlying array of components and so affect the index etc. -
checkComponentIndex
private void checkComponentIndex(int cIndex) -
checkComponentIndex
private void checkComponentIndex(int cIndex, int numComponents) -
updateComponentOffsets
private void updateComponentOffsets(int cIndex) -
removeComponent
Remove theByteBuf
from the given index.- Parameters:
cIndex
- the index on from which theByteBuf
will be remove
-
removeComponents
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
-
forEachByteAsc0
- Overrides:
forEachByteAsc0
in classAbstractByteBuf
- Throws:
Exception
-
forEachByteDesc0
- Overrides:
forEachByteDesc0
in classAbstractByteBuf
- Throws:
Exception
-
decompose
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
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
Description copied from class:ByteBuf
Returns theByteBufAllocator
which created this buffer. -
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 -
toComponentIndex0
private int toComponentIndex0(int 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
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
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
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
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.- Specified by:
getBytes
in classByteBuf
- Parameters:
length
- the maximum number of bytes to transfer- Returns:
- the actual number of bytes written out to the specified channel
- Throws:
IOException
- if the specified channel threw an exception during I/O
-
getBytes
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
- Parameters:
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:
IOException
- if the specified channel threw an exception during I/O
-
getBytes
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.- Specified by:
getBytes
in classByteBuf
- Parameters:
length
- the number of bytes to transfer- Throws:
IOException
- if the specified stream threw an exception during I/O
-
setByte
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
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
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
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
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
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
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
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
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.- Specified by:
setBytes
in classByteBuf
- Parameters:
length
- the number of bytes to transfer- Returns:
- the actual number of bytes read in from the specified channel.
-1
if the specifiedInputStream
reached EOF. - Throws:
IOException
- if the specified stream threw an exception during I/O
-
setBytes
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
- Parameters:
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:
IOException
- if the specified channel threw an exception during I/O
-
setBytes
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
- Parameters:
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:
IOException
- if the specified channel threw an exception during I/O
-
copy
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. -
copyTo
-
component
Return theByteBuf
on the specified index -
componentAtOffset
Return theByteBuf
on the specified index -
internalComponent
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
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
-
findComponent
-
findComponent0
-
findIt
-
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:
-
internalNioBuffer
Description copied from class:ByteBuf
Internal use only: Exposes the internal NIO buffer.- Specified by:
internalNioBuffer
in classByteBuf
-
nioBuffer
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. -
nioBuffers
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:
-
consolidate
Consolidate the composedByteBuf
s -
consolidate
Consolidate the composedByteBuf
s- Parameters:
cIndex
- the index on which to start to composenumComponents
- the number of components to compose
-
consolidate0
private void consolidate0(int cIndex, int numComponents) -
discardReadComponents
Discard allByteBuf
s which are read. -
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
-
allocBuffer
-
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
Description copied from class:ByteBuf
Sets thereaderIndex
of this buffer.- Overrides:
readerIndex
in classAbstractByteBuf
-
writerIndex
Description copied from class:ByteBuf
Sets thewriterIndex
of this buffer.- Overrides:
writerIndex
in classAbstractByteBuf
-
setIndex
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
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
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
Description copied from class:ByteBuf
Repositions the currentreaderIndex
to the markedreaderIndex
in this buffer.- Overrides:
resetReaderIndex
in classAbstractByteBuf
-
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
Description copied from class:ByteBuf
Repositions the currentwriterIndex
to the markedwriterIndex
in this buffer.- Overrides:
resetWriterIndex
in classAbstractByteBuf
-
ensureWritable
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:
-
getBytes
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
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
- Parameters:
length
- the number of bytes to transfer
-
getBytes
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
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
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
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
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
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
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
- Parameters:
length
- the number of bytes to transfer
-
setBytes
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
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
- Parameters:
length
- the number of NULs to write to the buffer
-
readBytes
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
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
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
- Parameters:
dstIndex
- the first index of the destinationlength
- the number of bytes to transfer
-
readBytes
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
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
- Parameters:
dstIndex
- the first index of the destinationlength
- the number of bytes to transfer
-
readBytes
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
Description copied from class:ByteBuf
Transfers this buffer's data to the specified stream starting at the currentreaderIndex
.- Overrides:
readBytes
in classAbstractByteBuf
- Parameters:
length
- the number of bytes to transfer- Throws:
IOException
- if the specified stream threw an exception during I/O
-
skipBytes
Description copied from class:ByteBuf
Increases the currentreaderIndex
by the specifiedlength
in this buffer.- Overrides:
skipBytes
in classAbstractByteBuf
-
writeBoolean
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
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
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
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
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
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
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
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
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
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
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
- Parameters:
length
- the number of bytes to transfer
-
writeBytes
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
- Parameters:
srcIndex
- the first index of the sourcelength
- the number of bytes to transfer
-
writeBytes
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
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
- Parameters:
srcIndex
- the first index of the sourcelength
- the number of bytes to transfer
-
writeBytes
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
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
Description copied from interface:ReferenceCounted
Increases the reference count by the specifiedincrement
.- Specified by:
retain
in interfaceReferenceCounted
- Overrides:
retain
in classAbstractReferenceCountedByteBuf
-
retain
Description copied from interface:ReferenceCounted
Increases the reference count by1
.- Specified by:
retain
in interfaceReferenceCounted
- Overrides:
retain
in classAbstractReferenceCountedByteBuf
-
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
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
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:
-
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
-
isAccessible
boolean isAccessible()Description copied from class:ByteBuf
Used internally byAbstractByteBuf.ensureAccessible()
to try to guard against using the buffer after it was released (best-effort).- Overrides:
isAccessible
in classAbstractReferenceCountedByteBuf
-
unwrap
Description copied from class:ByteBuf
Return the underlying buffer instance if this buffer is a wrapper of another buffer. -
clearComps
private void clearComps() -
removeComp
private void removeComp(int i) -
removeCompRange
private void removeCompRange(int from, int to) -
addComp
-
shiftComps
private void shiftComps(int i, int count)
-