public final class EmptyByteBuf extends ByteBuf
ByteBuf其容量和最大容量都是0 。
| Constructor and Description |
|---|
EmptyByteBuf(ByteBufAllocator alloc) |
| Modifier and Type | Method and Description |
|---|---|
ByteBufAllocator |
alloc()
返回创建此缓冲区的 ByteBufAllocator 。
|
byte[] |
array()
返回此缓冲区的后备字节数组。
|
int |
arrayOffset()
返回此缓冲区的后备字节数组中第一个字节的偏移量。
|
ByteBuf |
asReadOnly()
返回此缓冲区的只读版本。
|
int |
bytesBefore(byte value)
定位此缓冲区中第一次出现的指定
value 。
|
int |
bytesBefore(int length, byte value)
定位此缓冲区中第一次出现的指定
value 。
|
int |
bytesBefore(int index, int length, byte value)
定位此缓冲区中第一个出现的指定
value 。
|
int |
capacity()
返回此缓冲区可包含的字节数(字节)。
|
ByteBuf |
capacity(int newCapacity)
调整此缓冲区的容量。
|
ByteBuf |
clear()
将此缓冲区的
readerIndex和
writerIndex设置为
0 。
|
int |
compareTo(ByteBuf buffer)
将指定缓冲区的内容与此缓冲区的内容进行比较。
|
ByteBuf |
copy()
返回此缓冲区可读字节的副本。
|
ByteBuf |
copy(int index, int length)
返回此缓冲区的子区域的副本。
|
ByteBuf |
discardReadBytes()
丢弃第0个索引和
readerIndex之间的字节。
|
ByteBuf |
discardSomeReadBytes()
类似于
ByteBuf.discardReadBytes(),不同之
处在于此方法可能会丢弃部分,全部或者全部读取字节,具体取决于其内部实现方式,以减少潜在的额外内存消耗为代价来降低整体内存带宽消耗。
|
ByteBuf |
duplicate()
返回共享此缓冲区整个区域的缓冲区。
|
ByteBuf |
ensureWritable(int minWritableBytes)
确保
the writable bytes的数量等于或大于指定值。
|
int |
ensureWritable(int minWritableBytes, boolean force)
尝试确保
the writable bytes的数量等于或大于指定的值。
|
boolean |
equals(java.lang.Object obj)
确定指定缓冲区的内容是否与此数组的内容相同。
|
int |
forEachByte(ByteProcessor processor)
以指定的
processor按升序对此缓冲区的可读字节进行迭代。
|
int |
forEachByte(int index, int length, ByteProcessor processor)
以指定的
processor按升序迭代该缓冲区的指定区域。
|
int |
forEachByteDesc(ByteProcessor processor)
使用指定的
processor按降序对此缓冲区的可读字节进行迭代。
|
int |
forEachByteDesc(int index, int length, ByteProcessor processor)
以指定的
processor降序遍历此缓冲区的指定区域。
|
boolean |
getBoolean(int index)
在此缓冲区中获取指定绝对(@code索引)的布尔值。
|
byte |
getByte(int index)
获取此缓冲区中指定的绝对
index一个字节。
|
ByteBuf |
getBytes(int index, byte[] dst)
将此缓冲区的数据传输到指定的绝对目标
index开始的目标。
|
ByteBuf |
getBytes(int index, byte[] dst, int dstIndex, int length)
将此缓冲区的数据传输到指定的绝对目标
index开始的目标。
|
ByteBuf |
getBytes(int index, ByteBuf dst)
将该缓冲区的数据传输到指定的目的地,从指定的绝对
index开始,直到目标变为不可写入。
|
ByteBuf |
getBytes(int index, java.nio.ByteBuffer dst)
将缓冲区的数据传输到指定的目的地,从指定的绝对
index开始,直到目的地的位置达到其限制。
|
ByteBuf |
getBytes(int index, ByteBuf dst, int length)
将此缓冲区的数据传输到指定的绝对目标
index开始的目标。
|
ByteBuf |
getBytes(int index, ByteBuf dst, int dstIndex, int length)
将此缓冲区的数据传输到指定的绝对目标
index开始的目标。
|
int |
getBytes(int index, java.nio.channels.FileChannel out, long position, int length)
将此缓冲区的数据从指定的绝对
index到指定的通道,从给定的文件位置开始。
|
int |
getBytes(int index, java.nio.channels.GatheringByteChannel out, int length)
将此缓冲区的数据传输到指定的通道,从指定的绝对
index 。
|
ByteBuf |
getBytes(int index, java.io.OutputStream out, int length)
将此缓冲区的数据传输到指定绝对
index开始的指定流。
|
char |
getChar(int index)
在此缓冲区中指定的绝对
index处获取一个2字节的UTF-16字符。
|
java.lang.CharSequence |
getCharSequence(int index, int length, java.nio.charset.Charset charset)
在给定索引处获得具有给定长度的
CharSequence 。
|
double |
getDouble(int index)
在此缓冲区中的指定绝对
index处获取一个64位浮点数。
|
float |
getFloat(int index)
在此缓冲区中指定的绝对
index处获取一个32位浮点数。
|
int |
getInt(int index)
在此缓冲区中的指定绝对
index处获取一个32位整数。
|
int |
getIntLE(int index)
在此缓冲区中以小端字节顺序指定的绝对
index获取一个32位整数。
|
long |
getLong(int index)
在此缓冲区中的指定绝对
index处获取一个64位长整数。
|
long |
getLongLE(int index)
以Little Endian字节顺序在此缓冲区中的指定绝对
index处获取64位长整数。
|
int |
getMedium(int index)
在此缓冲区中的指定绝对
index处获取一个24位中等整数。
|
int |
getMediumLE(int index)
以Little Endian Byte Order的形式获取缓冲区中指定绝对
index的24位中等整数。
|
short |
getShort(int index)
在此缓冲区中的指定绝对
index处获取一个16位短整数。
|
short |
getShortLE(int index)
以Little Endian字节顺序在此缓冲区中的指定绝对
index处获取一个16位短整数。
|
short |
getUnsignedByte(int index)
在此缓冲区中的指定绝对
index处获取一个无符号字节。
|
long |
getUnsignedInt(int index)
在此缓冲区中指定的绝对
index处获取一个无符号的32位整数。
|
long |
getUnsignedIntLE(int index)
以小端字节顺序在此缓冲区中的指定绝对
index处获取一个无符号的32位整数。
|
int |
getUnsignedMedium(int index)
在此缓冲区中的指定绝对
index处获取一个无符号的24位中等整数。
|
int |
getUnsignedMediumLE(int index)
以Little Endian Byte Order的形式
index此缓冲区中指定绝对
index的无符号24位中等整数。
|
int |
getUnsignedShort(int index)
在此缓冲区中的指定绝对
index处获取一个无符号的16位短整数。
|
int |
getUnsignedShortLE(int index)
以Little Endian Byte Order的形式
index此缓冲区中指定绝对
index的无符号16位短整数。
|
boolean |
hasArray()
当且仅当此缓冲区有一个后备字节数组时返回
true 。
|
int |
hashCode()
返回从此缓冲区的内容计算出来的哈希码。
|
boolean |
hasMemoryAddress()
当且仅当此缓冲区具有对指向后备数据的低级内存地址的引用时才返回
true 。
|
int |
indexOf(int fromIndex, int toIndex, byte value)
定位此缓冲区中第一次出现的指定
value 。
|
java.nio.ByteBuffer |
internalNioBuffer(int index, int length)
仅内部使用:公开内部NIO缓冲区。
|
boolean |
isDirect()
当且仅当此缓冲区由NIO直接缓冲区支持时才返回
true 。
|
boolean |
isReadable()
返回
true当且仅当
(this.writerIndex - this.readerIndex)大于
0 。
|
boolean |
isReadable(int size)
当且仅当此缓冲区包含等于或多于指定数量的元素时返回
true 。
|
boolean |
isReadOnly()
当且仅当此缓冲区为只读时才返回
true 。
|
boolean |
isWritable()
返回
true当且仅当
(this.capacity - this.writerIndex)大于
0 。
|
boolean |
isWritable(int size)
当且仅当此缓冲区有足够的空间允许写入指定数量的元素时才返回
true 。
|
ByteBuf |
markReaderIndex()
在此缓冲区中标记当前
readerIndex 。
|
ByteBuf |
markWriterIndex()
在此缓冲区中标记当前
writerIndex 。
|
int |
maxCapacity()
返回此缓冲区允许的最大容量。
|
int |
maxWritableBytes()
返回可写入的最大字节数,等于
(this.maxCapacity - this.writerIndex) 。
|
long |
memoryAddress()
返回指向备份数据第一个字节的低级内存地址。
|
java.nio.ByteBuffer |
nioBuffer()
将此缓冲区的可读字节作为NIO
ByteBuffer 。
|
java.nio.ByteBuffer |
nioBuffer(int index, int length)
将此缓冲区的子区域公开为NIO
ByteBuffer 。
|
int |
nioBufferCount()
返回构成此缓冲区的NIO
ByteBuffer的最大数量。
|
java.nio.ByteBuffer[] |
nioBuffers()
以NIO
ByteBuffer的形式公开此缓冲区的可读字节。
|
java.nio.ByteBuffer[] |
nioBuffers(int index, int length)
将此缓冲区的字节公开为指定索引和长度的NIO
ByteBuffer所返回的缓冲区共享或包含此缓冲区的复制内容,同时更改返回的NIO缓冲区的位置和限制不会影响此索引和标记缓冲。
|
java.nio.ByteOrder |
order()
返回此缓冲区的
endianness 。
|
ByteBuf |
order(java.nio.ByteOrder endianness)
返回一个指定
endianness的缓冲区,该缓冲区共享此缓冲区的整个区域,索引和标记。
|
int |
readableBytes()
返回等于
(this.writerIndex - this.readerIndex)的可读字节数。
|
boolean |
readBoolean()
在当前
readerIndex处获取布尔值,并在此缓冲区
readerIndex
1增加
readerIndex 。
|
byte |
readByte()
获取当前
readerIndex一个字节,并在此缓冲区
readerIndex
1增加
readerIndex 。
|
ByteBuf |
readBytes(byte[] dst)
传输此缓冲区的数据到指定的目标并从当前
readerIndex并增加了
readerIndex由传输的字节(=数量
dst.length )。
|
ByteBuf |
readBytes(byte[] dst, int dstIndex, int length)
传输此缓冲区的数据到指定的目标并从当前
readerIndex并增加了
readerIndex由传输的字节(=数量
length )。
|
ByteBuf |
readBytes(ByteBuf dst)
将此缓冲区的数据传输到指定的目标,从当前
readerIndex开始,直到目标变为不可写入,并将传输字节数增加
readerIndex 。
|
ByteBuf |
readBytes(java.nio.ByteBuffer dst)
将缓冲区的数据传输到指定的目标,从当前的
readerIndex开始,直到目标的位置达到其限制,并将传输的字节数增加
readerIndex 。
|
ByteBuf |
readBytes(ByteBuf dst, int length)
传输此缓冲区的数据到指定的目标并从当前
readerIndex并增加了
readerIndex由传输的字节(=数量
length )。
|
ByteBuf |
readBytes(ByteBuf dst, int dstIndex, int length)
传输此缓冲区的数据到指定的目标并从当前
readerIndex并增加了
readerIndex由传输的字节(=数量
length )。
|
int |
readBytes(java.nio.channels.FileChannel out, long position, int length)
将此缓冲区的数据从当前的
readerIndex开始
readerIndex到指定通道,从给定的文件位置开始。
|
int |
readBytes(java.nio.channels.GatheringByteChannel out, int length)
将此缓冲区的数据传输到当前
readerIndex开始的指定流。
|
ByteBuf |
readBytes(int length)
传输此缓冲区的数据到一个新创建的缓冲器并从当前
readerIndex并增加了
readerIndex由传输的字节(=数量
length )。
|
ByteBuf |
readBytes(java.io.OutputStream out, int length)
将此缓冲区的数据传输到当前
readerIndex开始的指定流。
|
char |
readChar()
在当前的
readerIndex处获取一个2字节的UTF-16字符,并在此缓冲区
readerIndex
2增加
readerIndex 。
|
java.lang.CharSequence |
readCharSequence(int length, java.nio.charset.Charset charset)
在当前
readerIndex处获得具有给定长度的
CharSequence ,并将给定长度增加
readerIndex 。
|
double |
readDouble()
在当前
readerIndex处获取64位浮点数,并在此缓冲区
readerIndex
8增加
readerIndex 。
|
int |
readerIndex()
返回此缓冲区的
readerIndex 。
|
ByteBuf |
readerIndex(int readerIndex)
设置此缓冲区的
readerIndex 。
|
float |
readFloat()
在当前
readerIndex处获取32位浮点数,并在此缓冲区
readerIndex
4增加
readerIndex 。
|
int |
readInt()
在当前
readerIndex处获取32位整数,并在此缓冲区
readerIndex
4增加
readerIndex 。
|
int |
readIntLE()
在小端字节顺序的当前
readerIndex处获取32位整数,并在此缓冲区
readerIndex
4增加
readerIndex 。
|
long |
readLong()
在当前
readerIndex处获取64位整数,并在此缓冲区
readerIndex
8增加
readerIndex 。
|
long |
readLongLE()
在Little Endian字节顺序的当前
readerIndex处获取64位整数,并在此缓冲区
readerIndex
8增加
readerIndex 。
|
int |
readMedium()
在当前
readerIndex处获取24位中等整数,并在此缓冲区
readerIndex
3增加
readerIndex 。
|
int |
readMediumLE()
在Little Endian Byte Order中获取当前
readerIndex的24位中等整数,并在此缓冲区
readerIndex
3增加
readerIndex 。
|
ByteBuf |
readRetainedSlice(int length)
返回此缓冲区的子区域并从当前的一个新的保留切片
readerIndex并增加了
readerIndex由新的切片(=大小
length )。
|
short |
readShort()
在当前
readerIndex处获取16位短整数,并在此缓冲区
readerIndex
2增加
readerIndex 。
|
short |
readShortLE()
在Little Endian字节顺序的当前
readerIndex处获取一个16位短整数,并在该缓冲区中增加
readerIndex
2 。
|
ByteBuf |
readSlice(int length)
返回此缓冲区的子区域并从当前的新的片
readerIndex并增加了
readerIndex由新的切片(=大小
length )。
|
short |
readUnsignedByte()
获取当前
readerIndex处的无符号字节,并在此缓冲区
readerIndex
1增加
readerIndex 。
|
long |
readUnsignedInt()
在当前
readerIndex处获取一个无符号的32位整数,并在此缓冲区
readerIndex
4增加
readerIndex 。
|
long |
readUnsignedIntLE()
在小端字节顺序的当前
readerIndex处获取一个无符号的32位整数,并在此缓冲区
readerIndex
4增加
readerIndex 。
|
int |
readUnsignedMedium()
在当前
readerIndex处获取一个无符号的24位中等整数,并在此缓冲区
readerIndex
3增加
readerIndex 。
|
int |
readUnsignedMediumLE()
在Little Endian Byte Order中获取当前
readerIndex的无符号24位中等整数,并在此缓冲区
readerIndex
3增加
readerIndex 。
|
int |
readUnsignedShort()
在当前
readerIndex处获取一个无符号的16位短整数,并在此缓冲区
readerIndex
2增加
readerIndex 。
|
int |
readUnsignedShortLE()
在Little Endian Byte Order中获取当前
readerIndex的无符号16位短整数,并在此缓冲区
readerIndex
2增加
readerIndex 。
|
int |
refCnt()
返回此对象的引用计数。
|
boolean |
release()
通过减小引用计数
1并且如果所述引用计数达到在将释放该对象
0 。
|
boolean |
release(int decrement)
如果引用计数达到
0则减少指定的引用计数
decrement并释放此对象。
|
ByteBuf |
resetReaderIndex()
将当前
readerIndex重新定位到此缓冲区中标记为
readerIndex 。
|
ByteBuf |
resetWriterIndex()
将当前
writerIndex重新定位到此缓冲区中标记为
writerIndex 。
|
ByteBuf |
retain()
将参考计数增加
1 。
|
ByteBuf |
retain(int increment)
将参考计数增加
increment 。
|
ByteBuf |
retainedDuplicate()
返回共享此缓冲区整个区域的保留缓冲区。
|
ByteBuf |
retainedSlice()
返回此缓冲区可读字节的保留片段。
|
ByteBuf |
retainedSlice(int index, int length)
返回此缓冲区的子区域的保留切片。
|
ByteBuf |
setBoolean(int index, boolean value)
在此缓冲区中的指定绝对
index处设置指定的布尔值。
|
ByteBuf |
setByte(int index, int value)
在此缓冲区中的指定绝对
index处设置指定的字节。
|
ByteBuf |
setBytes(int index, byte[] src)
将指定的源数组的数据传输到此缓冲区,从指定的绝对
index 。
|
ByteBuf |
setBytes(int index, byte[] src, int srcIndex, int length)
从指定的绝对
index开始,将指定的源数组的数据传输到此缓冲区。
|
ByteBuf |
setBytes(int index, ByteBuf src)
将指定的源缓冲区的数据传输到此缓冲区,从指定的绝对
index开始,直到源缓冲区变得不可读。
|
ByteBuf |
setBytes(int index, java.nio.ByteBuffer src)
将指定的源缓冲区的数据从指定的绝对
index开始传输到此缓冲区,直到源缓冲区的位置达到其限制。
|
ByteBuf |
setBytes(int index, ByteBuf src, int length)
将指定的源缓冲区的数据从指定的绝对
index开始传送到此缓冲区。
|
ByteBuf |
setBytes(int index, ByteBuf src, int srcIndex, int length)
将指定的源缓冲区数据传输到此缓冲区,从指定的绝对
index 。
|
int |
setBytes(int index, java.nio.channels.FileChannel in, long position, int length)
将从给定文件位置开始的指定源通道的内容传输到此缓冲区,从指定的绝对
index 。
|
int |
setBytes(int index, java.io.InputStream in, int length)
将指定源流的内容从指定的绝对
index开始传输到此缓冲区。
|
int |
setBytes(int index, java.nio.channels.ScatteringByteChannel in, int length)
将指定源通道的内容从指定的绝对
index开始传输到此缓冲区。
|
ByteBuf |
setChar(int index, int value)
在此缓冲区的指定绝对
index处设置指定的2字节UTF-16字符。
|
int |
setCharSequence(int index, java.lang.CharSequence sequence, java.nio.charset.Charset charset)
将指定
CharSequence在当前
writerIndex并增加了
writerIndex由写入的字节。
|
ByteBuf |
setDouble(int index, double value)
在此缓冲区中的指定绝对
index处设置指定的64位浮点数。
|
ByteBuf |
setFloat(int index, float value)
在此缓冲区中指定的绝对
index处设置指定的32位浮点数。
|
ByteBuf |
setIndex(int readerIndex, int writerIndex)
readerIndex设置此缓冲区的
readerIndex和
writerIndex 。
|
ByteBuf |
setInt(int index, int value)
在此缓冲区中指定的绝对
index处设置指定的32位整数。
|
ByteBuf |
setIntLE(int index, int value)
使用Little Endian字节顺序在此缓冲区中的指定绝对
index处设置指定的32位整数。
|
ByteBuf |
setLong(int index, long value)
在此缓冲区中的指定绝对
index处设置指定的64位长整数。
|
ByteBuf |
setLongLE(int index, long value)
以小端字节顺序在此缓冲区中的指定绝对
index处设置指定的64位长整数。
|
ByteBuf |
setMedium(int index, int value)
在此缓冲区中的指定绝对
index处设置指定的24位中等整数。
|
ByteBuf |
setMediumLE(int index, int value)
以小端字节顺序在此缓冲区中的指定绝对
index处设置指定的24位中等整数。
|
ByteBuf |
setShort(int index, int value)
在此缓冲区中的指定绝对
index处设置指定的16位短整数。
|
ByteBuf |
setShortLE(int index, int value)
使用Little Endian Byte Order在此缓冲区中的指定绝对
index处设置指定的16位短整数。
|
ByteBuf |
setZero(int index, int length)
NUL (0x00)从指定的绝对
index开始填充此缓冲区。
|
ByteBuf |
skipBytes(int length)
此缓冲区中指定的
length增加当前
readerIndex 。
|
ByteBuf |
slice()
返回此缓冲区可读字节的一部分。
|
ByteBuf |
slice(int index, int length)
返回此缓冲区的子区域的一部分。
|
java.lang.String |
toString()
返回此缓冲区的字符串表示形式。
|
java.lang.String |
toString(java.nio.charset.Charset charset)
将此缓冲区的可读字节解码为具有指定字符集名称的字符串。
|
java.lang.String |
toString(int index, int length, java.nio.charset.Charset charset)
将此缓冲区的子区域解码为具有指定字符集的字符串。
|
ByteBuf |
touch()
记录此对象的当前访问位置以进行调试。
|
ByteBuf |
touch(java.lang.Object hint)
记录此对象的当前访问位置,并附加一些用于调试的任意信息。
|
ByteBuf |
unwrap()
如果此缓冲区是另一个缓冲区的包装,则返回底层缓冲区实例。
|
int |
writableBytes()
返回等于
(this.capacity - this.writerIndex)的可写字节数。
|
ByteBuf |
writeBoolean(boolean value)
在当前
writerIndex设置指定的布尔值,并在此缓冲区
writerIndex
1增加
writerIndex 。
|
ByteBuf |
writeByte(int value)
在当前
writerIndex处设置指定的字节,并在此缓冲区
writerIndex
1增加
writerIndex 。
|
ByteBuf |
writeBytes(byte[] src)
指定的源阵列的数据传送到该缓冲液并从当前
writerIndex并增加了
writerIndex由传输的字节(=数量
src.length )。
|
ByteBuf |
writeBytes(byte[] src, int srcIndex, int length)
指定的源阵列的数据传送到该缓冲液并从当前
writerIndex并增加了
writerIndex由传输的字节(=数量
length )。
|
ByteBuf |
writeBytes(ByteBuf src)
将指定源缓冲区的数据传输到此缓冲区,从当前
writerIndex开始,直到源缓冲区变得不可读,并将
writerIndex增加
writerIndex 。
|
ByteBuf |
writeBytes(java.nio.ByteBuffer src)
将指定的源缓冲区的数据从当前
writerIndex开始传送到此缓冲区,直到源缓冲区的位置达到其限制,并将
writerIndex增加
writerIndex传送的字节数。
|
ByteBuf |
writeBytes(ByteBuf src, int length)
指定的源缓冲区的数据传送到该缓冲液并从当前
writerIndex并增加了
writerIndex由传输的字节(=数量
length )。
|
ByteBuf |
writeBytes(ByteBuf src, int srcIndex, int length)
指定的源缓冲区的数据传送到该缓冲液并从当前
writerIndex并增加了
writerIndex由传输的字节(=数量
length )。
|
int |
writeBytes(java.nio.channels.FileChannel in, long position, int length)
将从给定文件位置开始的指定通道的内容传输到此缓冲区,从当前
writerIndex开始,并将传输字节数增加
writerIndex 。
|
int |
writeBytes(java.io.InputStream in, int length)
将指定流的内容传输到此缓冲区,从当前
writerIndex开始,并通过传输的字节数增加
writerIndex 。
|
int |
writeBytes(java.nio.channels.ScatteringByteChannel in, int length)
将指定通道的内容从当前
writerIndex开始传送到此缓冲区,并将传送的字节数增加到
writerIndex 。
|
ByteBuf |
writeChar(int value)
在当前
writerIndex处设置指定的2字节UTF-16字符,并在此缓冲区
writerIndex
2增加
writerIndex 。
|
int |
writeCharSequence(java.lang.CharSequence sequence, java.nio.charset.Charset charset)
将指定
CharSequence在当前
writerIndex并增加了
writerIndex由写入的字节。
|
ByteBuf |
writeDouble(double value)
在当前
writerIndex处设置指定的64位浮点数,并在此缓冲区
writerIndex
8增加
writerIndex 。
|
ByteBuf |
writeFloat(float value)
在当前
writerIndex处设置指定的32位浮点数,并在此缓冲区
writerIndex
4增加
writerIndex 。
|
ByteBuf |
writeInt(int value)
在当前
writerIndex设置指定的32位整数,并在此缓冲区
writerIndex
4增加
writerIndex 。
|
ByteBuf |
writeIntLE(int value)
以小端字节顺序在当前
writerIndex处设置指定的32位整数,并在此缓冲区
writerIndex
4增加
writerIndex 。
|
ByteBuf |
writeLong(long value)
在当前
writerIndex处设置指定的64位长整数,并在此缓冲区
writerIndex
8增加
writerIndex 。
|
ByteBuf |
writeLongLE(long value)
以小端字节顺序在当前
writerIndex处设置指定的64位长整数,并在此缓冲区
writerIndex
8增加
writerIndex 。
|
ByteBuf |
writeMedium(int value)
在当前
writerIndex中设置指定的24位中等整数,并在此缓冲区
writerIndex
3增加
writerIndex 。
|
ByteBuf |
writeMediumLE(int value)
在Little Endian Byte Order中设置当前
writerIndex中指定的24位中等整数,并在此缓冲区
writerIndex
3增加
writerIndex 。
|
int |
writerIndex()
返回此缓冲区的
writerIndex 。
|
ByteBuf |
writerIndex(int writerIndex)
设置此缓冲区的
writerIndex 。
|
ByteBuf |
writeShort(int value)
在当前
writerIndex处设置指定的16位短整数,并在此缓冲区
writerIndex
2增加
writerIndex 。
|
ByteBuf |
writeShortLE(int value)
在当前
writerIndex处设置Little Endian Byte Order中指定的16位短整数,并在此缓冲区
writerIndex
2增加
writerIndex 。
|
ByteBuf |
writeZero(int length)
用
NUL (0x00)从当前
writerIndex开始填充此缓冲区,
并将
writerIndex增加
writerIndex指定的
length 。
|
getDoubleLE, getFloatLE, readDoubleLE, readFloatLE, setDoubleLE, setFloatLE, writeDoubleLE, writeFloatLEpublic EmptyByteBuf(ByteBufAllocator alloc)
public ByteBuf capacity(int newCapacity)
ByteBuf
newCapacity小于当前容量,则此缓冲区的内容将被截断。
如果newCapacity大于当前容量,则缓冲区会附加长度为(newCapacity - currentCapacity)未指定数据。
public ByteBufAllocator alloc()
ByteBuf
ByteBufAllocator 。
public java.nio.ByteOrder order()
ByteBuf
public ByteBuf asReadOnly()
ByteBuf
asReadOnly类
ByteBuf
public boolean isReadOnly()
ByteBuf
true 。
isReadOnly在类
ByteBuf
public boolean isDirect()
ByteBuf
true 。
public int maxCapacity()
ByteBuf
ByteBuf.capacity(int)或ByteBuf.ensureWritable(int)将此缓冲区的容量增加到最大容量以上 ,那么这些方法将引发IllegalArgumentException 。
maxCapacity在类
ByteBuf
public ByteBuf order(java.nio.ByteOrder endianness)
ByteBuf
endianness的缓冲区,该缓冲区共享此缓冲区的整个区域,索引和标记。
修改返回的缓冲区或此缓冲区的内容,索引或标记会影响彼此的内容,索引和标记。
如果指定的endianness与此缓冲区的字节顺序相同,则此方法可返回this 。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public int readerIndex()
ByteBuf
readerIndex 。
readerIndex类
ByteBuf
public ByteBuf readerIndex(int readerIndex)
ByteBuf
readerIndex 。
readerIndex在类
ByteBuf
public int writerIndex()
ByteBuf
writerIndex 。
writerIndex在类
ByteBuf
public ByteBuf writerIndex(int writerIndex)
ByteBuf
writerIndex 。
writerIndex在类
ByteBuf
public ByteBuf setIndex(int readerIndex, int writerIndex)
ByteBuf
readerIndex设置此缓冲区的readerIndex和writerIndex 。
当您不得不担心ByteBuf.readerIndex(int)和ByteBuf.writerIndex(int)方法的调用顺序时,此方法非常有用。
例如,以下代码将失败:
// Create a buffer whose readerIndex, writerIndex and capacity are
// 0, 0 and 8 respectively.
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.
ByteBuf 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 ,无论缓冲区的当前索引值是什么:
// 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);
public int readableBytes()
ByteBuf
(this.writerIndex - this.readerIndex)的可读字节数。
readableBytes在类
ByteBuf
public int writableBytes()
ByteBuf
(this.capacity - this.writerIndex)的可写字节数。
writableBytes在类
ByteBuf
public int maxWritableBytes()
ByteBuf
(this.maxCapacity - this.writerIndex) 。
maxWritableBytes在类
ByteBuf
public boolean isReadable()
ByteBuf
true当且仅当
(this.writerIndex - this.readerIndex)大于
0 。
isReadable在类
ByteBuf
public boolean isWritable()
ByteBuf
true当且仅当
(this.capacity - this.writerIndex)大于
0 。
isWritable在类
ByteBuf
public ByteBuf clear()
ByteBuf
readerIndex和writerIndex设置为0 。
该方法与setIndex(0, 0)相同。
请注意,此方法的行为与NIO缓冲区的行为不同,后者将limit设置为limit的capacity 。
public ByteBuf markReaderIndex()
ByteBuf
readerIndex 。
您可以重新定位当前readerIndex到标记readerIndex通过调用ByteBuf.resetReaderIndex() 。
标记的初始值readerIndex是0 。
markReaderIndex类
ByteBuf
public ByteBuf resetReaderIndex()
ByteBuf
readerIndex重新定位到此缓冲区中标记为
readerIndex 。
resetReaderIndex在类
ByteBuf
public ByteBuf markWriterIndex()
ByteBuf
writerIndex 。
您可以重新定位当前writerIndex到标记writerIndex通过调用ByteBuf.resetWriterIndex() 。
标记的初始值writerIndex是0 。
markWriterIndex在类
ByteBuf
public ByteBuf resetWriterIndex()
ByteBuf
writerIndex重新定位到此缓冲区中标记为
writerIndex 。
resetWriterIndex在类
ByteBuf
public ByteBuf discardReadBytes()
ByteBuf
readerIndex之间的字节。
它移动之间的字节readerIndex和writerIndex至第0索引,并且设置readerIndex和writerIndex至0和oldWriterIndex - oldReaderIndex分别。
请参阅班级文件以获得更详细的解释。
discardReadBytes在类
ByteBuf
public ByteBuf discardSomeReadBytes()
ByteBuf
ByteBuf.discardReadBytes(),不同之
处在于此方法可能会丢弃部分,全部或者全部读取字节,具体取决于其内部实现方式,以减少潜在的额外内存消耗为代价来降低整体内存带宽消耗。
discardSomeReadBytes在类
ByteBuf
public ByteBuf ensureWritable(int minWritableBytes)
ByteBuf
ensureWritable在类
ByteBuf
minWritableBytes - 可写入字节的预期最小数量
public int ensureWritable(int minWritableBytes,
boolean force)
ByteBuf
ByteBuf.ensureWritable(int)不同,此方法不引发异常但返回代码。
ensureWritable在类
ByteBuf
minWritableBytes - 可写入字节的预期最小数量
force - 当ByteBuf.writerIndex() + minWritableBytes > ByteBuf.maxCapacity() :
true - 缓冲区的容量扩大到ByteBuf.maxCapacity() false - 缓冲区的容量不变 0如果缓冲区有足够的可写字节,并且其容量不变。
1如果缓冲区没有足够的字节,并且其容量不变。
2如果缓冲区有足够的可写字节,并且其容量已增加。
3如果缓冲区没有足够的字节,但其容量已增加到最大值。
public boolean getBoolean(int index)
ByteBuf
readerIndex或writerIndex 。
getBoolean
ByteBuf
public byte getByte(int index)
ByteBuf
index的字节。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public short getUnsignedByte(int index)
ByteBuf
index处获取一个无符号字节。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
getUnsignedByte在类
ByteBuf
public short getShort(int index)
ByteBuf
index处获取一个16位短整数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public short getShortLE(int index)
ByteBuf
index处获取一个16位短整数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
getShortLE在类
ByteBuf
public int getUnsignedShort(int index)
ByteBuf
index处获取一个无符号的16位短整数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
getUnsignedShort在类
ByteBuf
public int getUnsignedShortLE(int index)
ByteBuf
index此缓冲区中指定绝对index的无符号16位短整数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
getUnsignedShortLE在类
ByteBuf
public int getMedium(int index)
ByteBuf
index处获取一个24位中等整数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public int getMediumLE(int index)
ByteBuf
index处获取一个24位中等整数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
getMediumLE在类
ByteBuf
public int getUnsignedMedium(int index)
ByteBuf
index处获取一个无符号的24位中等整数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
getUnsignedMedium在类
ByteBuf
public int getUnsignedMediumLE(int index)
ByteBuf
index处获取无符号的24位中等整数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
getUnsignedMediumLE在类
ByteBuf
public int getInt(int index)
ByteBuf
index处获取一个32位整数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public int getIntLE(int index)
ByteBuf
index获取一个32位整数, index字节顺序。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public long getUnsignedInt(int index)
ByteBuf
index处获取一个无符号的32位整数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
getUnsignedInt在类
ByteBuf
public long getUnsignedIntLE(int index)
ByteBuf
index处获取一个无符号的32位整数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
getUnsignedIntLE在类
ByteBuf
public long getLong(int index)
ByteBuf
index处获取一个64位长整数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public long getLongLE(int index)
ByteBuf
index处获取64位长整数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public char getChar(int index)
ByteBuf
index处获取一个2字节的UTF-16字符。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public float getFloat(int index)
ByteBuf
index处获取一个32位浮点数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public double getDouble(int index)
ByteBuf
index处获取一个64位浮点数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public ByteBuf getBytes(int index, ByteBuf dst)
ByteBuf
index开始,直到目标变为不可写。
此方法与ByteBuf.getBytes(int, ByteBuf, int, int)基本相同,不同之writerIndex于此方法通过传输字节数增加目标的writerIndex ,而ByteBuf.getBytes(int, ByteBuf, int, int)则不增加。
此方法不会修改源缓冲区的readerIndex或writerIndex (即this )。
public ByteBuf getBytes(int index, ByteBuf dst, int length)
ByteBuf
index开始的目标。
此方法与ByteBuf.getBytes(int, ByteBuf, int, int)基本相同,不同之writerIndex于此方法通过传输字节数增加目标的writerIndex ,而ByteBuf.getBytes(int, ByteBuf, int, int)则不增加。
此方法不会修改源缓冲区的readerIndex或writerIndex (即this )。
public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length)
ByteBuf
index开始的目标。
此方法不会修改来源(即this )和目的地的readerIndex或writerIndex 。
public ByteBuf getBytes(int index, byte[] dst)
ByteBuf
index开始的目标。
此方法不会修改此缓冲区的readerIndex或writerIndex
public ByteBuf getBytes(int index, byte[] dst, int dstIndex, int length)
ByteBuf
index开始的目标。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public ByteBuf getBytes(int index, java.nio.ByteBuffer dst)
ByteBuf
index开始,直到目标位置达到其限制。
此方法不修改此缓冲区的readerIndex或writerIndex ,而目标的position将增加。
public ByteBuf getBytes(int index, java.io.OutputStream out, int length)
ByteBuf
index开始的指定流。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public int getBytes(int index,
java.nio.channels.GatheringByteChannel out,
int length)
ByteBuf
index 。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public int getBytes(int index,
java.nio.channels.FileChannel out,
long position,
int length)
ByteBuf
index开始index到指定的通道,从给定的文件位置开始。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
此方法不会修改频道的位置。
public java.lang.CharSequence getCharSequence(int index,
int length,
java.nio.charset.Charset charset)
ByteBuf
CharSequence 。
getCharSequence在类
ByteBuf
length - 阅读的长度
charset - 应该使用
public ByteBuf setBoolean(int index, boolean value)
ByteBuf
index处设置指定的布尔值。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
setBoolean在类
ByteBuf
public ByteBuf setByte(int index, int value)
ByteBuf
index处设置指定的字节。
指定值的24个高位被忽略。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public ByteBuf setShort(int index, int value)
ByteBuf
index处设置指定的16位短整数。
指定值的16个高位被忽略。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public ByteBuf setShortLE(int index, int value)
ByteBuf复制的描述
index处设置指定的16位短整数。
指定值的16个高位被忽略。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
setShortLE在类
ByteBuf
public ByteBuf setMedium(int index, int value)
ByteBuf
index处设置指定的24位中等整数。
请注意,最高有效字节在指定值中被忽略。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public ByteBuf setMediumLE(int index, int value)
ByteBuf
index处设置指定的24位中等整数。
请注意,最高有效字节在指定值中被忽略。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
setMediumLE在类
ByteBuf
public ByteBuf setInt(int index, int value)
ByteBuf
index处设置指定的32位整数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public ByteBuf setIntLE(int index, int value)
ByteBuf
index处设置指定的32位整数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public ByteBuf setLong(int index, long value)
ByteBuf
index处设置指定的64位长整数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public ByteBuf setLongLE(int index, long value)
ByteBuf
index处设置指定的64位长整数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public ByteBuf setChar(int index, int value)
ByteBuf
index处设置指定的2字节UTF-16字符。
指定值的16个高位被忽略。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public ByteBuf setFloat(int index, float value)
ByteBuf
index处设置指定的32位浮点数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public ByteBuf setDouble(int index, double value)
ByteBuf
index处设置指定的64位浮点数。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public ByteBuf setBytes(int index, ByteBuf src)
ByteBuf
index开始传输到此缓冲区,直到源缓冲区变得不可读。
此方法与ByteBuf.setBytes(int, ByteBuf, int, int)基本相同,不同之readerIndex于此方法将源缓冲区的readerIndex增加了传输字节数,而ByteBuf.setBytes(int, ByteBuf, int, int)则不增加。
此方法不会修改源缓冲区的readerIndex或writerIndex (即this )。
public ByteBuf setBytes(int index, ByteBuf src, int length)
ByteBuf
index 。
此方法与ByteBuf.setBytes(int, ByteBuf, int, int)基本相同,只是此方法将源缓冲区的readerIndex增加了传输字节数,而ByteBuf.setBytes(int, ByteBuf, int, int)则不增加。
此方法不会修改源缓冲区的readerIndex或writerIndex (即this )。
public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length)
ByteBuf
index开始传送到此缓冲区。
此方法不会修改源(即this )和目标的readerIndex或writerIndex 。
public ByteBuf setBytes(int index, byte[] src)
ByteBuf
index 。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public ByteBuf setBytes(int index, byte[] src, int srcIndex, int length)
ByteBuf
index 。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public ByteBuf setBytes(int index, java.nio.ByteBuffer src)
ByteBuf
index开始传输到此缓冲区,直到源缓冲区的位置达到其限制。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public int setBytes(int index,
java.io.InputStream in,
int length)
ByteBuf
index开始传输到此缓冲区。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public int setBytes(int index,
java.nio.channels.ScatteringByteChannel in,
int length)
ByteBuf
index开始传送到此缓冲区。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public int setBytes(int index,
java.nio.channels.FileChannel in,
long position,
int length)
ByteBuf
index 。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
此方法不会修改频道的位置。
public ByteBuf setZero(int index, int length)
ByteBuf
index开始填充此缓冲区。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public int setCharSequence(int index,
java.lang.CharSequence sequence,
java.nio.charset.Charset charset)
ByteBuf
CharSequence在当前
writerIndex并增加了
writerIndex由写入的字节。
setCharSequence在类
ByteBuf
index - 应在其上写入序列
sequence - 写
charset - 应该使用。
public boolean readBoolean()
ByteBuf
readerIndex的布尔值,并在此缓冲区
readerIndex
1增加
readerIndex 。
readBoolean在类
ByteBuf
public byte readByte()
ByteBuf
readerIndex一个字节,并在此缓冲区中增加
readerIndex
1 。
public short readUnsignedByte()
ByteBuf
readerIndex的无符号字节,并在此缓冲区
readerIndex
1增加
readerIndex 。
readUnsignedByte在类
ByteBuf
public short readShort()
ByteBuf
readerIndex处获取一个16位短整数,并在此缓冲区
readerIndex
2增加
readerIndex 。
public short readShortLE()
ByteBuf
readerIndex处获取一个16位短整数,并在此缓冲区中增加
readerIndex
2 。
readShortLE在类
ByteBuf
public int readUnsignedShort()
ByteBuf
readerIndex处获取一个无符号的16位短整数,并在此缓冲区
readerIndex
2增加
readerIndex 。
readUnsignedShort在类
ByteBuf
public int readUnsignedShortLE()
ByteBuf
readerIndex处获取一个无符号的16位短整数,并在此缓冲区
readerIndex
2增加
readerIndex 。
readUnsignedShortLE上课
ByteBuf
public int readMedium()
ByteBuf
readerIndex处获取24位中等整数,并在此缓冲区
readerIndex
3增加
readerIndex 。
readMedium类
ByteBuf
public int readMediumLE()
ByteBuf
readerIndex中以Little Endian字节顺序获取一个24位中等整数,并在此缓冲区
readerIndex
3增加
readerIndex 。
readMediumLE在类
ByteBuf
public int readUnsignedMedium()
ByteBuf
readerIndex处获取一个无符号的24位中等整数,并在此缓冲区
readerIndex
3增加
readerIndex 。
readUnsignedMedium在类
ByteBuf
public int readUnsignedMediumLE()
ByteBuf
readerIndex的无符号24位中等整数,并在此缓冲区中增加
readerIndex
3 。
readUnsignedMediumLE在类
ByteBuf
public int readInt()
ByteBuf
readerIndex处获取32位整数,并在此缓冲区
readerIndex
4增加
readerIndex 。
public int readIntLE()
ByteBuf
readerIndex处获取一个32位整数,并在此缓冲区
readerIndex
4增加
readerIndex 。
public long readUnsignedInt()
ByteBuf
readerIndex处获取一个无符号的32位整数,并在此缓冲区
readerIndex
4增加
readerIndex 。
readUnsignedInt在类
ByteBuf
public long readUnsignedIntLE()
ByteBuf
readerIndex处获取一个无符号的32位整数,并在此缓冲区中增加
readerIndex
4 。
readUnsignedIntLE在类
ByteBuf
public long readLong()
ByteBuf
readerIndex处获取64位整数,并在此缓冲区
readerIndex
8增加
readerIndex 。
public long readLongLE()
ByteBuf
readerIndex处获取64位整数,并在此缓冲区
readerIndex
8增加
readerIndex 。
readLongLE在类
ByteBuf
public char readChar()
ByteBuf
readerIndex处获取一个2字节的UTF-16字符,并在此缓冲区
readerIndex
2增加
readerIndex 。
public float readFloat()
ByteBuf
readerIndex处获取一个32位浮点数,并在此缓冲区
readerIndex
4增加
readerIndex 。
public double readDouble()
ByteBuf
readerIndex处获取一个64位浮点数,并在此缓冲区中增加
readerIndex
8 。
readDouble在类
ByteBuf
public ByteBuf readBytes(int length)
ByteBuf
readerIndex并增加了readerIndex由传输的字节(=数量length )。
返回缓冲区的readerIndex和writerIndex是0和length分别。
public ByteBuf readSlice(int length)
ByteBuf
readerIndex并增加了readerIndex由新的切片(=大小length )。
另外请注意,此方法不会调用ByteBuf.retain() ,因此引用计数不会增加。
public ByteBuf readRetainedSlice(int length)
ByteBuf
readerIndex并增加了readerIndex由新的切片(=大小length )。
请注意,与ByteBuf.readSlice(int)不同,此方法返回retained缓冲区。 此方法的行为与readSlice(...).retain()类似,但此方法可能会返回一个生成较少垃圾的缓冲区实现。
readRetainedSlice在类
ByteBuf
length - 新切片的大小
public ByteBuf readBytes(ByteBuf dst)
ByteBuf
readerIndex开始,直到目标变为不可写,并将readerIndex增加readerIndex所传输的字节数。
此方法与ByteBuf.readBytes(ByteBuf, int, int)基本相同,不同之writerIndex于此方法通过传输字节数增加目标的writerIndex ,而ByteBuf.readBytes(ByteBuf, int, int)则不增加。
public ByteBuf readBytes(ByteBuf dst, int length)
ByteBuf
readerIndex并增加了readerIndex由传输的字节(=数量length )。
此方法与ByteBuf.readBytes(ByteBuf, int, int)基本相同,不同之writerIndex于此方法通过传输的字节数(= length )增加目标的writerIndex ,而ByteBuf.readBytes(ByteBuf, int, int)则不增加。
public ByteBuf readBytes(ByteBuf dst, int dstIndex, int length)
ByteBuf
readerIndex并增加了
readerIndex由传输的字节(=数量
length )。
public ByteBuf readBytes(byte[] dst)
ByteBuf
readerIndex并增加了
readerIndex由传输的字节(=数量
dst.length )。
public ByteBuf readBytes(byte[] dst, int dstIndex, int length)
ByteBuf
readerIndex并增加了
readerIndex由传输的字节(=数量
length )。
public ByteBuf readBytes(java.nio.ByteBuffer dst)
ByteBuf
readerIndex开始,直到目标的位置达到其限制,并将
readerIndex增加
readerIndex所传输的字节数。
public ByteBuf readBytes(java.io.OutputStream out, int length)
ByteBuf
readerIndex开始的指定流。
public int readBytes(java.nio.channels.GatheringByteChannel out,
int length)
ByteBuf
readerIndex开始的指定流。
public int readBytes(java.nio.channels.FileChannel out,
long position,
int length)
ByteBuf
readerIndex到指定通道,从给定的文件位置开始。
此方法不会修改频道的位置。
public java.lang.CharSequence readCharSequence(int length,
java.nio.charset.Charset charset)
ByteBuf
readerIndex处获得给定长度的
CharSequence ,并将给定长度增加
readerIndex 。
readCharSequence在类
ByteBuf
length - 阅读的长度
charset - 应该使用
public ByteBuf writeBoolean(boolean value)
ByteBuf
writerIndex处设置指定的布尔值,并在此缓冲区中增加
writerIndex
1 。
writeBoolean在类
ByteBuf
public ByteBuf writeByte(int value)
ByteBuf
writerIndex处设置指定的字节,并在此缓冲区writerIndex 1增加writerIndex 。
指定值的24个高位被忽略。
public ByteBuf writeShort(int value)
ByteBuf
writerIndex处设置指定的16位短整数,并在此缓冲区中增加writerIndex 2 。
指定值的16个高位被忽略。
writeShort在类
ByteBuf
public ByteBuf writeShortLE(int value)
ByteBuf
writerIndex处设置Little Endian Byte Order中指定的16位短整数,并在此缓冲区writerIndex 2增加writerIndex 。
指定值的16个高位被忽略。
writeShortLE在类
ByteBuf
public ByteBuf writeMedium(int value)
ByteBuf
writerIndex中设置指定的24位中等整数,并在此缓冲区
writerIndex
3增加
writerIndex 。
writeMedium在类
ByteBuf
public ByteBuf writeMediumLE(int value)
ByteBuf
writerIndex处设置指定的24位中等整数,并在此缓冲区
writerIndex
3增加
writerIndex 。
writeMediumLE在类
ByteBuf
public ByteBuf writeInt(int value)
ByteBuf
writerIndex处设置指定的32位整数,并在此缓冲区
writerIndex
4增加
writerIndex 。
public ByteBuf writeIntLE(int value)
ByteBuf
writerIndex处设置指定的32位整数,并在此缓冲区
writerIndex
4增加
writerIndex 。
writeIntLE在类
ByteBuf
public ByteBuf writeLong(long value)
ByteBuf
writerIndex处设置指定的64位长整数,并在此缓冲区
writerIndex
8增加
writerIndex 。
public ByteBuf writeLongLE(long value)
ByteBuf
writerIndex处设置指定的64位长整数,并在此缓冲区
writerIndex
8增加
writerIndex 。
writeLongLE在类
ByteBuf
public ByteBuf writeChar(int value)
ByteBuf
writerIndex处设置指定的2字节UTF-16字符,并在此缓冲区writerIndex 2增加writerIndex 。
指定值的16个高位被忽略。
public ByteBuf writeFloat(float value)
ByteBuf
writerIndex处设置指定的32位浮点数,并在此缓冲区
writerIndex
4增加
writerIndex 。
writeFloat在类
ByteBuf
public ByteBuf writeDouble(double value)
ByteBuf
writerIndex处设置指定的64位浮点数并在此缓冲区
writerIndex
8增加
writerIndex 。
writeDouble在类
ByteBuf
public ByteBuf writeBytes(ByteBuf src)
ByteBuf
writerIndex开始,直到源缓冲区变得不可读,并将传输字节数增加writerIndex 。
此方法与ByteBuf.writeBytes(ByteBuf, int, int)基本相同,不同之readerIndex于此方法将源缓冲区的readerIndex增加了传输字节数,而ByteBuf.writeBytes(ByteBuf, int, int)则不增加。
writeBytes在类
ByteBuf
public ByteBuf writeBytes(ByteBuf src, int length)
ByteBuf
writerIndex并增加了writerIndex由传输的字节(=数量length )。
此方法与ByteBuf.writeBytes(ByteBuf, int, int)基本相同,不同之readerIndex于此方法将源缓冲区的readerIndex增加了传输字节数(= length ),而ByteBuf.writeBytes(ByteBuf, int, int)则不增加。
writeBytes在类
ByteBuf
length - 要传输的字节数
public ByteBuf writeBytes(ByteBuf src, int srcIndex, int length)
ByteBuf
writerIndex开始,并将
writerIndex增加
writerIndex的字节数(=
length )。
writeBytes在类
ByteBuf
srcIndex - 来源的第一个索引
length - 要传输的字节数
public ByteBuf writeBytes(byte[] src)
ByteBuf
writerIndex开始,并将
writerIndex增加
writerIndex传输的字节数(=
src.length )。
writeBytes
ByteBuf
public ByteBuf writeBytes(byte[] src, int srcIndex, int length)
ByteBuf
writerIndex并增加了
writerIndex由传输的字节(=数量
length )。
writeBytes类
ByteBuf
srcIndex - 来源的第一个索引
length - 要传输的字节数
public ByteBuf writeBytes(java.nio.ByteBuffer src)
ByteBuf
writerIndex开始传送到此缓冲区,直到源缓冲区的位置达到其限制,并将传送的字节数增加
writerIndex 。
writeBytes在类
ByteBuf
public int writeBytes(java.io.InputStream in,
int length)
ByteBuf
writerIndex开始传送到此缓冲区,并将传送的字节数增加到
writerIndex 。
writeBytes在类
ByteBuf
length - 要传输的字节数
public int writeBytes(java.nio.channels.ScatteringByteChannel in,
int length)
ByteBuf
writerIndex开始,并通过传输的字节数增加
writerIndex 。
writeBytes在类
ByteBuf
length - 传输的最大字节数
public int writeBytes(java.nio.channels.FileChannel in,
long position,
int length)
ByteBuf
writerIndex开始,并将传输字节数增加writerIndex 。
此方法不会修改频道的位置。
writeBytes在类
ByteBuf
position - 传输开始的文件位置
length - 传输的最大字节数
public ByteBuf writeZero(int length)
ByteBuf
writerIndex增加
writerIndex指定的
length 。
public int writeCharSequence(java.lang.CharSequence sequence,
java.nio.charset.Charset charset)
ByteBuf
CharSequence在当前writerIndex并增加了writerIndex由写入的字节。
在这个缓冲区中。
writeCharSequence在类
ByteBuf
sequence - 写
charset - 应该使用
public int indexOf(int fromIndex,
int toIndex,
byte value)
ByteBuf
value的第一个匹配项。
搜索从指定的fromIndex (含)到指定的toIndex ( toIndex )。
如果fromIndex大于toIndex ,则搜索按相反顺序执行。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public int bytesBefore(byte value)
ByteBuf
value 。
搜索从当前readerIndex (含)至当前writerIndex ( writerIndex )。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
bytesBefore在类
ByteBuf
readerIndex与第一个匹配项之间的字节数(如果找到)。
否则为-1 。
public int bytesBefore(int length,
byte value)
ByteBuf
value 。
搜索从当前的readerIndex (含)开始并持续指定的length 。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
bytesBefore在类
ByteBuf
readerIndex与第一个匹配项之间的字节数(如果找到)。
否则为-1 。
public int bytesBefore(int index,
int length,
byte value)
ByteBuf
value 。
搜索从指定的index (含)开始并持续指定的length 。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
bytesBefore在类
ByteBuf
index与第一个匹配项之间的字节数(如果找到)。
否则为-1 。
public int forEachByte(ByteProcessor processor)
ByteBuf
processor按升序对此缓冲区的可读字节进行迭代。
forEachByte在类
ByteBuf
-1如果处理器迭代到或超出可读字节的末尾。
上次访问的索引如果ByteProcessor.process(byte)返回false 。
public int forEachByte(int index,
int length,
ByteProcessor processor)
ByteBuf
processor按升序对此缓冲区的指定区域进行迭代。
(即index , (index + 1) ,.. (index + length - 1) )
forEachByte在类
ByteBuf
-1如果处理器迭代到或超出指定区域的末尾。
最后访问的索引如果ByteProcessor.process(byte)返回false 。
public int forEachByteDesc(ByteProcessor processor)
ByteBuf
processor按降序对此缓冲区的可读字节进行迭代。
forEachByteDesc在类
ByteBuf
-1如果处理器迭代到或超出可读字节的开头。
最后访问的索引如果ByteProcessor.process(byte)返回false 。
public int forEachByteDesc(int index,
int length,
ByteProcessor processor)
ByteBuf
processor降序遍历此缓冲区的指定区域。
(即(index + length - 1) , (index + length - 2) ,... index )
forEachByteDesc在类
ByteBuf
-1如果处理器迭代到或超出指定区域的开始位置。
最后访问的索引如果ByteProcessor.process(byte)返回false 。
public ByteBuf copy()
ByteBuf
buf.copy(buf.readerIndex(), buf.readableBytes())相同。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public ByteBuf copy(int index, int length)
ByteBuf
readerIndex或writerIndex 。
public ByteBuf slice()
ByteBuf
buf.slice(buf.readerIndex(), buf.readableBytes())相同。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
另外请注意,此方法不会调用ByteBuf.retain() ,因此引用计数不会增加。
public ByteBuf retainedSlice()
ByteBuf
buf.slice(buf.readerIndex(), buf.readableBytes())相同。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
请注意,与ByteBuf.slice()不同,此方法返回retained缓冲区。 此方法的行为与slice().retain()类似, slice().retain()在于此方法可能会返回一个生成较少垃圾的缓冲区实现。
retainedSlice在类
ByteBuf
public ByteBuf slice(int index, int length)
ByteBuf
readerIndex或writerIndex 。
另外请注意,此方法不会调用ByteBuf.retain() ,因此引用计数不会增加。
public ByteBuf retainedSlice(int index, int length)
ByteBuf
readerIndex或writerIndex 。
请注意,与ByteBuf.slice(int, int)不同,此方法返回retained缓冲区。 此方法的行为与slice(...).retain()类似,只不过此方法可能会返回一个生成较少垃圾的缓冲区实现。
retainedSlice在类
ByteBuf
public ByteBuf duplicate()
ByteBuf
readerIndex或writerIndex 。
读者和作家的标记不会重复。 另外请注意,此方法不会调用ByteBuf.retain() ,因此引用计数不会增加。
duplicate类
ByteBuf
ByteBuf.slice()返回的缓冲区的缓冲区。
然而,这个缓冲区将共享底层缓冲区的容量,因此如果需要的话允许访问所有的底层内容。
public ByteBuf retainedDuplicate()
ByteBuf
buf.slice(0, buf.capacity())相同。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
请注意,与ByteBuf.slice(int, int)不同,此方法返回retained缓冲区。 此方法的行为与duplicate().retain()类似,只不过此方法可能会返回一个生成较少垃圾的缓冲区实现。
retainedDuplicate上课
ByteBuf
public int nioBufferCount()
ByteBuf
ByteBuffer的最大数量。
请注意, ByteBuf.nioBuffers()或ByteBuf.nioBuffers(int, int)可能会返回更少数量的ByteBuffer 。
nioBufferCount类
ByteBuf
-1如果此缓冲区没有标的ByteBuffer 。
如果此缓冲区至少有一个底层ByteBuffer ,则底层ByteBuffer的ByteBuffer 。
请注意,此方法不会返回0以避免混淆。
ByteBuf.nioBuffer() ,
ByteBuf.nioBuffer(int, int) ,
ByteBuf.nioBuffers() ,
ByteBuf.nioBuffers(int, int)
public java.nio.ByteBuffer nioBuffer()
ByteBuf
ByteBuffer 。
返回的缓冲区共享或包含此缓冲区的复制内容,同时更改返回的NIO缓冲区的位置和限制不会影响此缓冲区的索引和标记。
该方法与buf.nioBuffer(buf.readerIndex(), buf.readableBytes())相同。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
请注意,如果此缓冲区是动态缓冲区并且它调整了其容量,则返回的NIO缓冲区将不会看到此缓冲区的更改。
nioBuffer在课堂上
ByteBuf
ByteBuf.nioBufferCount() ,
ByteBuf.nioBuffers() ,
ByteBuf.nioBuffers(int, int)
public java.nio.ByteBuffer nioBuffer(int index,
int length)
ByteBuf
ByteBuffer 。
返回的缓冲区共享或包含此缓冲区的复制内容,同时更改返回的NIO缓冲区的位置和限制不会影响此缓冲区的索引和标记。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
请注意,如果此缓冲区是动态缓冲区并且它调整了其容量,则返回的NIO缓冲区将不会看到此缓冲区的更改。
nioBuffer在类
ByteBuf
ByteBuf.nioBufferCount() ,
ByteBuf.nioBuffers() ,
ByteBuf.nioBuffers(int, int)
public java.nio.ByteBuffer[] nioBuffers()
ByteBuf
ByteBuffer的形式公开此缓冲区的可读字节。
返回的缓冲区共享或包含此缓冲区的复制内容,同时更改返回的NIO缓冲区的位置和限制不会影响此缓冲区的索引和标记。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
请注意,如果此缓冲区是动态缓冲区并且它调整了其容量,则返回的NIO缓冲区将不会看到此缓冲区的更改。
nioBuffers在类
ByteBuf
ByteBuf.nioBufferCount() ,
ByteBuf.nioBuffer() ,
ByteBuf.nioBuffer(int, int)
public java.nio.ByteBuffer[] nioBuffers(int index,
int length)
ByteBuf
ByteBuffer返回的缓冲区共享或包含此缓冲区的复制内容,同时更改返回的NIO缓冲区的位置和限制不会影响此索引和标记缓冲。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
请注意,如果此缓冲区是动态缓冲区并且它调整了其容量,则返回的NIO缓冲区将不会看到此缓冲区的更改。
nioBuffers在类
ByteBuf
ByteBuf.nioBufferCount() ,
ByteBuf.nioBuffer() ,
ByteBuf.nioBuffer(int, int)
public java.nio.ByteBuffer internalNioBuffer(int index,
int length)
ByteBuf
internalNioBuffer在类
ByteBuf
public boolean hasArray()
ByteBuf
true 。
如果此方法返回true,则可以放心地呼叫ByteBuf.array()和ByteBuf.arrayOffset() 。
public int arrayOffset()
ByteBuf
arrayOffset在类
ByteBuf
public boolean hasMemoryAddress()
ByteBuf
true 。
hasMemoryAddress在类
ByteBuf
public long memoryAddress()
ByteBuf
memoryAddress在类
ByteBuf
public java.lang.String toString(java.nio.charset.Charset charset)
ByteBuf
buf.toString(buf.readerIndex(), buf.readableBytes(), charsetName)相同。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public java.lang.String toString(int index,
int length,
java.nio.charset.Charset charset)
ByteBuf
readerIndex或writerIndex 。
public int hashCode()
ByteBuf
public boolean equals(java.lang.Object obj)
ByteBuf
ByteBuf.readerIndex()和ByteBuf.writerIndex() 。
此方法还为null返回false ,并返回一个不是ByteBuf类型实例的对象 。
public int compareTo(ByteBuf buffer)
ByteBuf
strcmp , memcmp和String.compareTo(String) 。
public java.lang.String toString()
ByteBuf
ByteBuf.readerIndex() , ByteBuf.writerIndex()和ByteBuf.capacity() 。
public boolean isReadable(int size)
ByteBuf
true 。
isReadable在类
ByteBuf
public boolean isWritable(int size)
ByteBuf
true 。
isWritable在类
ByteBuf
public int refCnt()
ReferenceCounted复制的描述
0 ,则表示此对象已被释放。
public ByteBuf retain()
ReferenceCounted复制的描述
1 。
retain接口
ReferenceCounted
retain在类
ByteBuf
public ByteBuf retain(int increment)
ReferenceCounted复制的描述
increment 。
retain在界面
ReferenceCounted
retain类
ByteBuf
public ByteBuf touch()
ReferenceCounted复制的描述
touch接口
ReferenceCounted
touch在类
ByteBuf
public ByteBuf touch(java.lang.Object hint)
ReferenceCounted复制的描述
ResourceLeakDetector提供给您。
touch接口
ReferenceCounted
touch在类
ByteBuf
public boolean release()
ReferenceCounted复制的描述
1并且如果所述引用计数达到在将释放该对象
0 。
true当且仅当引用计数变为
0且此对象已被释放
public boolean release(int decrement)
ReferenceCounted复制的描述
0则减少引用计数
decrement并释放此对象。
true当且仅当引用计数变为
0且此对象已被释放
Copyright © 2008–2018 The Netty Project. All rights reserved.