public class UnpooledUnsafeDirectByteBuf extends AbstractReferenceCountedByteBuf
ByteBuffer的缓冲区。
建议使用AbstractByteBufAllocator.directBuffer(int, int) , Unpooled.directBuffer(int)和Unpooled.wrappedBuffer(ByteBuffer) ,而不是显式调用构造函数。}
| Modifier | Constructor and Description |
|---|---|
protected |
UnpooledUnsafeDirectByteBuf(ByteBufAllocator alloc, java.nio.ByteBuffer initialBuffer, int maxCapacity)
通过包装指定的初始缓冲区来创建一个新的直接缓冲区。
|
|
UnpooledUnsafeDirectByteBuf(ByteBufAllocator alloc, int initialCapacity, int maxCapacity)
创建一个新的直接缓冲区。
|
| Modifier and Type | Method and Description |
|---|---|
protected byte |
_getByte(int index) |
protected int |
_getInt(int index) |
protected int |
_getIntLE(int index) |
protected long |
_getLong(int index) |
protected long |
_getLongLE(int index) |
protected short |
_getShort(int index) |
protected short |
_getShortLE(int index) |
protected int |
_getUnsignedMedium(int index) |
protected int |
_getUnsignedMediumLE(int index) |
protected void |
_setByte(int index, int value) |
protected void |
_setInt(int index, int value) |
protected void |
_setIntLE(int index, int value) |
protected void |
_setLong(int index, long value) |
protected void |
_setLongLE(int index, long value) |
protected void |
_setMedium(int index, int value) |
protected void |
_setMediumLE(int index, int value) |
protected void |
_setShort(int index, int value) |
protected void |
_setShortLE(int index, int value) |
ByteBufAllocator |
alloc()
返回创建此缓冲区的 ByteBufAllocator 。
|
protected java.nio.ByteBuffer |
allocateDirect(int initialCapacity)
用给定的initialCapacity分配一个新的直接
ByteBuffer 。
|
byte[] |
array()
返回此缓冲区的后备字节数组。
|
int |
arrayOffset()
返回此缓冲区的后备字节数组中第一个字节的偏移量。
|
int |
capacity()
返回此缓冲区可包含的字节数(字节)。
|
ByteBuf |
capacity(int newCapacity)
调整此缓冲区的容量。
|
ByteBuf |
copy(int index, int length)
返回此缓冲区的子区域的副本。
|
protected void |
deallocate()
|
protected void |
freeDirect(java.nio.ByteBuffer buffer)
免费直接
ByteBuffer
|
ByteBuf |
getBytes(int index, byte[] dst, int dstIndex, int length)
将此缓冲区的数据传输到指定的目标,从指定的绝对
index 。
|
ByteBuf |
getBytes(int index, java.nio.ByteBuffer dst)
将此缓冲区的数据传输到指定的目标位置,从指定的绝对
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 。
|
boolean |
hasArray()
当且仅当此缓冲区有一个后备字节数组时,才返回
true 。
|
boolean |
hasMemoryAddress()
当且仅当此缓冲区具有对指向后备数据的低级内存地址的引用时才返回
true 。
|
java.nio.ByteBuffer |
internalNioBuffer(int index, int length)
仅内部使用:公开内部NIO缓冲区。
|
boolean |
isDirect()
当且仅当此缓冲区由NIO直接缓冲区支持时才返回
true 。
|
long |
memoryAddress()
返回指向备份数据第一个字节的低级内存地址。
|
protected SwappedByteBuf |
newSwappedByteBuf()
为此 ByteBuf实例创建一个新的SwappedByteBuf 。
|
java.nio.ByteBuffer |
nioBuffer(int index, int length)
将此缓冲区的子区域公开为NIO
ByteBuffer 。
|
int |
nioBufferCount()
返回由此缓冲区组成的NIO
ByteBuffer的最大数量。
|
java.nio.ByteBuffer[] |
nioBuffers(int index, int length)
以指定的索引和长度公开此缓冲区的字节为NIO
ByteBuffer返回的缓冲区共享或包含此缓冲区的复制内容,同时更改返回的NIO缓冲区的位置和限制不会影响此索引和标记缓冲。
|
java.nio.ByteOrder |
order()
返回此缓冲区的
endianness 。
|
ByteBuf |
readBytes(java.nio.ByteBuffer dst)
将缓冲区的数据从当前的
readerIndex开始传送到指定的目标位置,直到目标位置达到其限制,然后将
readerIndex增加
readerIndex 。
|
int |
readBytes(java.nio.channels.FileChannel out, long position, int length)
将此缓冲区的数据从当前的
readerIndex到指定通道,从给定的文件位置开始。
|
int |
readBytes(java.nio.channels.GatheringByteChannel out, int length)
将此缓冲区的数据从当前的
readerIndex开始传输到指定的流。
|
ByteBuf |
setBytes(int index, byte[] src, int srcIndex, int length)
将指定的源数组的数据传输到此缓冲区,从指定的绝对
index 。
|
ByteBuf |
setBytes(int index, java.nio.ByteBuffer src)
将指定的源缓冲区的数据从指定的绝对
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 |
setZero(int index, int length)
以
NUL (0x00)填充此缓冲区,从指定的绝对
index 。
|
ByteBuf |
unwrap()
如果此缓冲区是另一个缓冲区的包装,则返回底层缓冲区实例。
|
ByteBuf |
writeZero(int length)
填充这个缓冲器与
NUL (0x00)并从当前
writerIndex并增加了
writerIndex由指定的
length 。
|
refCnt, release, release, retain, retain, setRefCnt, touch, touchadjustMarkers, asReadOnly, bytesBefore, bytesBefore, bytesBefore, checkDstIndex, checkIndex, checkIndex, checkNewCapacity, checkReadableBytes, checkSrcIndex, clear, compareTo, copy, discardReadBytes, discardSomeReadBytes, duplicate, ensureAccessible, ensureWritable, ensureWritable, equals, forEachByte, forEachByte, forEachByteDesc, forEachByteDesc, getBoolean, getByte, getBytes, getBytes, getBytes, getChar, getCharSequence, getDouble, getFloat, getInt, getIntLE, getLong, getLongLE, getMedium, getMediumLE, getShort, getShortLE, getUnsignedByte, getUnsignedInt, getUnsignedIntLE, getUnsignedMedium, getUnsignedMediumLE, getUnsignedShort, getUnsignedShortLE, hashCode, indexOf, isReadable, isReadable, isReadOnly, isWritable, isWritable, markReaderIndex, markWriterIndex, maxCapacity, maxCapacity, maxWritableBytes, nioBuffer, nioBuffers, order, readableBytes, readBoolean, readByte, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readChar, readCharSequence, readDouble, readerIndex, readerIndex, readFloat, readInt, readIntLE, readLong, readLongLE, readMedium, readMediumLE, readRetainedSlice, readShort, readShortLE, readSlice, readUnsignedByte, readUnsignedInt, readUnsignedIntLE, readUnsignedMedium, readUnsignedMediumLE, readUnsignedShort, readUnsignedShortLE, resetReaderIndex, resetWriterIndex, retainedDuplicate, retainedSlice, retainedSlice, setBoolean, setByte, setBytes, setBytes, setBytes, setChar, setCharSequence, setDouble, setFloat, setIndex, setInt, setIntLE, setLong, setLongLE, setMedium, setMediumLE, setShort, setShortLE, skipBytes, slice, slice, toString, toString, toString, writableBytes, writeBoolean, writeByte, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeChar, writeCharSequence, writeDouble, writeFloat, writeInt, writeIntLE, writeLong, writeLongLE, writeMedium, writeMediumLE, writerIndex, writerIndex, writeShort, writeShortLEgetDoubleLE, getFloatLE, readDoubleLE, readFloatLE, setDoubleLE, setFloatLE, writeDoubleLE, writeFloatLEpublic UnpooledUnsafeDirectByteBuf(ByteBufAllocator alloc, int initialCapacity, int maxCapacity)
initialCapacity - 底层直接缓冲区的初始容量
maxCapacity - 底层直接缓冲区的最大容量
protected UnpooledUnsafeDirectByteBuf(ByteBufAllocator alloc, java.nio.ByteBuffer initialBuffer, int maxCapacity)
maxCapacity - 底层直接缓冲区的最大容量
protected java.nio.ByteBuffer allocateDirect(int initialCapacity)
ByteBuffer 。
protected void freeDirect(java.nio.ByteBuffer buffer)
ByteBuffer
public boolean isDirect()
ByteBuf
true 。
public int capacity()
ByteBuf
public ByteBuf capacity(int newCapacity)
ByteBuf
newCapacity小于当前容量,则此缓冲区的内容将被截断。
如果newCapacity大于当前容量,则缓冲区会附加长度为(newCapacity - currentCapacity)未指定数据。
public ByteBufAllocator alloc()
ByteBuf
ByteBufAllocator 。
public java.nio.ByteOrder order()
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
protected byte _getByte(int index)
_getByte在课程
AbstractByteBuf
protected short _getShort(int index)
_getShort在课程
AbstractByteBuf
protected short _getShortLE(int index)
_getShortLE ,课时
AbstractByteBuf
protected int _getUnsignedMedium(int index)
_getUnsignedMedium
AbstractByteBuf
protected int _getUnsignedMediumLE(int index)
_getUnsignedMediumLE
AbstractByteBuf
protected int _getInt(int index)
_getInt在课堂
AbstractByteBuf
protected int _getIntLE(int index)
_getIntLE在课程
AbstractByteBuf
protected long _getLong(int index)
_getLong在课程
AbstractByteBuf
protected long _getLongLE(int index)
_getLongLE在课程
AbstractByteBuf
public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length)
ByteBuf
index 。
此方法不会修改源(即this )和目标的readerIndex或writerIndex 。
public ByteBuf getBytes(int index, byte[] dst, int dstIndex, int length)
ByteBuf
index开始的目标index 。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public ByteBuf getBytes(int index, java.nio.ByteBuffer dst)
ByteBuf
index开始,直到目的地的位置达到其限制。
此方法不会修改此缓冲区的readerIndex或writerIndex ,而目标的position将会增加。
public ByteBuf readBytes(java.nio.ByteBuffer dst)
ByteBuf
readerIndex开始,直到目标的位置达到其限制,并将
readerIndex增加
readerIndex传输的字节数。
readBytes在课程
AbstractByteBuf
protected void _setByte(int index,
int value)
_setByte
AbstractByteBuf
protected void _setShort(int index,
int value)
_setShort在课程
AbstractByteBuf
protected void _setShortLE(int index,
int value)
_setShortLE在课堂
AbstractByteBuf
protected void _setMedium(int index,
int value)
_setMedium
AbstractByteBuf
protected void _setMediumLE(int index,
int value)
_setMediumLE在课堂
AbstractByteBuf
protected void _setInt(int index,
int value)
_setInt在课程
AbstractByteBuf
protected void _setIntLE(int index,
int value)
_setIntLE ,课时
AbstractByteBuf
protected void _setLong(int index,
long value)
_setLong
AbstractByteBuf
protected void _setLongLE(int index,
long value)
_setLongLE在课程
AbstractByteBuf
public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length)
ByteBuf
index开始传输到此缓冲区。
此方法不会修改源(即this )和目标的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 ByteBuf getBytes(int index, java.io.OutputStream out, int length) throws java.io.IOException
ByteBuf
index 。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public int getBytes(int index,
java.nio.channels.GatheringByteChannel out,
int length)
throws java.io.IOException
ByteBuf
index 。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public int getBytes(int index,
java.nio.channels.FileChannel out,
long position,
int length)
throws java.io.IOException
ByteBuf
index到指定的通道,从给定的文件位置开始。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
此方法不会修改频道的位置。
public int readBytes(java.nio.channels.GatheringByteChannel out,
int length)
throws java.io.IOException
ByteBuf
readerIndex开始传输到指定的流。
readBytes在课堂
AbstractByteBuf
length - 传输的最大字节数
java.io.IOException - 如果指定的通道在I / O期间引发异常
public int readBytes(java.nio.channels.FileChannel out,
long position,
int length)
throws java.io.IOException
ByteBuf
readerIndex到指定的通道,从给定的文件位置开始。
此方法不会修改频道的位置。
readBytes在课程
AbstractByteBuf
position - 传输开始的文件位置
length - 传输的最大字节数
java.io.IOException - 如果指定的通道在I / O期间引发异常
public int setBytes(int index,
java.io.InputStream in,
int length)
throws java.io.IOException
ByteBuf
index开始传输到此缓冲区。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public int setBytes(int index,
java.nio.channels.ScatteringByteChannel in,
int length)
throws java.io.IOException
ByteBuf
index开始传送到此缓冲区。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
public int setBytes(int index,
java.nio.channels.FileChannel in,
long position,
int length)
throws java.io.IOException
ByteBuf
index 。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
此方法不会修改频道的位置。
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[] nioBuffers(int index,
int length)
ByteBuf
ByteBuffer返回的缓冲区共享或包含此缓冲区的复制内容,同时更改返回的NIO缓冲区的位置和限制不会影响此索引和标记缓冲。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
请注意,如果此缓冲区是动态缓冲区并且它调整了其容量,则返回的NIO缓冲区将不会看到此缓冲区的更改。
nioBuffers在课程
ByteBuf
ByteBuf.nioBufferCount() ,
ByteBuf.nioBuffer() ,
ByteBuf.nioBuffer(int, int)
public ByteBuf copy(int index, int length)
ByteBuf
readerIndex或writerIndex 。
public java.nio.ByteBuffer internalNioBuffer(int index,
int length)
ByteBuf
internalNioBuffer
ByteBuf
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)
protected void deallocate()
AbstractReferenceCountedByteBuf
deallocate ,课时
AbstractReferenceCountedByteBuf
protected SwappedByteBuf newSwappedByteBuf()
AbstractByteBuf
ByteBuf实例创建一个新的SwappedByteBuf 。
newSwappedByteBuf ,课时
AbstractByteBuf
public ByteBuf setZero(int index, int length)
ByteBuf
index 。
此方法不会修改此缓冲区的readerIndex或writerIndex 。
setZero在课程
AbstractByteBuf
length - 写入缓冲区的数量
NUL
public ByteBuf writeZero(int length)
ByteBuf
writerIndex增加
writerIndex指定的
length 。
writeZero在课堂
AbstractByteBuf
length - 写入缓冲区的数量
NUL
Copyright © 2008–2018 The Netty Project. All rights reserved.