public abstract class AbstractByteBuf extends Object implements ByteBuf
| 限定符和类型 | 字段和说明 |
|---|---|
protected ByteBufAllocator |
alloc |
protected ByteOrder |
byteOrder |
protected int |
markedReaderIndex |
protected int |
markedWriterIndex |
protected int |
readerIndex |
protected int |
writerIndex |
| 限定符 | 构造器和说明 |
|---|---|
protected |
AbstractByteBuf(ByteBufAllocator alloc,
int maxCapacity) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected abstract byte |
_getByte(int offset) |
protected abstract int |
_getBytes(int offset,
byte[] b,
int off,
int len) |
protected abstract void |
_putByte(int offset,
byte b) |
protected abstract void |
_putBytes(int offset,
byte[] b,
int off,
int len) |
ByteBufAllocator |
alloc()
Returns the
ByteBufAllocator which created this buffer. |
protected void |
checkFree() |
protected int |
checkReadable(int offset,
int len) |
protected abstract void |
extendByteBuf(int targetCapacity)
需要扩充到的目标容量
|
protected void |
finalize() |
void |
free()
释放 Buffer 占用的内存
|
byte |
getByte(int offset)
从 offset 偏移量的位置上开始读取 1 字节。
|
int |
getBytes(int offset,
byte[] b,
int off,
int len)
从 offset 偏移量的位置上开始读取 len 数量的字节,并将它们存储到 off 位置开始的缓冲区数组 b 中。
|
short |
getInt16(int offset)
读取 2 字节的 short(大端字节序),该方法不会更新 readerIndex 值。
|
short |
getInt16LE(int offset)
读取 2 字节的 short(小端字节序),该方法不会更新 readerIndex 值。
|
int |
getInt24(int offset)
读取 3 字节的 int(大端字节序),该方法不会更新 readerIndex 值。
|
int |
getInt24LE(int offset)
读取 3 字节的 int(小端字节序),该方法不会更新 readerIndex 值。
|
int |
getInt32(int offset)
读取 4 字节的 int(大端字节序),该方法不会更新 readerIndex 值。
|
int |
getInt32LE(int offset)
读取 4 字节的 int(小端字节序),该方法不会更新 readerIndex 值。
|
long |
getInt64(int offset)
读取 8 字节的 long(大端字节序),该方法不会更新 readerIndex 值。
|
long |
getInt64LE(int offset)
读取 8 字节的 long(小端字节序),该方法不会更新 readerIndex 值。
|
int |
getMaxCapacity() |
protected abstract String |
getSimpleName() |
int |
getUInt16(int offset)
读取 2 字节的 无符号 sort(小端字节序),该方法不会更新 readerIndex 值。
|
int |
getUInt16LE(int offset)
读取 2 字节的 无符号 sort(小端字节序),该方法不会更新 readerIndex 值。
|
int |
getUInt24(int offset)
读取 3 字节的 无符号 int(小端字节序),该方法不会更新 readerIndex 值。
|
int |
getUInt24LE(int offset)
读取 3 字节的 无符号 int(小端字节序),该方法不会更新 readerIndex 值。
|
long |
getUInt32(int offset)
读取 4 字节的 无符号 int(小端字节序),该方法不会更新 readerIndex 值。
|
long |
getUInt32LE(int offset)
读取 4 字节的 无符号 int(小端字节序),该方法不会更新 readerIndex 值。
|
short |
getUInt8(int offset)
读取 1 字节的 byte 返回 0~255 之间的一个数(小端字节序),该方法不会更新 readerIndex 值。
|
boolean |
isFree()
是否已经释放
|
boolean |
isOpen() |
ByteBuf |
markReader()
Marks the current
readerIndex in this buffer. |
ByteBuf |
markWriter()
Marks the current
writerIndex in this buffer. |
protected int |
nextReadable(int readableBytes) |
protected int |
nextWritable(int writableBytes) |
protected int |
offsetWritable(int offset,
int len) |
ByteOrder |
order()
字节序
|
ByteBuf |
order(ByteOrder newOrder)
设置字节序
|
int |
read(ByteBuffer dst)
use copy to dst
|
int |
read(ByteBuf dst,
int len)
use copy to dst
|
int |
readableBytes()
Returns the number of readable bytes which is equal to
(this.markedWriterIndex - this.readerIndex). |
byte |
readByte()
读取 1 字节。
|
int |
readBytes()
Returns the number of read bytes which is equal to
(readIndex - readMark). |
int |
readBytes(byte[] b,
int off,
int len)
读取 len 数量的字节,并将它们存储到 off 位置开始的缓冲区数组 b 中。
|
int |
readerIndex()
Returns the
readerIndex of this buffer. |
short |
readInt16()
读取 2 字节的 short(大端字节序),读取后 readerIndex 会增加 2。
|
short |
readInt16LE()
读取 2 字节的 short(小端字节序),读取后 readerIndex 会增加 2。
|
int |
readInt24()
读取 3 字节的 int(大端字节序),读取后 readerIndex 会增加 3。
|
int |
readInt24LE()
读取 3 字节的 int(小端字节序),读取后 readerIndex 会增加 3。
|
int |
readInt32()
读取 4 字节的 int(大端字节序),读取后 readerIndex 会增加 4。
|
int |
readInt32LE()
读取 4 字节的 int(小端字节序),读取后 readerIndex 会增加 4。
|
long |
readInt64()
读取 8 字节的 long(大端字节序),读取后 readerIndex 会增加 8。
|
long |
readInt64LE()
读取 8 字节的 long(小端字节序),读取后 readerIndex 会增加 8。
|
int |
readUInt16()
读取 2 字节的 无符号 sort(大端字节序),读取后 readerIndex 会增加 2。
|
int |
readUInt16LE()
读取 2 字节的 无符号 sort(小端字节序),读取后 readerIndex 会增加 2。
|
int |
readUInt24()
读取 3 字节的 无符号 int(大端字节序),读取后 readerIndex 会增加 3。
|
int |
readUInt24LE()
读取 3 字节的 无符号 int(小端字节序),读取后 readerIndex 会增加 3。
|
long |
readUInt32()
读取 4 字节的 无符号 int(大端字节序),读取后 readerIndex 会增加 4。
|
long |
readUInt32LE()
读取 4 字节的 无符号 int(小端字节序),读取后 readerIndex 会增加 4。
|
short |
readUInt8()
读取 1 字节的 byte 返回 0~255 之间的一个数(大端字节序),读取后 readerIndex 会增加 1。
|
protected void |
receivedBytes(int lastMarkedWriter,
int currentMarkedWriter)
markedWriterIndex 向前推进,有更多的数据可读
|
protected void |
recycleByteBuf()
回收 markedReaderIndex 之前的内存区块
|
ByteBuf |
resetReader()
Repositions the current
readerIndex to the marked
readerIndex in this buffer. |
ByteBuf |
resetWriter()
Repositions the current
writerIndex to the marked
writerIndex in this buffer. |
void |
setByte(int offset,
byte n)
在 offset 偏移量的位置上向后覆盖方式写入 1 字节的 byte,该方法不会更新 writerIndex 值。
|
void |
setBytes(int offset,
byte[] b)
在 offset 偏移量的位置上向后覆盖方式写入 b 数组的数据,该方法不会更新 writerIndex 值。
|
void |
setBytes(int offset,
byte[] b,
int off,
int len)
在 offset 偏移量的位置上向后覆盖方式写入 b 数组的数据,该方法不会更新 writerIndex 值。
|
void |
setInt16(int offset,
short n)
在 offset 偏移量的位置上向后覆盖方式写入 2 字节长度的 sort(大端字节序),该方法不会更新 writerIndex 值。
|
void |
setInt16LE(int offset,
short n)
在 offset 偏移量的位置上向后覆盖方式写入 2 字节长度的 sort(小端字节序),该方法不会更新 writerIndex 值。
|
void |
setInt24(int offset,
int n)
在 offset 偏移量的位置上向后覆盖方式写入 3 字节长度的 int(大端字节序),该方法不会更新 writerIndex 值。
|
void |
setInt24LE(int offset,
int n)
在 offset 偏移量的位置上向后覆盖方式写入 3 字节长度的 int(小端字节序),该方法不会更新 writerIndex 值。
|
void |
setInt32(int offset,
int n)
在 offset 偏移量的位置上向后覆盖方式写入 4 字节长度的 int(大端字节序),该方法不会更新 writerIndex 值。
|
void |
setInt32LE(int offset,
int n)
在 offset 偏移量的位置上向后覆盖方式写入 4 字节长度的 int(小端字节序),该方法不会更新 writerIndex 值。
|
void |
setInt64(int offset,
long n)
在 offset 偏移量的位置上向后覆盖方式写入 8 字节长度的 long(大端字节序),该方法不会更新 writerIndex 值。
|
void |
setInt64LE(int offset,
long n)
在 offset 偏移量的位置上向后覆盖方式写入 8 字节长度的 long(小端字节序),该方法不会更新 writerIndex 值。
|
ByteBuf |
skipReadableBytes(int length) |
ByteBuf |
skipWritableBytes(int length) |
String |
toString() |
int |
writableBytes()
Returns the number of writable bytes which is equal to
(maxCapacity - (writerIndex - readMark)). |
int |
write(ByteBuf src)
use copy form src ByteBuffer
|
int |
write(ByteBuffer src)
use copy form src ByteBuffer
|
void |
writeByte(byte n)
写入 1 字节的 byte,写入后 writerIndex 会 + 1。
|
void |
writeBytes(byte[] b,
int off,
int len)
数据写入,写入后 writerIndex 会增加 len。
|
int |
writedBytes()
Returns the number of writed bytes which is equal to
(writerIndex - writerMark). |
void |
writeInt16(short n)
写入 2 字节的 sort(大端字节序),写入后 writerIndex 会 + 2。
|
void |
writeInt16LE(short n)
写入 2 字节的 sort(小端字节序),写入后 writerIndex 会 + 2。
|
void |
writeInt24(int n)
写入 3 字节的 int(大端字节序),写入后 writerIndex 会 + 3。
|
void |
writeInt24LE(int n)
写入 3 字节的 int(小端字节序),写入后 writerIndex 会 + 3。
|
void |
writeInt32(int n)
写入 4 字节的 int(大端字节序),写入后 writerIndex 会 + 4。
|
void |
writeInt32LE(int n)
写入 4 字节的 int(小端字节序),写入后 writerIndex 会 + 4。
|
void |
writeInt64(long n)
写入 8 字节的 long(大端字节序),写入后 writerIndex 会 + 8。
|
void |
writeInt64LE(long n)
写入 8 字节的 int(小端字节序),写入后 writerIndex 会 + 8。
|
int |
writerIndex()
Returns the
writerIndex of this buffer. |
void |
writeUInt32(long n)
写入 4 字节的无符号 int(大端字节序),写入后 writerIndex 会 + 4。
|
void |
writeUInt32LE(long n)
写入 4 字节的无符号 int(小端字节序),写入后 writerIndex 会 + 4。
|
array, asByteBuffer, capacity, clear, close, copy, expect, expect, expectLast, expectLast, expectLine, flush, getBytes, getFloat32, getFloat32LE, getFloat64, getFloat64LE, getString, hasLine, hasReadable, hasWritable, isDirect, read, readBytes, readExpect, readExpect, readExpectLast, readExpectLast, readFloat32, readFloat32LE, readFloat64, readFloat64LE, readLine, readLine, readString, setFloat32, setFloat32LE, setFloat64, setFloat64LE, setString, writeBytes, writeFloat32, writeFloat32LE, writeFloat64, writeFloat64LE, writeStringprotected final ByteBufAllocator alloc
protected int markedReaderIndex
protected int markedWriterIndex
protected int readerIndex
protected int writerIndex
protected ByteOrder byteOrder
protected AbstractByteBuf(ByteBufAllocator alloc, int maxCapacity)
public ByteBufAllocator alloc()
ByteBufByteBufAllocator which created this buffer.public int getMaxCapacity()
protected void checkFree()
protected abstract void _putByte(int offset,
byte b)
protected abstract void _putBytes(int offset,
byte[] b,
int off,
int len)
protected abstract byte _getByte(int offset)
protected abstract int _getBytes(int offset,
byte[] b,
int off,
int len)
protected abstract void extendByteBuf(int targetCapacity)
protected void recycleByteBuf()
protected void receivedBytes(int lastMarkedWriter,
int currentMarkedWriter)
public int readableBytes()
ByteBuf(this.markedWriterIndex - this.readerIndex).readableBytes 在接口中 ByteBufpublic int readBytes()
ByteBuf(readIndex - readMark).public int writableBytes()
ByteBuf(maxCapacity - (writerIndex - readMark)).writableBytes 在接口中 ByteBufpublic int writedBytes()
ByteBuf(writerIndex - writerMark).writedBytes 在接口中 ByteBufprotected int nextWritable(int writableBytes)
protected int nextReadable(int readableBytes)
protected int offsetWritable(int offset,
int len)
protected int checkReadable(int offset,
int len)
public ByteBuf skipReadableBytes(int length)
skipReadableBytes 在接口中 ByteBufpublic ByteBuf skipWritableBytes(int length)
skipWritableBytes 在接口中 ByteBufpublic ByteBuf markReader()
ByteBufreaderIndex in this buffer.
You can reposition the current readerIndex to the marked readerIndex by calling ByteBuf.resetReader().
The initial value of the marked readerIndex is 0.markReader 在接口中 ByteBufpublic ByteBuf resetReader()
ByteBufreaderIndex to the marked
readerIndex in this buffer.resetReader 在接口中 ByteBufpublic int readerIndex()
ByteBufreaderIndex of this buffer.readerIndex 在接口中 ByteBufpublic ByteBuf markWriter()
ByteBufwriterIndex in this buffer.
You can reposition the current writerIndex to the marked writerIndex by calling ByteBuf.resetWriter().
The initial value of the marked writerIndex is 0.markWriter 在接口中 ByteBufpublic ByteBuf resetWriter()
ByteBufwriterIndex to the marked
writerIndex in this buffer.resetWriter 在接口中 ByteBufpublic int writerIndex()
ByteBufwriterIndex of this buffer.writerIndex 在接口中 ByteBufpublic void writeByte(byte n)
ByteBufIndexOutOfBoundsException 异常public void writeBytes(byte[] b,
int off,
int len)
ByteBufIndexOutOfBoundsException 异常writeBytes 在接口中 ByteBufpublic void writeInt16(short n)
ByteBufIndexOutOfBoundsException 异常writeInt16 在接口中 ByteBufpublic void writeInt24(int n)
ByteBufIndexOutOfBoundsException 异常writeInt24 在接口中 ByteBufpublic void writeInt32(int n)
ByteBufIndexOutOfBoundsException 异常writeInt32 在接口中 ByteBufpublic void writeUInt32(long n)
ByteBufIndexOutOfBoundsException 异常writeUInt32 在接口中 ByteBufpublic void writeInt64(long n)
ByteBufIndexOutOfBoundsException 异常writeInt64 在接口中 ByteBufpublic void writeInt16LE(short n)
ByteBufIndexOutOfBoundsException 异常writeInt16LE 在接口中 ByteBufpublic void writeInt24LE(int n)
ByteBufIndexOutOfBoundsException 异常writeInt24LE 在接口中 ByteBufpublic void writeInt32LE(int n)
ByteBufIndexOutOfBoundsException 异常writeInt32LE 在接口中 ByteBufpublic void writeUInt32LE(long n)
ByteBufIndexOutOfBoundsException 异常writeUInt32LE 在接口中 ByteBufpublic void writeInt64LE(long n)
ByteBufIndexOutOfBoundsException 异常writeInt64LE 在接口中 ByteBufpublic void setByte(int offset,
byte n)
ByteBufIndexOutOfBoundsException 异常public void setBytes(int offset,
byte[] b)
ByteBufIndexOutOfBoundsException 异常public void setBytes(int offset,
byte[] b,
int off,
int len)
ByteBufIndexOutOfBoundsException 异常public void setInt16(int offset,
short n)
ByteBufIndexOutOfBoundsException 异常public void setInt24(int offset,
int n)
ByteBufIndexOutOfBoundsException 异常public void setInt32(int offset,
int n)
ByteBufIndexOutOfBoundsException 异常public void setInt64(int offset,
long n)
ByteBufIndexOutOfBoundsException 异常public void setInt16LE(int offset,
short n)
ByteBufIndexOutOfBoundsException 异常setInt16LE 在接口中 ByteBufpublic void setInt24LE(int offset,
int n)
ByteBufIndexOutOfBoundsException 异常setInt24LE 在接口中 ByteBufpublic void setInt32LE(int offset,
int n)
ByteBufIndexOutOfBoundsException 异常setInt32LE 在接口中 ByteBufpublic void setInt64LE(int offset,
long n)
ByteBufIndexOutOfBoundsException 异常setInt64LE 在接口中 ByteBufpublic byte readByte()
ByteBufIndexOutOfBoundsException 异常public int readBytes(byte[] b,
int off,
int len)
ByteBufpublic short readInt16()
ByteBufIndexOutOfBoundsException 异常public int readInt24()
ByteBufIndexOutOfBoundsException 异常public int readInt32()
ByteBufIndexOutOfBoundsException 异常public long readInt64()
ByteBufIndexOutOfBoundsException 异常public short readInt16LE()
ByteBufIndexOutOfBoundsException 异常readInt16LE 在接口中 ByteBufpublic int readInt24LE()
ByteBufIndexOutOfBoundsException 异常readInt24LE 在接口中 ByteBufpublic int readInt32LE()
ByteBufIndexOutOfBoundsException 异常readInt32LE 在接口中 ByteBufpublic long readInt64LE()
ByteBufIndexOutOfBoundsException 异常readInt64LE 在接口中 ByteBufpublic byte getByte(int offset)
ByteBufIndexOutOfBoundsException 异常public int getBytes(int offset,
byte[] b,
int off,
int len)
ByteBufpublic short getInt16(int offset)
ByteBufIndexOutOfBoundsException 异常public int getInt24(int offset)
ByteBufIndexOutOfBoundsException 异常public int getInt32(int offset)
ByteBufIndexOutOfBoundsException 异常public long getInt64(int offset)
ByteBufIndexOutOfBoundsException 异常public short getInt16LE(int offset)
ByteBufIndexOutOfBoundsException 异常getInt16LE 在接口中 ByteBufpublic int getInt24LE(int offset)
ByteBufIndexOutOfBoundsException 异常getInt24LE 在接口中 ByteBufpublic int getInt32LE(int offset)
ByteBufIndexOutOfBoundsException 异常getInt32LE 在接口中 ByteBufpublic long getInt64LE(int offset)
ByteBufIndexOutOfBoundsException 异常getInt64LE 在接口中 ByteBufpublic short readUInt8()
ByteBufIndexOutOfBoundsException 异常public int readUInt16()
ByteBufIndexOutOfBoundsException 异常readUInt16 在接口中 ByteBufpublic int readUInt24()
ByteBufIndexOutOfBoundsException 异常readUInt24 在接口中 ByteBufpublic long readUInt32()
ByteBufIndexOutOfBoundsException 异常readUInt32 在接口中 ByteBufpublic int readUInt16LE()
ByteBufIndexOutOfBoundsException 异常readUInt16LE 在接口中 ByteBufpublic int readUInt24LE()
ByteBufIndexOutOfBoundsException 异常readUInt24LE 在接口中 ByteBufpublic long readUInt32LE()
ByteBufIndexOutOfBoundsException 异常readUInt32LE 在接口中 ByteBufpublic short getUInt8(int offset)
ByteBufIndexOutOfBoundsException 异常public int getUInt16(int offset)
ByteBufIndexOutOfBoundsException 异常public int getUInt24(int offset)
ByteBufIndexOutOfBoundsException 异常public long getUInt32(int offset)
ByteBufIndexOutOfBoundsException 异常public int getUInt16LE(int offset)
ByteBufIndexOutOfBoundsException 异常getUInt16LE 在接口中 ByteBufpublic int getUInt24LE(int offset)
ByteBufIndexOutOfBoundsException 异常getUInt24LE 在接口中 ByteBufpublic long getUInt32LE(int offset)
ByteBufIndexOutOfBoundsException 异常getUInt32LE 在接口中 ByteBufpublic int read(ByteBuffer dst)
ByteBufread 在接口中 ReadableByteChannelread 在接口中 ByteBufpublic int write(ByteBuffer src)
ByteBufwrite 在接口中 WritableByteChannelwrite 在接口中 ByteBufprotected abstract String getSimpleName()
Copyright © 2022–2024. All rights reserved.