public class DynamicCompositeByteBuf extends Object
ByteBuf, and it can be read just like a normal ByteBuf.
it can be constructed by one or many readable ByteBuf,
reference count of these buffers is not retained, and are managed by DynamicCompositeByteBuf.
when dynamic composite byte buffer release, it will release every sub buffers.
when the readable size of a sub buffer is zero, it will be removed from dynamic composite byte buffer,
and will be release.
Currently, DynamicCompositeByteBuf does not support to write bytes,
because netty ByteBuf has satisfied already.| 构造器和说明 |
|---|
DynamicCompositeByteBuf() |
DynamicCompositeByteBuf(io.netty.buffer.ByteBuf buf)
construct a new
DynamicCompositeByteBuf with netty ByteBuf. |
DynamicCompositeByteBuf(io.netty.buffer.ByteBuf[] bufs,
int offset,
int len)
construct a new
DynamicCompositeByteBuf with netty ByteBuf array. |
DynamicCompositeByteBuf(int capacity) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addBuffer(io.netty.buffer.ByteBuf buffer)
add netty
ByteBuf to DynamicCompositeByteBuf. |
byte[] |
array()
it not check hasArray for performance
|
int |
arrayOffset()
it not check hasArray for performance
|
boolean |
hasArray() |
boolean |
isEmpty() |
boolean |
isReadable() |
io.netty.buffer.ByteBuf |
nettyByteBuf()
convert
DynamicCompositeByteBuf to netty ByteBuf,
the reference count of its underlying buffers are not increased. |
ByteOrder |
order() |
int |
readableBytes() |
byte |
readByte()
Gets a byte at the current
readerIndex and increases
the readerIndex by 1 in this buffer. |
DynamicCompositeByteBuf |
readBytes(byte[] dst) |
DynamicCompositeByteBuf |
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). |
char |
readChar()
Gets a 2-byte UTF-16 character at the current
readerIndex
and increases the readerIndex by 2 in this buffer. |
double |
readDouble()
Gets a 64-bit floating point number at the current
readerIndex
and increases the readerIndex by 8 in this buffer. |
double |
readDoubleLE()
Gets a 64-bit floating point number at the current
readerIndex
in Little Endian Byte Order and increases the readerIndex
by 8 in this buffer. |
int |
readerIndex() |
float |
readFloat()
Gets a 32-bit floating point number at the current
readerIndex
and increases the readerIndex by 4 in this buffer. |
float |
readFloatLE()
Gets a 32-bit floating point number at the current
readerIndex
in Little Endian Byte Order and increases the readerIndex
by 4 in this buffer. |
int |
readInt()
Gets a 32-bit integer at the current
readerIndex
and increases the readerIndex by 4 in this buffer. |
int |
readIntLE()
Gets a 32-bit integer at the current
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 4 in this buffer. |
long |
readLong()
Gets a 64-bit integer at the current
readerIndex
and increases the readerIndex by 8 in this buffer. |
long |
readLongLE()
Gets a 64-bit integer at the current
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 8 in this buffer. |
io.netty.buffer.ByteBuf |
readRetainedSlice(int length)
Returns a new
CompositeByteBuf which slice the first length of this
composite byte buffer and increases the readerIndex by the size
of the new slice (= length). |
short |
readShort()
Gets a 16-bit short integer at the current
readerIndex
and increases the readerIndex by 2 in this buffer. |
short |
readShortLE()
Gets a 16-bit short integer at the current
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 2 in this buffer. |
short |
readUnsignedByte()
Gets an unsigned byte at the current
readerIndex and increases
the readerIndex by 1 in this buffer. |
int |
readUnsignedShort()
Gets an unsigned 16-bit short integer at the current
readerIndex
and increases the readerIndex by 2 in this buffer. |
int |
readUnsignedShortLE()
Gets an unsigned 16-bit short integer at the current
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 2 in this buffer. |
void |
release() |
io.netty.buffer.ByteBuf |
retainedSlice(int length)
Returns a new
CompositeByteBuf which slice the first length of this
composite byte buffer while they maintain separate indexes and marks. |
void |
skipBytes(int length) |
String |
toString() |
public DynamicCompositeByteBuf()
public DynamicCompositeByteBuf(int capacity)
public DynamicCompositeByteBuf(io.netty.buffer.ByteBuf buf)
DynamicCompositeByteBuf with netty ByteBuf.buf - input buf, readable size should be greater than zero.public DynamicCompositeByteBuf(io.netty.buffer.ByteBuf[] bufs,
int offset,
int len)
DynamicCompositeByteBuf with netty ByteBuf array.bufs - byte buffer array, readable size of each element should be greater than zero.offset - offset at arraylen - length for create the new DynamicCompositeByteBufpublic int readableBytes()
public boolean isEmpty()
public boolean hasArray()
DynamicCompositeByteBuf has a backing arraypublic byte[] array()
throws UnsupportedOperationException
null otherwise.UnsupportedOperationExceptionpublic int arrayOffset()
throws UnsupportedOperationException
UnsupportedOperationExceptionpublic int readerIndex()
public boolean isReadable()
public io.netty.buffer.ByteBuf nettyByteBuf()
DynamicCompositeByteBuf to netty ByteBuf,
the reference count of its underlying buffers are not increased.public void addBuffer(io.netty.buffer.ByteBuf buffer)
ByteBuf to DynamicCompositeByteBuf.
the reference count of netty byte buffer will be managed by DynamicCompositeByteBuf.buffer - netty byte bufferpublic io.netty.buffer.ByteBuf readRetainedSlice(int length)
CompositeByteBuf which slice the first length of this
composite byte buffer and increases the readerIndex by the size
of the new slice (= length).length - the size of the new composite byte bufferIndexOutOfBoundsException - if length is greater than this.readableBytespublic io.netty.buffer.ByteBuf retainedSlice(int length)
CompositeByteBuf which slice the first length of this
composite byte buffer while they maintain separate indexes and marks.
This method does not modify readerIndex or writerIndex of this buffer.length - the size of the new composite byte bufferIndexOutOfBoundsException - if length is greater than this.readableBytespublic void skipBytes(int length)
public DynamicCompositeByteBuf readBytes(byte[] dst)
public DynamicCompositeByteBuf readBytes(byte[] dst, int dstIndex, int length)
readerIndex and increases the readerIndex
by the number of the transferred bytes (= length).dstIndex - the first index of the destinationlength - the number of bytes to transferIndexOutOfBoundsException - if the specified dstIndex is less than 0,
if length is greater than this.readableBytes, or
if dstIndex + length is greater than dst.lengthpublic byte readByte()
readerIndex and increases
the readerIndex by 1 in this buffer.IndexOutOfBoundsException - if this.readableBytes is less than 1public short readUnsignedByte()
readerIndex and increases
the readerIndex by 1 in this buffer.IndexOutOfBoundsException - if this.readableBytes is less than 1public short readShort()
readerIndex
and increases the readerIndex by 2 in this buffer.IndexOutOfBoundsException - if this.readableBytes is less than 2public short readShortLE()
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 2 in this buffer.IndexOutOfBoundsException - if this.readableBytes is less than 2public int readUnsignedShort()
readerIndex
and increases the readerIndex by 2 in this buffer.IndexOutOfBoundsException - if this.readableBytes is less than 2public int readUnsignedShortLE()
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 2 in this buffer.IndexOutOfBoundsException - if this.readableBytes is less than 2public int readInt()
readerIndex
and increases the readerIndex by 4 in this buffer.IndexOutOfBoundsException - if this.readableBytes is less than 4public int readIntLE()
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 4 in this buffer.IndexOutOfBoundsException - if this.readableBytes is less than 4public long readLong()
readerIndex
and increases the readerIndex by 8 in this buffer.IndexOutOfBoundsException - if this.readableBytes is less than 8public long readLongLE()
readerIndex
in the Little Endian Byte Order and increases the readerIndex
by 8 in this buffer.IndexOutOfBoundsException - if this.readableBytes is less than 8public char readChar()
readerIndex
and increases the readerIndex by 2 in this buffer.IndexOutOfBoundsException - if this.readableBytes is less than 2public float readFloat()
readerIndex
and increases the readerIndex by 4 in this buffer.IndexOutOfBoundsException - if this.readableBytes is less than 4public float readFloatLE()
readerIndex
in Little Endian Byte Order and increases the readerIndex
by 4 in this buffer.IndexOutOfBoundsException - if this.readableBytes is less than 4public double readDouble()
readerIndex
and increases the readerIndex by 8 in this buffer.IndexOutOfBoundsException - if this.readableBytes is less than 8public double readDoubleLE()
readerIndex
in Little Endian Byte Order and increases the readerIndex
by 8 in this buffer.IndexOutOfBoundsException - if this.readableBytes is less than 8public ByteOrder order()
public void release()
Copyright © 2019 Baidu, Inc.. All rights reserved.