public class CompositeByteBuf extends AbstractReferenceCountedByteBuf implements java.lang.Iterable<ByteBuf>
ByteBufAllocator.compositeBuffer()
or Unpooled.wrappedBuffer(ByteBuf...)
instead of calling the
constructor explicitly.构造器和说明 |
---|
CompositeByteBuf(ByteBufAllocator alloc,
boolean direct,
int maxNumComponents) |
CompositeByteBuf(ByteBufAllocator alloc,
boolean direct,
int maxNumComponents,
ByteBuf... buffers) |
CompositeByteBuf(ByteBufAllocator alloc,
boolean direct,
int maxNumComponents,
java.lang.Iterable<ByteBuf> buffers) |
限定符和类型 | 方法和说明 |
---|---|
protected byte |
_getByte(int index) |
protected int |
_getInt(int index) |
protected long |
_getLong(int index) |
protected short |
_getShort(int index) |
protected int |
_getUnsignedMedium(int index) |
protected void |
_setByte(int index,
int value) |
protected void |
_setInt(int index,
int value) |
protected void |
_setLong(int index,
long value) |
protected void |
_setMedium(int index,
int value) |
protected void |
_setShort(int index,
int value) |
CompositeByteBuf |
addComponent(boolean increaseWriterIndex,
ByteBuf buffer)
|
CompositeByteBuf |
addComponent(boolean increaseWriterIndex,
int cIndex,
ByteBuf buffer)
Add the given
ByteBuf on the specific index and increase the writerIndex
if increaseWriterIndex is true . |
CompositeByteBuf |
addComponent(ByteBuf buffer)
Add the given
ByteBuf . |
CompositeByteBuf |
addComponent(int cIndex,
ByteBuf buffer)
Add the given
ByteBuf on the specific index. |
CompositeByteBuf |
addComponents(boolean increaseWriterIndex,
ByteBuf... buffers)
|
CompositeByteBuf |
addComponents(boolean increaseWriterIndex,
java.lang.Iterable<ByteBuf> buffers)
|
CompositeByteBuf |
addComponents(ByteBuf... buffers)
Add the given
ByteBuf s. |
CompositeByteBuf |
addComponents(int cIndex,
ByteBuf... buffers)
Add the given
ByteBuf s on the specific index
Be aware that this method does not increase the writerIndex of the CompositeByteBuf . |
CompositeByteBuf |
addComponents(int cIndex,
java.lang.Iterable<ByteBuf> buffers)
Add the given
ByteBuf s on the specific index
Be aware that this method does not increase the writerIndex of the CompositeByteBuf . |
CompositeByteBuf |
addComponents(java.lang.Iterable<ByteBuf> buffers)
Add the given
ByteBuf s. |
ByteBufAllocator |
alloc()
Returns the
ByteBufAllocator which created this buffer. |
byte[] |
array()
Returns the backing byte array of this buffer.
|
int |
arrayOffset()
Returns the offset of the first byte within the backing byte array of
this buffer.
|
int |
capacity()
Returns the number of bytes (octets) this buffer can contain.
|
CompositeByteBuf |
capacity(int newCapacity)
Adjusts the capacity of this buffer.
|
CompositeByteBuf |
clear()
Sets the
readerIndex and writerIndex of this buffer to
0 . |
ByteBuf |
component(int cIndex)
Return the
ByteBuf on the specified index |
ByteBuf |
componentAtOffset(int offset)
Return the
ByteBuf on the specified index |
CompositeByteBuf |
consolidate()
Consolidate the composed
ByteBuf s |
CompositeByteBuf |
consolidate(int cIndex,
int numComponents)
Consolidate the composed
ByteBuf s |
ByteBuf |
copy(int index,
int length)
Returns a copy of this buffer's sub-region.
|
protected void |
deallocate()
Called once
AbstractReferenceCountedByteBuf.refCnt() is equals 0. |
java.util.List<ByteBuf> |
decompose(int offset,
int length)
Same with
AbstractByteBuf.slice(int, int) except that this method returns a list. |
CompositeByteBuf |
discardReadBytes()
Discards the bytes between the 0th index and
readerIndex . |
CompositeByteBuf |
discardReadComponents()
Discard all
ByteBuf s which are read. |
CompositeByteBuf |
discardSomeReadBytes()
Similar to
ByteBuf.discardReadBytes() except that this method might discard
some, all, or none of read bytes depending on its internal implementation to reduce
overall memory bandwidth consumption at the cost of potentially additional memory
consumption. |
CompositeByteBuf |
ensureWritable(int minWritableBytes)
Makes sure the number of the writable bytes
is equal to or greater than the specified value.
|
byte |
getByte(int index)
Gets a byte at the specified absolute
index in this buffer. |
CompositeByteBuf |
getBytes(int index,
byte[] dst)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index . |
CompositeByteBuf |
getBytes(int index,
byte[] dst,
int dstIndex,
int length)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index . |
CompositeByteBuf |
getBytes(int index,
ByteBuf dst)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index until the destination becomes
non-writable. |
CompositeByteBuf |
getBytes(int index,
java.nio.ByteBuffer dst)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index until the destination's position
reaches its limit. |
CompositeByteBuf |
getBytes(int index,
ByteBuf dst,
int length)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index . |
CompositeByteBuf |
getBytes(int index,
ByteBuf dst,
int dstIndex,
int length)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index . |
int |
getBytes(int index,
java.nio.channels.GatheringByteChannel out,
int length)
Transfers this buffer's data to the specified channel starting at the
specified absolute
index . |
CompositeByteBuf |
getBytes(int index,
java.io.OutputStream out,
int length)
Transfers this buffer's data to the specified stream starting at the
specified absolute
index . |
boolean |
hasArray()
Returns
true if and only if this buffer has a backing byte array. |
boolean |
hasMemoryAddress()
Returns
true if and only if this buffer has a reference to the low-level memory address that points
to the backing data. |
ByteBuf |
internalComponent(int cIndex)
Return the internal
ByteBuf on the specified index. |
ByteBuf |
internalComponentAtOffset(int offset)
Return the internal
ByteBuf on the specified offset. |
java.nio.ByteBuffer |
internalNioBuffer(int index,
int length)
Internal use only: Exposes the internal NIO buffer.
|
boolean |
isDirect()
Returns
true if and only if this buffer is backed by an
NIO direct buffer. |
java.util.Iterator<ByteBuf> |
iterator() |
CompositeByteBuf |
markReaderIndex()
Marks the current
readerIndex in this buffer. |
CompositeByteBuf |
markWriterIndex()
Marks the current
writerIndex in this buffer. |
int |
maxNumComponents()
Return the max number of
ByteBuf 's that are composed in this instance |
long |
memoryAddress()
Returns the low-level memory address that point to the first byte of ths backing data.
|
java.nio.ByteBuffer |
nioBuffer(int index,
int length)
Exposes this buffer's sub-region as an NIO
ByteBuffer . |
int |
nioBufferCount()
Returns the maximum number of NIO
ByteBuffer s that consist this buffer. |
java.nio.ByteBuffer[] |
nioBuffers()
Exposes this buffer's readable bytes as an NIO
ByteBuffer 's. |
java.nio.ByteBuffer[] |
nioBuffers(int index,
int length)
Exposes this buffer's bytes as an NIO
ByteBuffer 's for the specified index and length
The returned buffer either share or contains the copied content of this buffer, while changing
the position and limit of the returned NIO buffer does not affect the indexes and marks of this buffer. |
int |
numComponents()
Return the current number of
ByteBuf 's that are composed in this instance |
java.nio.ByteOrder |
order()
Returns the endianness
of this buffer.
|
CompositeByteBuf |
readBytes(byte[] dst)
Transfers this buffer's data to the specified destination starting at
the current
readerIndex and increases the readerIndex
by the number of the transferred bytes (= dst.length ). |
CompositeByteBuf |
readBytes(byte[] dst,
int dstIndex,
int length)
Transfers this buffer's data to the specified destination starting at
the current
readerIndex and increases the readerIndex
by the number of the transferred bytes (= length ). |
CompositeByteBuf |
readBytes(ByteBuf dst)
Transfers this buffer's data to the specified destination starting at
the current
readerIndex until the destination becomes
non-writable, and increases the readerIndex by the number of the
transferred bytes. |
CompositeByteBuf |
readBytes(java.nio.ByteBuffer dst)
Transfers this buffer's data to the specified destination starting at
the current
readerIndex until the destination's position
reaches its limit, and increases the readerIndex by the
number of the transferred bytes. |
CompositeByteBuf |
readBytes(ByteBuf dst,
int length)
Transfers this buffer's data to the specified destination starting at
the current
readerIndex and increases the readerIndex
by the number of the transferred bytes (= length ). |
CompositeByteBuf |
readBytes(ByteBuf dst,
int dstIndex,
int length)
Transfers this buffer's data to the specified destination starting at
the current
readerIndex and increases the readerIndex
by the number of the transferred bytes (= length ). |
CompositeByteBuf |
readBytes(java.io.OutputStream out,
int length)
Transfers this buffer's data to the specified stream starting at the
current
readerIndex . |
CompositeByteBuf |
readerIndex(int readerIndex)
Sets the
readerIndex of this buffer. |
CompositeByteBuf |
removeComponent(int cIndex)
Remove the
ByteBuf from the given index. |
CompositeByteBuf |
removeComponents(int cIndex,
int numComponents)
Remove the number of
ByteBuf s starting from the given index. |
CompositeByteBuf |
resetReaderIndex()
Repositions the current
readerIndex to the marked
readerIndex in this buffer. |
CompositeByteBuf |
resetWriterIndex()
Repositions the current
writerIndex to the marked
writerIndex in this buffer. |
CompositeByteBuf |
retain()
Increases the reference count by
1 . |
CompositeByteBuf |
retain(int increment)
Increases the reference count by the specified
increment . |
CompositeByteBuf |
setBoolean(int index,
boolean value)
Sets the specified boolean at the specified absolute
index in this
buffer. |
CompositeByteBuf |
setByte(int index,
int value)
Sets the specified byte at the specified absolute
index in this
buffer. |
CompositeByteBuf |
setBytes(int index,
byte[] src)
Transfers the specified source array's data to this buffer starting at
the specified absolute
index . |
CompositeByteBuf |
setBytes(int index,
byte[] src,
int srcIndex,
int length)
Transfers the specified source array's data to this buffer starting at
the specified absolute
index . |
CompositeByteBuf |
setBytes(int index,
ByteBuf src)
Transfers the specified source buffer's data to this buffer starting at
the specified absolute
index until the source buffer becomes
unreadable. |
CompositeByteBuf |
setBytes(int index,
java.nio.ByteBuffer src)
Transfers the specified source buffer's data to this buffer starting at
the specified absolute
index until the source buffer's position
reaches its limit. |
CompositeByteBuf |
setBytes(int index,
ByteBuf src,
int length)
Transfers the specified source buffer's data to this buffer starting at
the specified absolute
index . |
CompositeByteBuf |
setBytes(int index,
ByteBuf src,
int srcIndex,
int length)
Transfers the specified source buffer's data to this buffer starting at
the specified absolute
index . |
int |
setBytes(int index,
java.io.InputStream in,
int length)
Transfers the content of the specified source stream to this buffer
starting at the specified absolute
index . |
int |
setBytes(int index,
java.nio.channels.ScatteringByteChannel in,
int length)
Transfers the content of the specified source channel to this buffer
starting at the specified absolute
index . |
CompositeByteBuf |
setChar(int index,
int value)
Sets the specified 2-byte UTF-16 character at the specified absolute
index in this buffer. |
CompositeByteBuf |
setDouble(int index,
double value)
Sets the specified 64-bit floating-point number at the specified
absolute
index in this buffer. |
CompositeByteBuf |
setFloat(int index,
float value)
Sets the specified 32-bit floating-point number at the specified
absolute
index in this buffer. |
CompositeByteBuf |
setIndex(int readerIndex,
int writerIndex)
Sets the
readerIndex and writerIndex of this buffer
in one shot. |
CompositeByteBuf |
setInt(int index,
int value)
Sets the specified 32-bit integer at the specified absolute
index in this buffer. |
CompositeByteBuf |
setLong(int index,
long value)
Sets the specified 64-bit long integer at the specified absolute
index in this buffer. |
CompositeByteBuf |
setMedium(int index,
int value)
Sets the specified 24-bit medium integer at the specified absolute
index in this buffer. |
CompositeByteBuf |
setShort(int index,
int value)
Sets the specified 16-bit short integer at the specified absolute
index in this buffer. |
CompositeByteBuf |
setZero(int index,
int length)
Fills this buffer with NUL (0x00) starting at the specified
absolute
index . |
CompositeByteBuf |
skipBytes(int length)
Increases the current
readerIndex by the specified
length in this buffer. |
int |
toByteIndex(int cIndex) |
int |
toComponentIndex(int offset)
Return the index for the given offset
|
java.lang.String |
toString()
Returns the string representation of this buffer.
|
ByteBuf |
unwrap()
Return the underlying buffer instance if this buffer is a wrapper of another buffer.
|
CompositeByteBuf |
writeBoolean(boolean value)
Sets the specified boolean at the current
writerIndex
and increases the writerIndex by 1 in this buffer. |
CompositeByteBuf |
writeByte(int value)
Sets the specified byte at the current
writerIndex
and increases the writerIndex by 1 in this buffer. |
CompositeByteBuf |
writeBytes(byte[] src)
Transfers the specified source array's data to this buffer starting at
the current
writerIndex and increases the writerIndex
by the number of the transferred bytes (= src.length ). |
CompositeByteBuf |
writeBytes(byte[] src,
int srcIndex,
int length)
Transfers the specified source array's data to this buffer starting at
the current
writerIndex and increases the writerIndex
by the number of the transferred bytes (= length ). |
CompositeByteBuf |
writeBytes(ByteBuf src)
Transfers the specified source buffer's data to this buffer starting at
the current
writerIndex until the source buffer becomes
unreadable, and increases the writerIndex by the number of
the transferred bytes. |
CompositeByteBuf |
writeBytes(java.nio.ByteBuffer src)
Transfers the specified source buffer's data to this buffer starting at
the current
writerIndex until the source buffer's position
reaches its limit, and increases the writerIndex by the
number of the transferred bytes. |
CompositeByteBuf |
writeBytes(ByteBuf src,
int length)
Transfers the specified source buffer's data to this buffer starting at
the current
writerIndex and increases the writerIndex
by the number of the transferred bytes (= length ). |
CompositeByteBuf |
writeBytes(ByteBuf src,
int srcIndex,
int length)
Transfers the specified source buffer's data to this buffer starting at
the current
writerIndex and increases the writerIndex
by the number of the transferred bytes (= length ). |
CompositeByteBuf |
writeChar(int value)
Sets the specified 2-byte UTF-16 character at the current
writerIndex and increases the writerIndex by 2
in this buffer. |
CompositeByteBuf |
writeDouble(double value)
Sets the specified 64-bit floating point number at the current
writerIndex and increases the writerIndex by 8
in this buffer. |
CompositeByteBuf |
writeFloat(float value)
Sets the specified 32-bit floating point number at the current
writerIndex and increases the writerIndex by 4
in this buffer. |
CompositeByteBuf |
writeInt(int value)
Sets the specified 32-bit integer at the current
writerIndex
and increases the writerIndex by 4 in this buffer. |
CompositeByteBuf |
writeLong(long value)
Sets the specified 64-bit long integer at the current
writerIndex and increases the writerIndex by 8
in this buffer. |
CompositeByteBuf |
writeMedium(int value)
Sets the specified 24-bit medium integer at the current
writerIndex and increases the writerIndex by 3
in this buffer. |
CompositeByteBuf |
writerIndex(int writerIndex)
Sets the
writerIndex of this buffer. |
CompositeByteBuf |
writeShort(int value)
Sets the specified 16-bit short integer at the current
writerIndex and increases the writerIndex by 2
in this buffer. |
CompositeByteBuf |
writeZero(int length)
Fills this buffer with NUL (0x00) starting at the current
writerIndex and increases the writerIndex by the
specified length . |
refCnt, release, release, setRefCnt
adjustMarkers, bytesBefore, bytesBefore, bytesBefore, checkDstIndex, checkIndex, checkIndex, checkNewCapacity, checkReadableBytes, checkSrcIndex, compareTo, copy, duplicate, ensureAccessible, ensureWritable, equals, forEachByte, forEachByte, forEachByteDesc, forEachByteDesc, getBoolean, getChar, getDouble, getFloat, getInt, getLong, getMedium, getShort, getUnsignedByte, getUnsignedInt, getUnsignedMedium, getUnsignedShort, hashCode, indexOf, isReadable, isReadable, isWritable, isWritable, maxCapacity, maxCapacity, maxWritableBytes, newSwappedByteBuf, nioBuffer, order, readableBytes, readBoolean, readByte, readBytes, readBytes, readChar, readDouble, readerIndex, readFloat, readInt, readLong, readMedium, readShort, readSlice, readUnsignedByte, readUnsignedInt, readUnsignedMedium, readUnsignedShort, slice, slice, toString, toString, writableBytes, writeBytes, writeBytes, writerIndex
public CompositeByteBuf(ByteBufAllocator alloc, boolean direct, int maxNumComponents)
public CompositeByteBuf(ByteBufAllocator alloc, boolean direct, int maxNumComponents, ByteBuf... buffers)
public CompositeByteBuf(ByteBufAllocator alloc, boolean direct, int maxNumComponents, java.lang.Iterable<ByteBuf> buffers)
public CompositeByteBuf addComponent(ByteBuf buffer)
ByteBuf
.
Be aware that this method does not increase the writerIndex
of the CompositeByteBuf
.
If you need to have it increased use addComponent(boolean, ByteBuf)
.
ReferenceCounted.release()
ownership of buffer
is transfered to this CompositeByteBuf
.
buffer
- the ByteBuf
to add. ReferenceCounted.release()
ownership is transfered to this
CompositeByteBuf
.public CompositeByteBuf addComponents(ByteBuf... buffers)
ByteBuf
s.
Be aware that this method does not increase the writerIndex
of the CompositeByteBuf
.
If you need to have it increased use addComponents(boolean, ByteBuf[])
.
ReferenceCounted.release()
ownership of all ByteBuf
objects in buffers
is transfered to this
CompositeByteBuf
.
buffers
- the ByteBuf
s to add. ReferenceCounted.release()
ownership of all ReferenceCounted.release()
ownership of all ByteBuf
objects is transfered to this CompositeByteBuf
.public CompositeByteBuf addComponents(java.lang.Iterable<ByteBuf> buffers)
ByteBuf
s.
Be aware that this method does not increase the writerIndex
of the CompositeByteBuf
.
If you need to have it increased use addComponents(boolean, Iterable)
.
ReferenceCounted.release()
ownership of all ByteBuf
objects in buffers
is transfered to this
CompositeByteBuf
.
buffers
- the ByteBuf
s to add. ReferenceCounted.release()
ownership of all ReferenceCounted.release()
ownership of all ByteBuf
objects is transfered to this CompositeByteBuf
.public CompositeByteBuf addComponent(int cIndex, ByteBuf buffer)
ByteBuf
on the specific index.
Be aware that this method does not increase the writerIndex
of the CompositeByteBuf
.
If you need to have it increased use addComponent(boolean, int, ByteBuf)
.
ReferenceCounted.release()
ownership of buffer
is transfered to this CompositeByteBuf
.
cIndex
- the index on which the ByteBuf
will be added.buffer
- the ByteBuf
to add. ReferenceCounted.release()
ownership is transfered to this
CompositeByteBuf
.public CompositeByteBuf addComponent(boolean increaseWriterIndex, ByteBuf buffer)
ByteBuf
and increase the writerIndex
if increaseWriterIndex
is
true
.
ReferenceCounted.release()
ownership of buffer
is transfered to this CompositeByteBuf
.buffer
- the ByteBuf
to add. ReferenceCounted.release()
ownership is transfered to this
CompositeByteBuf
.public CompositeByteBuf addComponents(boolean increaseWriterIndex, ByteBuf... buffers)
ByteBuf
s and increase the writerIndex
if increaseWriterIndex
is
true
.
ReferenceCounted.release()
ownership of all ByteBuf
objects in buffers
is transfered to this
CompositeByteBuf
.buffers
- the ByteBuf
s to add. ReferenceCounted.release()
ownership of all ReferenceCounted.release()
ownership of all ByteBuf
objects is transfered to this CompositeByteBuf
.public CompositeByteBuf addComponents(boolean increaseWriterIndex, java.lang.Iterable<ByteBuf> buffers)
ByteBuf
s and increase the writerIndex
if increaseWriterIndex
is
true
.
ReferenceCounted.release()
ownership of all ByteBuf
objects in buffers
is transfered to this
CompositeByteBuf
.buffers
- the ByteBuf
s to add. ReferenceCounted.release()
ownership of all ReferenceCounted.release()
ownership of all ByteBuf
objects is transfered to this CompositeByteBuf
.public CompositeByteBuf addComponent(boolean increaseWriterIndex, int cIndex, ByteBuf buffer)
ByteBuf
on the specific index and increase the writerIndex
if increaseWriterIndex
is true
.
ReferenceCounted.release()
ownership of buffer
is transfered to this CompositeByteBuf
.cIndex
- the index on which the ByteBuf
will be added.buffer
- the ByteBuf
to add. ReferenceCounted.release()
ownership is transfered to this
CompositeByteBuf
.public CompositeByteBuf addComponents(int cIndex, ByteBuf... buffers)
ByteBuf
s on the specific index
Be aware that this method does not increase the writerIndex
of the CompositeByteBuf
.
If you need to have it increased you need to handle it by your own.
ReferenceCounted.release()
ownership of all ByteBuf
objects in buffers
is transfered to this
CompositeByteBuf
.
cIndex
- the index on which the ByteBuf
will be added. ReferenceCounted.release()
ownership of all
ReferenceCounted.release()
ownership of all ByteBuf
objects is transfered to this
CompositeByteBuf
.buffers
- the ByteBuf
s to add. ReferenceCounted.release()
ownership of all ReferenceCounted.release()
ownership of all ByteBuf
objects is transfered to this CompositeByteBuf
.public CompositeByteBuf addComponents(int cIndex, java.lang.Iterable<ByteBuf> buffers)
ByteBuf
s on the specific index
Be aware that this method does not increase the writerIndex
of the CompositeByteBuf
.
If you need to have it increased you need to handle it by your own.
ReferenceCounted.release()
ownership of all ByteBuf
objects in buffers
is transfered to this
CompositeByteBuf
.
cIndex
- the index on which the ByteBuf
will be added.buffers
- the ByteBuf
s to add. ReferenceCounted.release()
ownership of all
ReferenceCounted.release()
ownership of all ByteBuf
objects is transfered to this
CompositeByteBuf
.public CompositeByteBuf removeComponent(int cIndex)
ByteBuf
from the given index.cIndex
- the index on from which the ByteBuf
will be removepublic CompositeByteBuf removeComponents(int cIndex, int numComponents)
ByteBuf
s starting from the given index.cIndex
- the index on which the ByteBuf
s will be started to removednumComponents
- the number of components to removepublic java.util.Iterator<ByteBuf> iterator()
iterator
在接口中 java.lang.Iterable<ByteBuf>
public java.util.List<ByteBuf> decompose(int offset, int length)
AbstractByteBuf.slice(int, int)
except that this method returns a list.public boolean isDirect()
ByteBuf
true
if and only if this buffer is backed by an
NIO direct buffer.public boolean hasArray()
ByteBuf
true
if and only if this buffer has a backing byte array.
If this method returns true, you can safely call ByteBuf.array()
and
ByteBuf.arrayOffset()
.public byte[] array()
ByteBuf
public int arrayOffset()
ByteBuf
arrayOffset
在类中 ByteBuf
public boolean hasMemoryAddress()
ByteBuf
true
if and only if this buffer has a reference to the low-level memory address that points
to the backing data.hasMemoryAddress
在类中 ByteBuf
public long memoryAddress()
ByteBuf
memoryAddress
在类中 ByteBuf
public int capacity()
ByteBuf
public CompositeByteBuf capacity(int newCapacity)
ByteBuf
newCapacity
is less than the current
capacity, the content of this buffer is truncated. If the newCapacity
is greater
than the current capacity, the buffer is appended with unspecified data whose length is
(newCapacity - currentCapacity)
.public ByteBufAllocator alloc()
ByteBuf
ByteBufAllocator
which created this buffer.public java.nio.ByteOrder order()
ByteBuf
public int numComponents()
ByteBuf
's that are composed in this instancepublic int maxNumComponents()
ByteBuf
's that are composed in this instancepublic int toComponentIndex(int offset)
public int toByteIndex(int cIndex)
public byte getByte(int index)
ByteBuf
index
in this buffer.
This method does not modify readerIndex
or writerIndex
of
this buffer.getByte
在类中 AbstractByteBuf
protected byte _getByte(int index)
_getByte
在类中 AbstractByteBuf
protected short _getShort(int index)
_getShort
在类中 AbstractByteBuf
protected int _getUnsignedMedium(int index)
_getUnsignedMedium
在类中 AbstractByteBuf
protected int _getInt(int index)
_getInt
在类中 AbstractByteBuf
protected long _getLong(int index)
_getLong
在类中 AbstractByteBuf
public CompositeByteBuf getBytes(int index, byte[] dst, int dstIndex, int length)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of this buffer.public CompositeByteBuf getBytes(int index, java.nio.ByteBuffer dst)
ByteBuf
index
until the destination's position
reaches its limit.
This method does not modify readerIndex
or writerIndex
of
this buffer while the destination's position
will be increased.public CompositeByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of both the source (i.e. this
) and the destination.public int getBytes(int index, java.nio.channels.GatheringByteChannel out, int length) throws java.io.IOException
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.public CompositeByteBuf getBytes(int index, java.io.OutputStream out, int length) throws java.io.IOException
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.public CompositeByteBuf setByte(int index, int value)
ByteBuf
index
in this
buffer. The 24 high-order bits of the specified value are ignored.
This method does not modify readerIndex
or writerIndex
of
this buffer.setByte
在类中 AbstractByteBuf
protected void _setByte(int index, int value)
_setByte
在类中 AbstractByteBuf
public CompositeByteBuf setShort(int index, int value)
ByteBuf
index
in this buffer. The 16 high-order bits of the specified
value are ignored.
This method does not modify readerIndex
or writerIndex
of
this buffer.setShort
在类中 AbstractByteBuf
protected void _setShort(int index, int value)
_setShort
在类中 AbstractByteBuf
public CompositeByteBuf setMedium(int index, int value)
ByteBuf
index
in this buffer. Please note that the most significant
byte is ignored in the specified value.
This method does not modify readerIndex
or writerIndex
of
this buffer.setMedium
在类中 AbstractByteBuf
protected void _setMedium(int index, int value)
_setMedium
在类中 AbstractByteBuf
public CompositeByteBuf setInt(int index, int value)
ByteBuf
index
in this buffer.
This method does not modify readerIndex
or writerIndex
of
this buffer.setInt
在类中 AbstractByteBuf
protected void _setInt(int index, int value)
_setInt
在类中 AbstractByteBuf
public CompositeByteBuf setLong(int index, long value)
ByteBuf
index
in this buffer.
This method does not modify readerIndex
or writerIndex
of
this buffer.setLong
在类中 AbstractByteBuf
protected void _setLong(int index, long value)
_setLong
在类中 AbstractByteBuf
public CompositeByteBuf setBytes(int index, byte[] src, int srcIndex, int length)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.public CompositeByteBuf setBytes(int index, java.nio.ByteBuffer src)
ByteBuf
index
until the source buffer's position
reaches its limit.
This method does not modify readerIndex
or writerIndex
of
this buffer.public CompositeByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of both the source (i.e. this
) and the destination.public int setBytes(int index, java.io.InputStream in, int length) throws java.io.IOException
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.public int setBytes(int index, java.nio.channels.ScatteringByteChannel in, int length) throws java.io.IOException
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.public ByteBuf copy(int index, int length)
ByteBuf
readerIndex
or writerIndex
of
this buffer.public ByteBuf componentAtOffset(int offset)
ByteBuf
on the specified indexpublic ByteBuf internalComponent(int cIndex)
ByteBuf
on the specified index. Note that updating the indexes of the returned
buffer will lead to an undefined behavior of this buffer.cIndex
- the index for which the ByteBuf
should be returnedpublic ByteBuf internalComponentAtOffset(int offset)
ByteBuf
on the specified offset. Note that updating the indexes of the returned
buffer will lead to an undefined behavior of this buffer.offset
- the offset for which the ByteBuf
should be returnedpublic int nioBufferCount()
ByteBuf
ByteBuffer
s that consist this buffer. Note that ByteBuf.nioBuffers()
or ByteBuf.nioBuffers(int, int)
might return a less number of ByteBuffer
s.nioBufferCount
在类中 ByteBuf
-1
if this buffer has no underlying ByteBuffer
.
the number of the underlying ByteBuffer
s if this buffer has at least one underlying
ByteBuffer
. Note that this method does not return 0
to avoid confusion.ByteBuf.nioBuffer()
,
ByteBuf.nioBuffer(int, int)
,
ByteBuf.nioBuffers()
,
ByteBuf.nioBuffers(int, int)
public java.nio.ByteBuffer internalNioBuffer(int index, int length)
ByteBuf
internalNioBuffer
在类中 ByteBuf
public java.nio.ByteBuffer nioBuffer(int index, int length)
ByteBuf
ByteBuffer
. The returned buffer
either share or contains the copied content of this buffer, while changing the position
and limit of the returned NIO buffer does not affect the indexes and marks of this buffer.
This method does not modify readerIndex
or writerIndex
of this buffer.
Please note that the returned NIO buffer will not see the changes of this buffer if this buffer
is a dynamic buffer and it adjusted its capacity.public java.nio.ByteBuffer[] nioBuffers(int index, int length)
ByteBuf
ByteBuffer
's for the specified index and length
The returned buffer either share or contains the copied content of this buffer, while changing
the position and limit of the returned NIO buffer does not affect the indexes and marks of this buffer.
This method does not modify readerIndex
or writerIndex
of this buffer. Please note that the
returned NIO buffer will not see the changes of this buffer if this buffer is a dynamic
buffer and it adjusted its capacity.public CompositeByteBuf consolidate()
ByteBuf
spublic CompositeByteBuf consolidate(int cIndex, int numComponents)
ByteBuf
scIndex
- the index on which to start to composenumComponents
- the number of components to composepublic CompositeByteBuf discardReadComponents()
ByteBuf
s which are read.public CompositeByteBuf discardReadBytes()
ByteBuf
readerIndex
.
It moves the bytes between readerIndex
and writerIndex
to the 0th index, and sets readerIndex
and writerIndex
to 0
and oldWriterIndex - oldReaderIndex
respectively.
Please refer to the class documentation for more detailed explanation.
discardReadBytes
在类中 AbstractByteBuf
public java.lang.String toString()
ByteBuf
ByteBuf.readerIndex()
,
ByteBuf.writerIndex()
and ByteBuf.capacity()
.toString
在类中 AbstractByteBuf
public CompositeByteBuf readerIndex(int readerIndex)
ByteBuf
readerIndex
of this buffer.readerIndex
在类中 AbstractByteBuf
public CompositeByteBuf writerIndex(int writerIndex)
ByteBuf
writerIndex
of this buffer.writerIndex
在类中 AbstractByteBuf
public CompositeByteBuf setIndex(int readerIndex, int writerIndex)
ByteBuf
readerIndex
and writerIndex
of this buffer
in one shot. This method is useful when you have to worry about the
invocation order of ByteBuf.readerIndex(int)
and ByteBuf.writerIndex(int)
methods. For example, the following code will fail:
// Create a buffer whose readerIndex, writerIndex and capacity are // 0, 0 and 8 respectively.The following code will also fail:ByteBuf
buf =Unpooled
.buffer(8); // IndexOutOfBoundsException is thrown because the specified // readerIndex (2) cannot be greater than the current writerIndex (0). buf.readerIndex(2); buf.writerIndex(4);
// Create a buffer whose readerIndex, writerIndex and capacity are // 0, 8 and 8 respectively.By contrast, this method guarantees that it never throws anByteBuf
buf =Unpooled
.wrappedBuffer(new byte[8]); // readerIndex becomes 8. buf.readLong(); // IndexOutOfBoundsException is thrown because the specified // writerIndex (4) cannot be less than the current readerIndex (8). buf.writerIndex(4); buf.readerIndex(2);
IndexOutOfBoundsException
as long as the specified
indexes meet basic constraints, regardless what the current index
values of the buffer are:
// No matter what the current state of the buffer is, the following // call always succeeds as long as the capacity of the buffer is not // less than 4. buf.setIndex(2, 4);
setIndex
在类中 AbstractByteBuf
public CompositeByteBuf clear()
ByteBuf
readerIndex
and writerIndex
of this buffer to
0
.
This method is identical to setIndex(0, 0)
.
Please note that the behavior of this method is different
from that of NIO buffer, which sets the limit
to
the capacity
of the buffer.
clear
在类中 AbstractByteBuf
public CompositeByteBuf markReaderIndex()
ByteBuf
readerIndex
in this buffer. You can
reposition the current readerIndex
to the marked
readerIndex
by calling ByteBuf.resetReaderIndex()
.
The initial value of the marked readerIndex
is 0
.markReaderIndex
在类中 AbstractByteBuf
public CompositeByteBuf resetReaderIndex()
ByteBuf
readerIndex
to the marked
readerIndex
in this buffer.resetReaderIndex
在类中 AbstractByteBuf
public CompositeByteBuf markWriterIndex()
ByteBuf
writerIndex
in this buffer. You can
reposition the current writerIndex
to the marked
writerIndex
by calling ByteBuf.resetWriterIndex()
.
The initial value of the marked writerIndex
is 0
.markWriterIndex
在类中 AbstractByteBuf
public CompositeByteBuf resetWriterIndex()
ByteBuf
writerIndex
to the marked
writerIndex
in this buffer.resetWriterIndex
在类中 AbstractByteBuf
public CompositeByteBuf ensureWritable(int minWritableBytes)
ByteBuf
IllegalArgumentException
.ensureWritable
在类中 AbstractByteBuf
minWritableBytes
- the expected minimum number of writable bytespublic CompositeByteBuf getBytes(int index, ByteBuf dst)
ByteBuf
index
until the destination becomes
non-writable. This method is basically same with
ByteBuf.getBytes(int, ByteBuf, int, int)
, except that this
method increases the writerIndex
of the destination by the
number of the transferred bytes while
ByteBuf.getBytes(int, ByteBuf, int, int)
does not.
This method does not modify readerIndex
or writerIndex
of
the source buffer (i.e. this
).getBytes
在类中 AbstractByteBuf
public CompositeByteBuf getBytes(int index, ByteBuf dst, int length)
ByteBuf
index
. This method is basically same
with ByteBuf.getBytes(int, ByteBuf, int, int)
, except that this
method increases the writerIndex
of the destination by the
number of the transferred bytes while
ByteBuf.getBytes(int, ByteBuf, int, int)
does not.
This method does not modify readerIndex
or writerIndex
of
the source buffer (i.e. this
).getBytes
在类中 AbstractByteBuf
length
- the number of bytes to transferpublic CompositeByteBuf getBytes(int index, byte[] dst)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffergetBytes
在类中 AbstractByteBuf
public CompositeByteBuf setBoolean(int index, boolean value)
ByteBuf
index
in this
buffer.
This method does not modify readerIndex
or writerIndex
of
this buffer.setBoolean
在类中 AbstractByteBuf
public CompositeByteBuf setChar(int index, int value)
ByteBuf
index
in this buffer.
The 16 high-order bits of the specified value are ignored.
This method does not modify readerIndex
or writerIndex
of
this buffer.setChar
在类中 AbstractByteBuf
public CompositeByteBuf setFloat(int index, float value)
ByteBuf
index
in this buffer.
This method does not modify readerIndex
or writerIndex
of
this buffer.setFloat
在类中 AbstractByteBuf
public CompositeByteBuf setDouble(int index, double value)
ByteBuf
index
in this buffer.
This method does not modify readerIndex
or writerIndex
of
this buffer.setDouble
在类中 AbstractByteBuf
public CompositeByteBuf setBytes(int index, ByteBuf src)
ByteBuf
index
until the source buffer becomes
unreadable. This method is basically same with
ByteBuf.setBytes(int, ByteBuf, int, int)
, except that this
method increases the readerIndex
of the source buffer by
the number of the transferred bytes while
ByteBuf.setBytes(int, ByteBuf, int, int)
does not.
This method does not modify readerIndex
or writerIndex
of
the source buffer (i.e. this
).setBytes
在类中 AbstractByteBuf
public CompositeByteBuf setBytes(int index, ByteBuf src, int length)
ByteBuf
index
. This method is basically same
with ByteBuf.setBytes(int, ByteBuf, int, int)
, except that this
method increases the readerIndex
of the source buffer by
the number of the transferred bytes while
ByteBuf.setBytes(int, ByteBuf, int, int)
does not.
This method does not modify readerIndex
or writerIndex
of
the source buffer (i.e. this
).setBytes
在类中 AbstractByteBuf
length
- the number of bytes to transferpublic CompositeByteBuf setBytes(int index, byte[] src)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.setBytes
在类中 AbstractByteBuf
public CompositeByteBuf setZero(int index, int length)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.setZero
在类中 AbstractByteBuf
length
- the number of NULs to write to the bufferpublic CompositeByteBuf readBytes(ByteBuf dst)
ByteBuf
readerIndex
until the destination becomes
non-writable, and increases the readerIndex
by the number of the
transferred bytes. This method is basically same with
ByteBuf.readBytes(ByteBuf, int, int)
, except that this method
increases the writerIndex
of the destination by the number of
the transferred bytes while ByteBuf.readBytes(ByteBuf, int, int)
does not.readBytes
在类中 AbstractByteBuf
public CompositeByteBuf readBytes(ByteBuf dst, int length)
ByteBuf
readerIndex
and increases the readerIndex
by the number of the transferred bytes (= length
). This method
is basically same with ByteBuf.readBytes(ByteBuf, int, int)
,
except that this method increases the writerIndex
of the
destination by the number of the transferred bytes (= length
)
while ByteBuf.readBytes(ByteBuf, int, int)
does not.readBytes
在类中 AbstractByteBuf
public CompositeByteBuf readBytes(ByteBuf dst, int dstIndex, int length)
ByteBuf
readerIndex
and increases the readerIndex
by the number of the transferred bytes (= length
).readBytes
在类中 AbstractByteBuf
dstIndex
- the first index of the destinationlength
- the number of bytes to transferpublic CompositeByteBuf readBytes(byte[] dst)
ByteBuf
readerIndex
and increases the readerIndex
by the number of the transferred bytes (= dst.length
).readBytes
在类中 AbstractByteBuf
public CompositeByteBuf readBytes(byte[] dst, int dstIndex, int length)
ByteBuf
readerIndex
and increases the readerIndex
by the number of the transferred bytes (= length
).readBytes
在类中 AbstractByteBuf
dstIndex
- the first index of the destinationlength
- the number of bytes to transferpublic CompositeByteBuf readBytes(java.nio.ByteBuffer dst)
ByteBuf
readerIndex
until the destination's position
reaches its limit, and increases the readerIndex
by the
number of the transferred bytes.readBytes
在类中 AbstractByteBuf
public CompositeByteBuf readBytes(java.io.OutputStream out, int length) throws java.io.IOException
ByteBuf
readerIndex
.readBytes
在类中 AbstractByteBuf
length
- the number of bytes to transferjava.io.IOException
- if the specified stream threw an exception during I/Opublic CompositeByteBuf skipBytes(int length)
ByteBuf
readerIndex
by the specified
length
in this buffer.skipBytes
在类中 AbstractByteBuf
public CompositeByteBuf writeBoolean(boolean value)
ByteBuf
writerIndex
and increases the writerIndex
by 1
in this buffer.writeBoolean
在类中 AbstractByteBuf
public CompositeByteBuf writeByte(int value)
ByteBuf
writerIndex
and increases the writerIndex
by 1
in this buffer.
The 24 high-order bits of the specified value are ignored.writeByte
在类中 AbstractByteBuf
public CompositeByteBuf writeShort(int value)
ByteBuf
writerIndex
and increases the writerIndex
by 2
in this buffer. The 16 high-order bits of the specified value are ignored.writeShort
在类中 AbstractByteBuf
public CompositeByteBuf writeMedium(int value)
ByteBuf
writerIndex
and increases the writerIndex
by 3
in this buffer.writeMedium
在类中 AbstractByteBuf
public CompositeByteBuf writeInt(int value)
ByteBuf
writerIndex
and increases the writerIndex
by 4
in this buffer.writeInt
在类中 AbstractByteBuf
public CompositeByteBuf writeLong(long value)
ByteBuf
writerIndex
and increases the writerIndex
by 8
in this buffer.writeLong
在类中 AbstractByteBuf
public CompositeByteBuf writeChar(int value)
ByteBuf
writerIndex
and increases the writerIndex
by 2
in this buffer. The 16 high-order bits of the specified value are ignored.writeChar
在类中 AbstractByteBuf
public CompositeByteBuf writeFloat(float value)
ByteBuf
writerIndex
and increases the writerIndex
by 4
in this buffer.writeFloat
在类中 AbstractByteBuf
public CompositeByteBuf writeDouble(double value)
ByteBuf
writerIndex
and increases the writerIndex
by 8
in this buffer.writeDouble
在类中 AbstractByteBuf
public CompositeByteBuf writeBytes(ByteBuf src)
ByteBuf
writerIndex
until the source buffer becomes
unreadable, and increases the writerIndex
by the number of
the transferred bytes. This method is basically same with
ByteBuf.writeBytes(ByteBuf, int, int)
, except that this method
increases the readerIndex
of the source buffer by the number of
the transferred bytes while ByteBuf.writeBytes(ByteBuf, int, int)
does not.writeBytes
在类中 AbstractByteBuf
public CompositeByteBuf writeBytes(ByteBuf src, int length)
ByteBuf
writerIndex
and increases the writerIndex
by the number of the transferred bytes (= length
). This method
is basically same with ByteBuf.writeBytes(ByteBuf, int, int)
,
except that this method increases the readerIndex
of the source
buffer by the number of the transferred bytes (= length
) while
ByteBuf.writeBytes(ByteBuf, int, int)
does not.writeBytes
在类中 AbstractByteBuf
length
- the number of bytes to transferpublic CompositeByteBuf writeBytes(ByteBuf src, int srcIndex, int length)
ByteBuf
writerIndex
and increases the writerIndex
by the number of the transferred bytes (= length
).writeBytes
在类中 AbstractByteBuf
srcIndex
- the first index of the sourcelength
- the number of bytes to transferpublic CompositeByteBuf writeBytes(byte[] src)
ByteBuf
writerIndex
and increases the writerIndex
by the number of the transferred bytes (= src.length
).writeBytes
在类中 AbstractByteBuf
public CompositeByteBuf writeBytes(byte[] src, int srcIndex, int length)
ByteBuf
writerIndex
and increases the writerIndex
by the number of the transferred bytes (= length
).writeBytes
在类中 AbstractByteBuf
srcIndex
- the first index of the sourcelength
- the number of bytes to transferpublic CompositeByteBuf writeBytes(java.nio.ByteBuffer src)
ByteBuf
writerIndex
until the source buffer's position
reaches its limit, and increases the writerIndex
by the
number of the transferred bytes.writeBytes
在类中 AbstractByteBuf
public CompositeByteBuf writeZero(int length)
ByteBuf
writerIndex
and increases the writerIndex
by the
specified length
.writeZero
在类中 AbstractByteBuf
length
- the number of NULs to write to the bufferpublic CompositeByteBuf retain(int increment)
ReferenceCounted
increment
.retain
在接口中 ReferenceCounted
retain
在类中 AbstractReferenceCountedByteBuf
public CompositeByteBuf retain()
ReferenceCounted
1
.retain
在接口中 ReferenceCounted
retain
在类中 AbstractReferenceCountedByteBuf
public java.nio.ByteBuffer[] nioBuffers()
ByteBuf
ByteBuffer
's. The returned buffer
either share or contains the copied content of this buffer, while changing the position
and limit of the returned NIO buffer does not affect the indexes and marks of this buffer.
This method does not modify readerIndex
or writerIndex
of this buffer.
Please note that the returned NIO buffer will not see the changes of this buffer if this buffer
is a dynamic buffer and it adjusted its capacity.public CompositeByteBuf discardSomeReadBytes()
ByteBuf
ByteBuf.discardReadBytes()
except that this method might discard
some, all, or none of read bytes depending on its internal implementation to reduce
overall memory bandwidth consumption at the cost of potentially additional memory
consumption.discardSomeReadBytes
在类中 AbstractByteBuf
protected void deallocate()
AbstractReferenceCountedByteBuf
AbstractReferenceCountedByteBuf.refCnt()
is equals 0.