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)CompositeByteBufaddComponent(boolean increaseWriterIndex, int cIndex, ByteBuf buffer)Add the givenByteBufon the specific index and increase thewriterIndexifincreaseWriterIndexistrue.CompositeByteBufaddComponent(boolean increaseWriterIndex, ByteBuf buffer)CompositeByteBufaddComponent(int cIndex, ByteBuf buffer)Add the givenByteBufon the specific index.CompositeByteBufaddComponent(ByteBuf buffer)Add the givenByteBuf.CompositeByteBufaddComponents(boolean increaseWriterIndex, ByteBuf... buffers)CompositeByteBufaddComponents(boolean increaseWriterIndex, java.lang.Iterable<ByteBuf> buffers)CompositeByteBufaddComponents(int cIndex, ByteBuf... buffers)Add the givenByteBufs on the specific indexCompositeByteBufaddComponents(int cIndex, java.lang.Iterable<ByteBuf> buffers)Add the givenByteBufs on the specific index Be aware that this method does not increase thewriterIndexof theCompositeByteBuf.CompositeByteBufaddComponents(ByteBuf... buffers)Add the givenByteBufs.CompositeByteBufaddComponents(java.lang.Iterable<ByteBuf> buffers)Add the givenByteBufs.CompositeByteBufaddFlattenedComponents(boolean increaseWriterIndex, ByteBuf buffer)ByteBufAllocatoralloc()Returns theByteBufAllocatorwhich created this buffer.byte[]array()Returns the backing byte array of this buffer.intarrayOffset()Returns the offset of the first byte within the backing byte array of this buffer.intcapacity()Returns the number of bytes (octets) this buffer can contain.CompositeByteBufcapacity(int newCapacity)Adjusts the capacity of this buffer.CompositeByteBufclear()Sets thereaderIndexandwriterIndexof this buffer to0.ByteBufcomponent(int cIndex)Return a duplicate of theByteBufon the specified component index.ByteBufcomponentAtOffset(int offset)Return theByteBufon the specified indexByteBufcomponentSlice(int cIndex)Return a slice of theByteBufon the specified component index.CompositeByteBufconsolidate()Consolidate the composedByteBufsCompositeByteBufconsolidate(int cIndex, int numComponents)Consolidate the composedByteBufsByteBufcopy(int index, int length)Returns a copy of this buffer's sub-region.protected voiddeallocate()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.CompositeByteBufdiscardReadBytes()Discards the bytes between the 0th index andreaderIndex.CompositeByteBufdiscardReadComponents()Discard allByteBufs which are read.CompositeByteBufdiscardSomeReadBytes()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.CompositeByteBufensureWritable(int minWritableBytes)Expands the bufferByteBuf.capacity()to make sure the number of writable bytes is equal to or greater than the specified value.protected intforEachByteAsc0(int start, int end, ByteProcessor processor)protected intforEachByteDesc0(int rStart, int rEnd, ByteProcessor processor)bytegetByte(int index)Gets a byte at the specified absoluteindexin this buffer.CompositeByteBufgetBytes(int index, byte[] dst)Transfers this buffer's data to the specified destination starting at the specified absoluteindex.CompositeByteBufgetBytes(int index, byte[] dst, int dstIndex, int length)Transfers this buffer's data to the specified destination starting at the specified absoluteindex.CompositeByteBufgetBytes(int index, ByteBuf dst)Transfers this buffer's data to the specified destination starting at the specified absoluteindexuntil the destination becomes non-writable.CompositeByteBufgetBytes(int index, ByteBuf dst, int length)Transfers this buffer's data to the specified destination starting at the specified absoluteindex.CompositeByteBufgetBytes(int index, ByteBuf dst, int dstIndex, int length)Transfers this buffer's data to the specified destination starting at the specified absoluteindex.CompositeByteBufgetBytes(int index, java.io.OutputStream out, int length)Transfers this buffer's data to the specified stream starting at the specified absoluteindex.CompositeByteBufgetBytes(int index, java.nio.ByteBuffer dst)Transfers this buffer's data to the specified destination starting at the specified absoluteindexuntil the destination's position reaches its limit.intgetBytes(int index, java.nio.channels.FileChannel out, long position, int length)Transfers this buffer's data starting at the specified absoluteindexto the specified channel starting at the given file position.intgetBytes(int index, java.nio.channels.GatheringByteChannel out, int length)Transfers this buffer's data to the specified channel starting at the specified absoluteindex.booleanhasArray()Returnstrueif and only if this buffer has a backing byte array.booleanhasMemoryAddress()Returnstrueif and only if this buffer has a reference to the low-level memory address that points to the backing data.ByteBufinternalComponent(int cIndex)Return the internalByteBufon the specified index.ByteBufinternalComponentAtOffset(int offset)Return the internalByteBufon the specified offset.java.nio.ByteBufferinternalNioBuffer(int index, int length)Internal use only: Exposes the internal NIO buffer.booleanisDirect()Returnstrueif and only if this buffer is backed by an NIO direct buffer.java.util.Iterator<ByteBuf>iterator()CompositeByteBufmarkReaderIndex()Marks the currentreaderIndexin this buffer.CompositeByteBufmarkWriterIndex()Marks the currentwriterIndexin this buffer.intmaxNumComponents()Return the max number ofByteBuf's that are composed in this instancelongmemoryAddress()Returns the low-level memory address that point to the first byte of ths backing data.java.nio.ByteBuffernioBuffer(int index, int length)Exposes this buffer's sub-region as an NIOByteBuffer.intnioBufferCount()Returns the maximum number of NIOByteBuffers 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.intnumComponents()Return the current number ofByteBuf's that are composed in this instancejava.nio.ByteOrderorder()Returns the endianness of this buffer.CompositeByteBufreadBytes(byte[] dst)Transfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=dst.length).CompositeByteBufreadBytes(byte[] dst, int dstIndex, int length)Transfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length).CompositeByteBufreadBytes(ByteBuf dst)Transfers this buffer's data to the specified destination starting at the currentreaderIndexuntil the destination becomes non-writable, and increases thereaderIndexby the number of the transferred bytes.CompositeByteBufreadBytes(ByteBuf dst, int length)Transfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length).CompositeByteBufreadBytes(ByteBuf dst, int dstIndex, int length)Transfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length).CompositeByteBufreadBytes(java.io.OutputStream out, int length)Transfers this buffer's data to the specified stream starting at the currentreaderIndex.CompositeByteBufreadBytes(java.nio.ByteBuffer dst)Transfers this buffer's data to the specified destination starting at the currentreaderIndexuntil the destination's position reaches its limit, and increases thereaderIndexby the number of the transferred bytes.CompositeByteBufreaderIndex(int readerIndex)Sets thereaderIndexof this buffer.CompositeByteBufremoveComponent(int cIndex)Remove theByteBuffrom the given index.CompositeByteBufremoveComponents(int cIndex, int numComponents)Remove the number ofByteBufs starting from the given index.CompositeByteBufresetReaderIndex()Repositions the currentreaderIndexto the markedreaderIndexin this buffer.CompositeByteBufresetWriterIndex()Repositions the currentwriterIndexto the markedwriterIndexin this buffer.CompositeByteBufretain()Increases the reference count by1.CompositeByteBufretain(int increment)Increases the reference count by the specifiedincrement.CompositeByteBufsetBoolean(int index, boolean value)Sets the specified boolean at the specified absoluteindexin this buffer.CompositeByteBufsetByte(int index, int value)Sets the specified byte at the specified absoluteindexin this buffer.CompositeByteBufsetBytes(int index, byte[] src)Transfers the specified source array's data to this buffer starting at the specified absoluteindex.CompositeByteBufsetBytes(int index, byte[] src, int srcIndex, int length)Transfers the specified source array's data to this buffer starting at the specified absoluteindex.CompositeByteBufsetBytes(int index, ByteBuf src)Transfers the specified source buffer's data to this buffer starting at the specified absoluteindexuntil the source buffer becomes unreadable.CompositeByteBufsetBytes(int index, ByteBuf src, int length)Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex.CompositeByteBufsetBytes(int index, ByteBuf src, int srcIndex, int length)Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex.intsetBytes(int index, java.io.InputStream in, int length)Transfers the content of the specified source stream to this buffer starting at the specified absoluteindex.CompositeByteBufsetBytes(int index, java.nio.ByteBuffer src)Transfers the specified source buffer's data to this buffer starting at the specified absoluteindexuntil the source buffer's position reaches its limit.intsetBytes(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.intsetBytes(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.CompositeByteBufsetChar(int index, int value)Sets the specified 2-byte UTF-16 character at the specified absoluteindexin this buffer.CompositeByteBufsetDouble(int index, double value)Sets the specified 64-bit floating-point number at the specified absoluteindexin this buffer.CompositeByteBufsetFloat(int index, float value)Sets the specified 32-bit floating-point number at the specified absoluteindexin this buffer.CompositeByteBufsetIndex(int readerIndex, int writerIndex)Sets thereaderIndexandwriterIndexof this buffer in one shot.CompositeByteBufsetInt(int index, int value)Sets the specified 32-bit integer at the specified absoluteindexin this buffer.CompositeByteBufsetLong(int index, long value)Sets the specified 64-bit long integer at the specified absoluteindexin this buffer.CompositeByteBufsetMedium(int index, int value)Sets the specified 24-bit medium integer at the specified absoluteindexin this buffer.CompositeByteBufsetShort(int index, int value)Sets the specified 16-bit short integer at the specified absoluteindexin this buffer.CompositeByteBufsetZero(int index, int length)Fills this buffer with NUL (0x00) starting at the specified absoluteindex.CompositeByteBufskipBytes(int length)Increases the currentreaderIndexby the specifiedlengthin this buffer.inttoByteIndex(int cIndex)inttoComponentIndex(int offset)Return the index for the given offsetjava.lang.StringtoString()Returns the string representation of this buffer.CompositeByteBuftouch()Records the current access location of this object for debugging purposes.CompositeByteBuftouch(java.lang.Object hint)Records the current access location of this object with an additional arbitrary information for debugging purposes.ByteBufunwrap()Return the underlying buffer instance if this buffer is a wrapper of another buffer.CompositeByteBufwriteBoolean(boolean value)Sets the specified boolean at the currentwriterIndexand increases thewriterIndexby1in this buffer.CompositeByteBufwriteByte(int value)Sets the specified byte at the currentwriterIndexand increases thewriterIndexby1in this buffer.CompositeByteBufwriteBytes(byte[] src)Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=src.length).CompositeByteBufwriteBytes(byte[] src, int srcIndex, int length)Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).CompositeByteBufwriteBytes(ByteBuf src)Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexuntil the source buffer becomes unreadable, and increases thewriterIndexby the number of the transferred bytes.CompositeByteBufwriteBytes(ByteBuf src, int length)Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).CompositeByteBufwriteBytes(ByteBuf src, int srcIndex, int length)Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).CompositeByteBufwriteBytes(java.nio.ByteBuffer src)Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexuntil the source buffer's position reaches its limit, and increases thewriterIndexby the number of the transferred bytes.CompositeByteBufwriteChar(int value)Sets the specified 2-byte UTF-16 character at the currentwriterIndexand increases thewriterIndexby2in this buffer.CompositeByteBufwriteDouble(double value)Sets the specified 64-bit floating point number at the currentwriterIndexand increases thewriterIndexby8in this buffer.CompositeByteBufwriteFloat(float value)Sets the specified 32-bit floating point number at the currentwriterIndexand increases thewriterIndexby4in this buffer.CompositeByteBufwriteInt(int value)Sets the specified 32-bit integer at the currentwriterIndexand increases thewriterIndexby4in this buffer.CompositeByteBufwriteLong(long value)Sets the specified 64-bit long integer at the currentwriterIndexand increases thewriterIndexby8in this buffer.CompositeByteBufwriteMedium(int value)Sets the specified 24-bit medium integer at the currentwriterIndexand increases thewriterIndexby3in this buffer.CompositeByteBufwriterIndex(int writerIndex)Sets thewriterIndexof this buffer.CompositeByteBufwriteShort(int value)Sets the specified 16-bit short integer at the currentwriterIndexand increases thewriterIndexby2in this buffer.CompositeByteBufwriteZero(int length)Fills this buffer with NUL (0x00) starting at the currentwriterIndexand increases thewriterIndexby 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, readString, 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
writerIndexof theCompositeByteBuf. If you need to have it increased useaddComponent(boolean, ByteBuf).ReferenceCounted.release()ownership ofbufferis transferred to thisCompositeByteBuf.- Parameters:
buffer- theByteBufto add.ReferenceCounted.release()ownership is transferred to thisCompositeByteBuf.
-
addComponents
public CompositeByteBuf addComponents(ByteBuf... buffers)
Add the givenByteBufs.Be aware that this method does not increase the
writerIndexof theCompositeByteBuf. If you need to have it increased useaddComponents(boolean, ByteBuf[]).ReferenceCounted.release()ownership of allByteBufobjects inbuffersis transferred to thisCompositeByteBuf.- Parameters:
buffers- theByteBufs to add.ReferenceCounted.release()ownership of allReferenceCounted.release()ownership of allByteBufobjects is transferred to thisCompositeByteBuf.
-
addComponents
public CompositeByteBuf addComponents(java.lang.Iterable<ByteBuf> buffers)
Add the givenByteBufs.Be aware that this method does not increase the
writerIndexof theCompositeByteBuf. If you need to have it increased useaddComponents(boolean, Iterable).ReferenceCounted.release()ownership of allByteBufobjects inbuffersis transferred to thisCompositeByteBuf.- Parameters:
buffers- theByteBufs to add.ReferenceCounted.release()ownership of allReferenceCounted.release()ownership of allByteBufobjects is transferred to thisCompositeByteBuf.
-
addComponent
public CompositeByteBuf addComponent(int cIndex, ByteBuf buffer)
Add the givenByteBufon the specific index.Be aware that this method does not increase the
writerIndexof theCompositeByteBuf. If you need to have it increased useaddComponent(boolean, int, ByteBuf).ReferenceCounted.release()ownership ofbufferis transferred to thisCompositeByteBuf.- Parameters:
cIndex- the index on which theByteBufwill be added.buffer- theByteBufto add.ReferenceCounted.release()ownership is transferred to thisCompositeByteBuf.
-
addComponent
public CompositeByteBuf addComponent(boolean increaseWriterIndex, ByteBuf buffer)
Add the givenByteBufand increase thewriterIndexifincreaseWriterIndexistrue.ReferenceCounted.release()ownership ofbufferis transferred to thisCompositeByteBuf.- Parameters:
buffer- theByteBufto add.ReferenceCounted.release()ownership is transferred to thisCompositeByteBuf.
-
addComponents
public CompositeByteBuf addComponents(boolean increaseWriterIndex, ByteBuf... buffers)
Add the givenByteBufs and increase thewriterIndexifincreaseWriterIndexistrue.ReferenceCounted.release()ownership of allByteBufobjects inbuffersis transferred to thisCompositeByteBuf.- Parameters:
buffers- theByteBufs to add.ReferenceCounted.release()ownership of allReferenceCounted.release()ownership of allByteBufobjects is transferred to thisCompositeByteBuf.
-
addComponents
public CompositeByteBuf addComponents(boolean increaseWriterIndex, java.lang.Iterable<ByteBuf> buffers)
Add the givenByteBufs and increase thewriterIndexifincreaseWriterIndexistrue.ReferenceCounted.release()ownership of allByteBufobjects inbuffersis transferred to thisCompositeByteBuf.- Parameters:
buffers- theByteBufs to add.ReferenceCounted.release()ownership of allReferenceCounted.release()ownership of allByteBufobjects is transferred to thisCompositeByteBuf.
-
addComponent
public CompositeByteBuf addComponent(boolean increaseWriterIndex, int cIndex, ByteBuf buffer)
Add the givenByteBufon the specific index and increase thewriterIndexifincreaseWriterIndexistrue.ReferenceCounted.release()ownership ofbufferis transferred to thisCompositeByteBuf.- Parameters:
cIndex- the index on which theByteBufwill be added.buffer- theByteBufto add.ReferenceCounted.release()ownership is transferred to thisCompositeByteBuf.
-
addComponents
public CompositeByteBuf addComponents(int cIndex, ByteBuf... buffers)
Add the givenByteBufs on the specific indexBe aware that this method does not increase the
writerIndexof theCompositeByteBuf. If you need to have it increased you need to handle it by your own.ReferenceCounted.release()ownership of allByteBufobjects inbuffersis transferred to thisCompositeByteBuf.- Parameters:
cIndex- the index on which theByteBufwill be added.ReferenceCounted.release()ownership of allReferenceCounted.release()ownership of allByteBufobjects is transferred to thisCompositeByteBuf.buffers- theByteBufs to add.ReferenceCounted.release()ownership of allReferenceCounted.release()ownership of allByteBufobjects is transferred to thisCompositeByteBuf.
-
addComponents
public CompositeByteBuf addComponents(int cIndex, java.lang.Iterable<ByteBuf> buffers)
Add the givenByteBufs on the specific index Be aware that this method does not increase thewriterIndexof theCompositeByteBuf. If you need to have it increased you need to handle it by your own.ReferenceCounted.release()ownership of allByteBufobjects inbuffersis transferred to thisCompositeByteBuf.- Parameters:
cIndex- the index on which theByteBufwill be added.buffers- theByteBufs to add.ReferenceCounted.release()ownership of allReferenceCounted.release()ownership of allByteBufobjects is transferred to thisCompositeByteBuf.
-
addFlattenedComponents
public CompositeByteBuf addFlattenedComponents(boolean increaseWriterIndex, ByteBuf buffer)
Add the givenByteBufand increase thewriterIndexifincreaseWriterIndexistrue. If the provided buffer is aCompositeByteBufitself, 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 ofbufferis transferred to thisCompositeByteBuf.- Parameters:
buffer- theByteBufto add.ReferenceCounted.release()ownership is transferred to thisCompositeByteBuf.
-
removeComponent
public CompositeByteBuf removeComponent(int cIndex)
Remove theByteBuffrom the given index.- Parameters:
cIndex- the index on from which theByteBufwill be remove
-
removeComponents
public CompositeByteBuf removeComponents(int cIndex, int numComponents)
Remove the number ofByteBufs starting from the given index.- Parameters:
cIndex- the index on which theByteBufs will be started to removednumComponents- the number of components to remove
-
iterator
public java.util.Iterator<ByteBuf> iterator()
- Specified by:
iteratorin 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:ByteBufReturnstrueif and only if this buffer is backed by an NIO direct buffer.
-
hasArray
public boolean hasArray()
Description copied from class:ByteBufReturnstrueif 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:ByteBufReturns the backing byte array of this buffer.
-
arrayOffset
public int arrayOffset()
Description copied from class:ByteBufReturns the offset of the first byte within the backing byte array of this buffer.- Specified by:
arrayOffsetin classByteBuf
-
hasMemoryAddress
public boolean hasMemoryAddress()
Description copied from class:ByteBufReturnstrueif and only if this buffer has a reference to the low-level memory address that points to the backing data.- Specified by:
hasMemoryAddressin classByteBuf
-
memoryAddress
public long memoryAddress()
Description copied from class:ByteBufReturns the low-level memory address that point to the first byte of ths backing data.- Specified by:
memoryAddressin classByteBuf
-
capacity
public int capacity()
Description copied from class:ByteBufReturns the number of bytes (octets) this buffer can contain.
-
capacity
public CompositeByteBuf capacity(int newCapacity)
Description copied from class:ByteBufAdjusts the capacity of this buffer. If thenewCapacityis less than the current capacity, the content of this buffer is truncated. If thenewCapacityis 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:ByteBufReturns theByteBufAllocatorwhich created this buffer.
-
order
public java.nio.ByteOrder order()
Description copied from class:ByteBufReturns 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:ByteBufGets a byte at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
getBytein classAbstractByteBuf
-
_getByte
protected byte _getByte(int index)
- Specified by:
_getBytein classAbstractByteBuf
-
_getShort
protected short _getShort(int index)
- Specified by:
_getShortin classAbstractByteBuf
-
_getShortLE
protected short _getShortLE(int index)
- Specified by:
_getShortLEin classAbstractByteBuf
-
_getUnsignedMedium
protected int _getUnsignedMedium(int index)
- Specified by:
_getUnsignedMediumin classAbstractByteBuf
-
_getUnsignedMediumLE
protected int _getUnsignedMediumLE(int index)
- Specified by:
_getUnsignedMediumLEin classAbstractByteBuf
-
_getInt
protected int _getInt(int index)
- Specified by:
_getIntin classAbstractByteBuf
-
_getIntLE
protected int _getIntLE(int index)
- Specified by:
_getIntLEin classAbstractByteBuf
-
_getLong
protected long _getLong(int index)
- Specified by:
_getLongin classAbstractByteBuf
-
_getLongLE
protected long _getLongLE(int index)
- Specified by:
_getLongLEin classAbstractByteBuf
-
getBytes
public CompositeByteBuf getBytes(int index, byte[] dst, int dstIndex, int length)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
getBytes
public CompositeByteBuf getBytes(int index, java.nio.ByteBuffer dst)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the specified absoluteindexuntil the destination's position reaches its limit. This method does not modifyreaderIndexorwriterIndexof this buffer while the destination'spositionwill be increased.
-
getBytes
public CompositeByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof 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.IOExceptionDescription copied from class:ByteBufTransfers this buffer's data to the specified channel starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
getBytes
public int getBytes(int index, java.nio.channels.FileChannel out, long position, int length) throws java.io.IOExceptionDescription copied from class:ByteBufTransfers this buffer's data starting at the specified absoluteindexto the specified channel starting at the given file position. This method does not modifyreaderIndexorwriterIndexof this buffer. This method does not modify the channel's position.- Specified by:
getBytesin classByteBufposition- 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:ByteBufTransfers this buffer's data to the specified stream starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setByte
public CompositeByteBuf setByte(int index, int value)
Description copied from class:ByteBufSets the specified byte at the specified absoluteindexin this buffer. The 24 high-order bits of the specified value are ignored. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setBytein classAbstractByteBuf
-
_setByte
protected void _setByte(int index, int value)- Specified by:
_setBytein classAbstractByteBuf
-
setShort
public CompositeByteBuf setShort(int index, int value)
Description copied from class:ByteBufSets the specified 16-bit short integer at the specified absoluteindexin this buffer. The 16 high-order bits of the specified value are ignored. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setShortin classAbstractByteBuf
-
_setShort
protected void _setShort(int index, int value)- Specified by:
_setShortin classAbstractByteBuf
-
_setShortLE
protected void _setShortLE(int index, int value)- Specified by:
_setShortLEin classAbstractByteBuf
-
setMedium
public CompositeByteBuf setMedium(int index, int value)
Description copied from class:ByteBufSets the specified 24-bit medium integer at the specified absoluteindexin this buffer. Please note that the most significant byte is ignored in the specified value. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setMediumin classAbstractByteBuf
-
_setMedium
protected void _setMedium(int index, int value)- Specified by:
_setMediumin classAbstractByteBuf
-
_setMediumLE
protected void _setMediumLE(int index, int value)- Specified by:
_setMediumLEin classAbstractByteBuf
-
setInt
public CompositeByteBuf setInt(int index, int value)
Description copied from class:ByteBufSets the specified 32-bit integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setIntin classAbstractByteBuf
-
_setInt
protected void _setInt(int index, int value)- Specified by:
_setIntin classAbstractByteBuf
-
_setIntLE
protected void _setIntLE(int index, int value)- Specified by:
_setIntLEin classAbstractByteBuf
-
setLong
public CompositeByteBuf setLong(int index, long value)
Description copied from class:ByteBufSets the specified 64-bit long integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setLongin classAbstractByteBuf
-
_setLong
protected void _setLong(int index, long value)- Specified by:
_setLongin classAbstractByteBuf
-
_setLongLE
protected void _setLongLE(int index, long value)- Specified by:
_setLongLEin classAbstractByteBuf
-
setBytes
public CompositeByteBuf setBytes(int index, byte[] src, int srcIndex, int length)
Description copied from class:ByteBufTransfers the specified source array's data to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setBytes
public CompositeByteBuf setBytes(int index, java.nio.ByteBuffer src)
Description copied from class:ByteBufTransfers the specified source buffer's data to this buffer starting at the specified absoluteindexuntil the source buffer's position reaches its limit. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setBytes
public CompositeByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length)
Description copied from class:ByteBufTransfers the specified source buffer's data to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof both the source (i.e.this) and the destination.
-
setBytes
public int setBytes(int index, java.io.InputStream in, int length) throws java.io.IOExceptionDescription copied from class:ByteBufTransfers the content of the specified source stream to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setBytes
public int setBytes(int index, java.nio.channels.ScatteringByteChannel in, int length) throws java.io.IOExceptionDescription copied from class:ByteBufTransfers the content of the specified source channel to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setBytes
public int setBytes(int index, java.nio.channels.FileChannel in, long position, int length) throws java.io.IOExceptionDescription copied from class:ByteBufTransfers 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 modifyreaderIndexorwriterIndexof this buffer. This method does not modify the channel's position.- Specified by:
setBytesin classByteBufposition- 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.
-1if the specified channel is closed or 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:ByteBufReturns 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 modifyreaderIndexorwriterIndexof this buffer.
-
component
public ByteBuf component(int cIndex)
Return a duplicate of theByteBufon the specified component index.Note that this method returns a shallow duplicate of the underlying component buffer. The returned buffer's
readerIndexandwriterIndexwill be independent of the composite buffer's indices and will not be adjusted to reflect the component's view within the composite buffer.If you need a buffer that represents the component's readable view as seen from the composite buffer, use
componentSlice(int cIndex)instead.
-
componentSlice
public ByteBuf componentSlice(int cIndex)
Return a slice of theByteBufon the specified component index.This method provides a view of the component that reflects its state within the composite buffer. The returned buffer's readable bytes will correspond to the bytes that this component contributes to the composite buffer's capacity. The slice will have its own independent
readerIndexandwriterIndex, starting at0.
-
componentAtOffset
public ByteBuf componentAtOffset(int offset)
Return theByteBufon the specified index
-
internalComponent
public ByteBuf internalComponent(int cIndex)
Return the internalByteBufon 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 theByteBufshould be returned
-
internalComponentAtOffset
public ByteBuf internalComponentAtOffset(int offset)
Return the internalByteBufon 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 theByteBufshould be returned
-
nioBufferCount
public int nioBufferCount()
Description copied from class:ByteBufReturns the maximum number of NIOByteBuffers that consist this buffer. Note thatByteBuf.nioBuffers()orByteBuf.nioBuffers(int, int)might return a less number ofByteBuffers.- Specified by:
nioBufferCountin classByteBuf- Returns:
-1if this buffer has no underlyingByteBuffer. the number of the underlyingByteBuffers if this buffer has at least one underlyingByteBuffer. Note that this method does not return0to 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:ByteBufInternal use only: Exposes the internal NIO buffer.- Specified by:
internalNioBufferin classByteBuf
-
nioBuffer
public java.nio.ByteBuffer nioBuffer(int index, int length)Description copied from class:ByteBufExposes 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 modifyreaderIndexorwriterIndexof 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:
nioBufferin 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:ByteBufExposes 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 modifyreaderIndexorwriterIndexof 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:
nioBuffersin classByteBuf- See Also:
ByteBuf.nioBufferCount(),ByteBuf.nioBuffer(),ByteBuf.nioBuffer(int, int)
-
consolidate
public CompositeByteBuf consolidate()
Consolidate the composedByteBufs
-
consolidate
public CompositeByteBuf consolidate(int cIndex, int numComponents)
Consolidate the composedByteBufs- Parameters:
cIndex- the index on which to start to composenumComponents- the number of components to compose
-
discardReadComponents
public CompositeByteBuf discardReadComponents()
Discard allByteBufs which are read.
-
discardReadBytes
public CompositeByteBuf discardReadBytes()
Description copied from class:ByteBufDiscards the bytes between the 0th index andreaderIndex. It moves the bytes betweenreaderIndexandwriterIndexto the 0th index, and setsreaderIndexandwriterIndexto0andoldWriterIndex - oldReaderIndexrespectively.Please refer to the class documentation for more detailed explanation.
- Overrides:
discardReadBytesin classAbstractByteBuf
-
toString
public java.lang.String toString()
Description copied from class:ByteBufReturns 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:
toStringin classAbstractByteBuf
-
readerIndex
public CompositeByteBuf readerIndex(int readerIndex)
Description copied from class:ByteBufSets thereaderIndexof this buffer.- Overrides:
readerIndexin classAbstractByteBuf
-
writerIndex
public CompositeByteBuf writerIndex(int writerIndex)
Description copied from class:ByteBufSets thewriterIndexof this buffer.- Overrides:
writerIndexin classAbstractByteBuf
-
setIndex
public CompositeByteBuf setIndex(int readerIndex, int writerIndex)
Description copied from class:ByteBufSets thereaderIndexandwriterIndexof 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:ByteBufbuf =Unpooled.buffer(8); // IndexOutOfBoundsException is thrown because the specified // readerIndex (2) cannot be greater than the current writerIndex (0). buf.readerIndex(2); buf.writerIndex(4);// Create a buffer whose readerIndex, writerIndex and capacity are // 0, 8 and 8 respectively.
By contrast, this method guarantees that it never throws anByteBufbuf =Unpooled.wrappedBuffer(new byte[8]); // readerIndex becomes 8. buf.readLong(); // IndexOutOfBoundsException is thrown because the specified // writerIndex (4) cannot be less than the current readerIndex (8). buf.writerIndex(4); buf.readerIndex(2);IndexOutOfBoundsExceptionas 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:
setIndexin classAbstractByteBuf
-
clear
public CompositeByteBuf clear()
Description copied from class:ByteBufSets thereaderIndexandwriterIndexof 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
limitto thecapacityof the buffer.- Overrides:
clearin classAbstractByteBuf
-
markReaderIndex
public CompositeByteBuf markReaderIndex()
Description copied from class:ByteBufMarks the currentreaderIndexin this buffer. You can reposition the currentreaderIndexto the markedreaderIndexby callingByteBuf.resetReaderIndex(). The initial value of the markedreaderIndexis0.- Overrides:
markReaderIndexin classAbstractByteBuf
-
resetReaderIndex
public CompositeByteBuf resetReaderIndex()
Description copied from class:ByteBufRepositions the currentreaderIndexto the markedreaderIndexin this buffer.- Overrides:
resetReaderIndexin classAbstractByteBuf
-
markWriterIndex
public CompositeByteBuf markWriterIndex()
Description copied from class:ByteBufMarks the currentwriterIndexin this buffer. You can reposition the currentwriterIndexto the markedwriterIndexby callingByteBuf.resetWriterIndex(). The initial value of the markedwriterIndexis0.- Overrides:
markWriterIndexin classAbstractByteBuf
-
resetWriterIndex
public CompositeByteBuf resetWriterIndex()
Description copied from class:ByteBufRepositions the currentwriterIndexto the markedwriterIndexin this buffer.- Overrides:
resetWriterIndexin classAbstractByteBuf
-
ensureWritable
public CompositeByteBuf ensureWritable(int minWritableBytes)
Description copied from class:ByteBufExpands 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:
ensureWritablein 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:ByteBufTransfers this buffer's data to the specified destination starting at the specified absoluteindexuntil the destination becomes non-writable. This method is basically same withByteBuf.getBytes(int, ByteBuf, int, int), except that this method increases thewriterIndexof the destination by the number of the transferred bytes whileByteBuf.getBytes(int, ByteBuf, int, int)does not. This method does not modifyreaderIndexorwriterIndexof the source buffer (i.e.this).- Overrides:
getBytesin classAbstractByteBuf
-
getBytes
public CompositeByteBuf getBytes(int index, ByteBuf dst, int length)
Description copied from class:ByteBufTransfers 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 thewriterIndexof the destination by the number of the transferred bytes whileByteBuf.getBytes(int, ByteBuf, int, int)does not. This method does not modifyreaderIndexorwriterIndexof the source buffer (i.e.this).- Overrides:
getBytesin classAbstractByteBuflength- the number of bytes to transfer
-
getBytes
public CompositeByteBuf getBytes(int index, byte[] dst)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer- Overrides:
getBytesin classAbstractByteBuf
-
setBoolean
public CompositeByteBuf setBoolean(int index, boolean value)
Description copied from class:ByteBufSets the specified boolean at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setBooleanin classAbstractByteBuf
-
setChar
public CompositeByteBuf setChar(int index, int value)
Description copied from class:ByteBufSets the specified 2-byte UTF-16 character at the specified absoluteindexin this buffer. The 16 high-order bits of the specified value are ignored. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setCharin classAbstractByteBuf
-
setFloat
public CompositeByteBuf setFloat(int index, float value)
Description copied from class:ByteBufSets the specified 32-bit floating-point number at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setFloatin classAbstractByteBuf
-
setDouble
public CompositeByteBuf setDouble(int index, double value)
Description copied from class:ByteBufSets the specified 64-bit floating-point number at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setDoublein classAbstractByteBuf
-
setBytes
public CompositeByteBuf setBytes(int index, ByteBuf src)
Description copied from class:ByteBufTransfers the specified source buffer's data to this buffer starting at the specified absoluteindexuntil the source buffer becomes unreadable. This method is basically same withByteBuf.setBytes(int, ByteBuf, int, int), except that this method increases thereaderIndexof the source buffer by the number of the transferred bytes whileByteBuf.setBytes(int, ByteBuf, int, int)does not. This method does not modifyreaderIndexorwriterIndexof this buffer (i.e.this).- Overrides:
setBytesin classAbstractByteBuf
-
setBytes
public CompositeByteBuf setBytes(int index, ByteBuf src, int length)
Description copied from class:ByteBufTransfers 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 thereaderIndexof the source buffer by the number of the transferred bytes whileByteBuf.setBytes(int, ByteBuf, int, int)does not. This method does not modifyreaderIndexorwriterIndexof this buffer (i.e.this).- Overrides:
setBytesin classAbstractByteBuflength- the number of bytes to transfer
-
setBytes
public CompositeByteBuf setBytes(int index, byte[] src)
Description copied from class:ByteBufTransfers the specified source array's data to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setBytesin classAbstractByteBuf
-
setZero
public CompositeByteBuf setZero(int index, int length)
Description copied from class:ByteBufFills this buffer with NUL (0x00) starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setZeroin classAbstractByteBuflength- the number of NULs to write to the buffer
-
readBytes
public CompositeByteBuf readBytes(ByteBuf dst)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the currentreaderIndexuntil the destination becomes non-writable, and increases thereaderIndexby the number of the transferred bytes. This method is basically same withByteBuf.readBytes(ByteBuf, int, int), except that this method increases thewriterIndexof the destination by the number of the transferred bytes whileByteBuf.readBytes(ByteBuf, int, int)does not.- Overrides:
readBytesin classAbstractByteBuf
-
readBytes
public CompositeByteBuf readBytes(ByteBuf dst, int length)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length). This method is basically same withByteBuf.readBytes(ByteBuf, int, int), except that this method increases thewriterIndexof the destination by the number of the transferred bytes (=length) whileByteBuf.readBytes(ByteBuf, int, int)does not.- Overrides:
readBytesin classAbstractByteBuf
-
readBytes
public CompositeByteBuf readBytes(ByteBuf dst, int dstIndex, int length)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length).- Overrides:
readBytesin classAbstractByteBufdstIndex- the first index of the destinationlength- the number of bytes to transfer
-
readBytes
public CompositeByteBuf readBytes(byte[] dst)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=dst.length).- Overrides:
readBytesin classAbstractByteBuf
-
readBytes
public CompositeByteBuf readBytes(byte[] dst, int dstIndex, int length)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length).- Overrides:
readBytesin classAbstractByteBufdstIndex- the first index of the destinationlength- the number of bytes to transfer
-
readBytes
public CompositeByteBuf readBytes(java.nio.ByteBuffer dst)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the currentreaderIndexuntil the destination's position reaches its limit, and increases thereaderIndexby the number of the transferred bytes.- Overrides:
readBytesin classAbstractByteBuf
-
readBytes
public CompositeByteBuf readBytes(java.io.OutputStream out, int length) throws java.io.IOException
Description copied from class:ByteBufTransfers this buffer's data to the specified stream starting at the currentreaderIndex.- Overrides:
readBytesin classAbstractByteBuflength- 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:ByteBufIncreases the currentreaderIndexby the specifiedlengthin this buffer.- Overrides:
skipBytesin classAbstractByteBuf
-
writeBoolean
public CompositeByteBuf writeBoolean(boolean value)
Description copied from class:ByteBufSets the specified boolean at the currentwriterIndexand increases thewriterIndexby1in this buffer. Ifthis.writableBytesis less than1,ByteBuf.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Overrides:
writeBooleanin classAbstractByteBuf
-
writeByte
public CompositeByteBuf writeByte(int value)
Description copied from class:ByteBufSets the specified byte at the currentwriterIndexand increases thewriterIndexby1in this buffer. The 24 high-order bits of the specified value are ignored. Ifthis.writableBytesis less than1,ByteBuf.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Overrides:
writeBytein classAbstractByteBuf
-
writeShort
public CompositeByteBuf writeShort(int value)
Description copied from class:ByteBufSets the specified 16-bit short integer at the currentwriterIndexand increases thewriterIndexby2in this buffer. The 16 high-order bits of the specified value are ignored. Ifthis.writableBytesis less than2,ByteBuf.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Overrides:
writeShortin classAbstractByteBuf
-
writeMedium
public CompositeByteBuf writeMedium(int value)
Description copied from class:ByteBufSets the specified 24-bit medium integer at the currentwriterIndexand increases thewriterIndexby3in this buffer. Ifthis.writableBytesis less than3,ByteBuf.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Overrides:
writeMediumin classAbstractByteBuf
-
writeInt
public CompositeByteBuf writeInt(int value)
Description copied from class:ByteBufSets the specified 32-bit integer at the currentwriterIndexand increases thewriterIndexby4in this buffer. Ifthis.writableBytesis less than4,ByteBuf.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Overrides:
writeIntin classAbstractByteBuf
-
writeLong
public CompositeByteBuf writeLong(long value)
Description copied from class:ByteBufSets the specified 64-bit long integer at the currentwriterIndexand increases thewriterIndexby8in this buffer. Ifthis.writableBytesis less than8,ByteBuf.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Overrides:
writeLongin classAbstractByteBuf
-
writeChar
public CompositeByteBuf writeChar(int value)
Description copied from class:ByteBufSets the specified 2-byte UTF-16 character at the currentwriterIndexand increases thewriterIndexby2in this buffer. The 16 high-order bits of the specified value are ignored. Ifthis.writableBytesis less than2,ByteBuf.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Overrides:
writeCharin classAbstractByteBuf
-
writeFloat
public CompositeByteBuf writeFloat(float value)
Description copied from class:ByteBufSets the specified 32-bit floating point number at the currentwriterIndexand increases thewriterIndexby4in this buffer. Ifthis.writableBytesis less than4,ByteBuf.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Overrides:
writeFloatin classAbstractByteBuf
-
writeDouble
public CompositeByteBuf writeDouble(double value)
Description copied from class:ByteBufSets the specified 64-bit floating point number at the currentwriterIndexand increases thewriterIndexby8in this buffer. Ifthis.writableBytesis less than8,ByteBuf.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Overrides:
writeDoublein classAbstractByteBuf
-
writeBytes
public CompositeByteBuf writeBytes(ByteBuf src)
Description copied from class:ByteBufTransfers the specified source buffer's data to this buffer starting at the currentwriterIndexuntil the source buffer becomes unreadable, and increases thewriterIndexby the number of the transferred bytes. This method is basically same withByteBuf.writeBytes(ByteBuf, int, int), except that this method increases thereaderIndexof the source buffer by the number of the transferred bytes whileByteBuf.writeBytes(ByteBuf, int, int)does not. Ifthis.writableBytesis less thansrc.readableBytes,ByteBuf.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Overrides:
writeBytesin classAbstractByteBuf
-
writeBytes
public CompositeByteBuf writeBytes(ByteBuf src, int length)
Description copied from class:ByteBufTransfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length). This method is basically same withByteBuf.writeBytes(ByteBuf, int, int), except that this method increases thereaderIndexof the source buffer by the number of the transferred bytes (=length) whileByteBuf.writeBytes(ByteBuf, int, int)does not. Ifthis.writableBytesis less thanlength,ByteBuf.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Overrides:
writeBytesin classAbstractByteBuflength- the number of bytes to transfer
-
writeBytes
public CompositeByteBuf writeBytes(ByteBuf src, int srcIndex, int length)
Description copied from class:ByteBufTransfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length). Ifthis.writableBytesis less thanlength,ByteBuf.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Overrides:
writeBytesin classAbstractByteBufsrcIndex- the first index of the sourcelength- the number of bytes to transfer
-
writeBytes
public CompositeByteBuf writeBytes(byte[] src)
Description copied from class:ByteBufTransfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=src.length). Ifthis.writableBytesis less thansrc.length,ByteBuf.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Overrides:
writeBytesin classAbstractByteBuf
-
writeBytes
public CompositeByteBuf writeBytes(byte[] src, int srcIndex, int length)
Description copied from class:ByteBufTransfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length). Ifthis.writableBytesis less thanlength,ByteBuf.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Overrides:
writeBytesin classAbstractByteBufsrcIndex- the first index of the sourcelength- the number of bytes to transfer
-
writeBytes
public CompositeByteBuf writeBytes(java.nio.ByteBuffer src)
Description copied from class:ByteBufTransfers the specified source buffer's data to this buffer starting at the currentwriterIndexuntil the source buffer's position reaches its limit, and increases thewriterIndexby the number of the transferred bytes. Ifthis.writableBytesis less thansrc.remaining(),ByteBuf.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Overrides:
writeBytesin classAbstractByteBuf
-
writeZero
public CompositeByteBuf writeZero(int length)
Description copied from class:ByteBufFills this buffer with NUL (0x00) starting at the currentwriterIndexand increases thewriterIndexby the specifiedlength. Ifthis.writableBytesis less thanlength,ByteBuf.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Overrides:
writeZeroin classAbstractByteBuf- Parameters:
length- the number of NULs to write to the buffer
-
retain
public CompositeByteBuf retain(int increment)
Description copied from interface:ReferenceCountedIncreases the reference count by the specifiedincrement.- Specified by:
retainin interfaceReferenceCounted- Overrides:
retainin classAbstractReferenceCountedByteBuf
-
retain
public CompositeByteBuf retain()
Description copied from interface:ReferenceCountedIncreases the reference count by1.- Specified by:
retainin interfaceReferenceCounted- Overrides:
retainin classAbstractReferenceCountedByteBuf
-
touch
public CompositeByteBuf touch()
Description copied from interface:ReferenceCountedRecords 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:
touchin interfaceReferenceCounted- Overrides:
touchin classAbstractReferenceCountedByteBuf
-
touch
public CompositeByteBuf touch(java.lang.Object hint)
Description copied from interface:ReferenceCountedRecords 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:
touchin interfaceReferenceCounted- Overrides:
touchin classAbstractReferenceCountedByteBuf
-
nioBuffers
public java.nio.ByteBuffer[] nioBuffers()
Description copied from class:ByteBufExposes 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 modifyreaderIndexorwriterIndexof 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:
nioBuffersin classAbstractByteBuf- See Also:
ByteBuf.nioBufferCount(),ByteBuf.nioBuffer(),ByteBuf.nioBuffer(int, int)
-
discardSomeReadBytes
public CompositeByteBuf discardSomeReadBytes()
Description copied from class:ByteBufSimilar 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:
discardSomeReadBytesin classAbstractByteBuf
-
deallocate
protected void deallocate()
Description copied from class:AbstractReferenceCountedByteBufCalled onceAbstractReferenceCountedByteBuf.refCnt()is equals 0.- Specified by:
deallocatein classAbstractReferenceCountedByteBuf
-
-