final class PooledDirectByteBuf extends PooledByteBuf<java.nio.ByteBuffer>
| Modifier and Type | Field and Description |
|---|---|
private static Recycler<PooledDirectByteBuf> |
RECYCLER |
cache, chunk, handle, length, maxLength, memory, offsetleakDetector, readerIndex, writerIndex| Modifier | Constructor and Description |
|---|---|
private |
PooledDirectByteBuf(Recycler.Handle<PooledDirectByteBuf> recyclerHandle,
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) |
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.
|
ByteBuf |
copy(int index,
int length)
Returns a copy of this buffer's sub-region.
|
ByteBuf |
getBytes(int index,
byte[] dst,
int dstIndex,
int length)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index. |
private void |
getBytes(int index,
byte[] dst,
int dstIndex,
int length,
boolean internal) |
ByteBuf |
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. |
private void |
getBytes(int index,
java.nio.ByteBuffer dst,
boolean internal) |
ByteBuf |
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.FileChannel out,
long position,
int length)
Transfers this buffer's data starting at the specified absolute
index
to the specified channel starting at the given file position. |
private int |
getBytes(int index,
java.nio.channels.FileChannel out,
long position,
int length,
boolean internal) |
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. |
private int |
getBytes(int index,
java.nio.channels.GatheringByteChannel out,
int length,
boolean internal) |
ByteBuf |
getBytes(int index,
java.io.OutputStream out,
int length)
Transfers this buffer's data to the specified stream starting at the
specified absolute
index. |
private void |
getBytes(int index,
java.io.OutputStream out,
int length,
boolean internal) |
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. |
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. |
long |
memoryAddress()
Returns the low-level memory address that point to the first byte of ths backing data.
|
(package private) static PooledDirectByteBuf |
newInstance(int maxCapacity) |
protected java.nio.ByteBuffer |
newInternalNioBuffer(java.nio.ByteBuffer memory) |
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
ByteBuffers that consist this buffer. |
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 shares the content with this buffer, while changing the position and limit
of the returned NIO buffer does not affect the indexes and marks of this buffer. |
ByteBuf |
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). |
ByteBuf |
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. |
int |
readBytes(java.nio.channels.FileChannel out,
long position,
int length)
Transfers this buffer's data starting at the current
readerIndex
to the specified channel starting at the given file position. |
int |
readBytes(java.nio.channels.GatheringByteChannel out,
int length)
Transfers this buffer's data to the specified stream starting at the
current
readerIndex. |
ByteBuf |
readBytes(java.io.OutputStream out,
int length)
Transfers this buffer's data to the specified stream starting at the
current
readerIndex. |
ByteBuf |
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. |
ByteBuf |
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. |
ByteBuf |
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.nio.channels.FileChannel in,
long position,
int length)
Transfers the content of the specified source channel starting at the given file position
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. |
alloc, capacity, capacity, deallocate, idx, init, initUnpooled, internalNioBuffer, order, retainedDuplicate, retainedSlice, retainedSlice, reuse, unwraprefCnt, release, release, retain, retain, setRefCnt, touch, touchadjustMarkers, asReadOnly, bytesBefore, bytesBefore, bytesBefore, checkDstIndex, checkIndex, checkIndex, checkIndex0, checkNewCapacity, checkReadableBytes, checkSrcIndex, clear, compareTo, copy, discardMarks, 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, newSwappedByteBuf, nioBuffer, nioBuffers, order, readableBytes, readBoolean, readByte, 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, setBoolean, setByte, setBytes, setBytes, setBytes, setChar, setCharSequence, setDouble, setFloat, setIndex, setIndex0, setInt, setIntLE, setLong, setLongLE, setMedium, setMediumLE, setShort, setShortLE, setZero, 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, writeShortLE, writeZeroprivate static final Recycler<PooledDirectByteBuf> RECYCLER
private PooledDirectByteBuf(Recycler.Handle<PooledDirectByteBuf> recyclerHandle, int maxCapacity)
static PooledDirectByteBuf newInstance(int maxCapacity)
protected java.nio.ByteBuffer newInternalNioBuffer(java.nio.ByteBuffer memory)
newInternalNioBuffer in class PooledByteBuf<java.nio.ByteBuffer>public boolean isDirect()
ByteBuftrue if and only if this buffer is backed by an
NIO direct buffer.protected byte _getByte(int index)
_getByte in class AbstractByteBufprotected short _getShort(int index)
_getShort in class AbstractByteBufprotected short _getShortLE(int index)
_getShortLE in class AbstractByteBufprotected int _getUnsignedMedium(int index)
_getUnsignedMedium in class AbstractByteBufprotected int _getUnsignedMediumLE(int index)
_getUnsignedMediumLE in class AbstractByteBufprotected int _getInt(int index)
_getInt in class AbstractByteBufprotected int _getIntLE(int index)
_getIntLE in class AbstractByteBufprotected long _getLong(int index)
_getLong in class AbstractByteBufprotected long _getLongLE(int index)
_getLongLE in class AbstractByteBufpublic ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length)
ByteBufindex.
This method does not modify readerIndex or writerIndex
of both the source (i.e. this) and the destination.public ByteBuf getBytes(int index, byte[] dst, int dstIndex, int length)
ByteBufindex.
This method does not modify readerIndex or writerIndex
of this buffer.private void getBytes(int index,
byte[] dst,
int dstIndex,
int length,
boolean internal)
public ByteBuf readBytes(byte[] dst, int dstIndex, int length)
ByteBufreaderIndex and increases the readerIndex
by the number of the transferred bytes (= length).readBytes in class AbstractByteBufdstIndex - the first index of the destinationlength - the number of bytes to transferpublic ByteBuf getBytes(int index, java.nio.ByteBuffer dst)
ByteBufindex 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.private void getBytes(int index,
java.nio.ByteBuffer dst,
boolean internal)
public ByteBuf readBytes(java.nio.ByteBuffer dst)
ByteBufreaderIndex until the destination's position
reaches its limit, and increases the readerIndex by the
number of the transferred bytes.readBytes in class AbstractByteBufpublic ByteBuf getBytes(int index, java.io.OutputStream out, int length) throws java.io.IOException
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer.private void getBytes(int index,
java.io.OutputStream out,
int length,
boolean internal)
throws java.io.IOException
java.io.IOExceptionpublic ByteBuf readBytes(java.io.OutputStream out, int length) throws java.io.IOException
ByteBufreaderIndex.readBytes in class AbstractByteBuflength - the number of bytes to transferjava.io.IOException - if the specified stream threw an exception during I/Opublic int getBytes(int index,
java.nio.channels.GatheringByteChannel out,
int length)
throws java.io.IOException
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer.private int getBytes(int index,
java.nio.channels.GatheringByteChannel out,
int length,
boolean internal)
throws java.io.IOException
java.io.IOExceptionpublic int getBytes(int index,
java.nio.channels.FileChannel out,
long position,
int length)
throws java.io.IOException
ByteBufindex
to the specified channel starting at the given file position.
This method does not modify readerIndex or writerIndex of
this buffer. This method does not modify the channel's position.getBytes in class ByteBufposition - the file position at which the transfer is to beginlength - the maximum number of bytes to transferjava.io.IOException - if the specified channel threw an exception during I/Oprivate int getBytes(int index,
java.nio.channels.FileChannel out,
long position,
int length,
boolean internal)
throws java.io.IOException
java.io.IOExceptionpublic int readBytes(java.nio.channels.GatheringByteChannel out,
int length)
throws java.io.IOException
ByteBufreaderIndex.readBytes in class AbstractByteBuflength - the maximum number of bytes to transferjava.io.IOException - if the specified channel threw an exception during I/Opublic int readBytes(java.nio.channels.FileChannel out,
long position,
int length)
throws java.io.IOException
ByteBufreaderIndex
to the specified channel starting at the given file position.
This method does not modify the channel's position.readBytes in class AbstractByteBufposition - the file position at which the transfer is to beginlength - the maximum number of bytes to transferjava.io.IOException - if the specified channel threw an exception during I/Oprotected void _setByte(int index,
int value)
_setByte in class AbstractByteBufprotected void _setShort(int index,
int value)
_setShort in class AbstractByteBufprotected void _setShortLE(int index,
int value)
_setShortLE in class AbstractByteBufprotected void _setMedium(int index,
int value)
_setMedium in class AbstractByteBufprotected void _setMediumLE(int index,
int value)
_setMediumLE in class AbstractByteBufprotected void _setInt(int index,
int value)
_setInt in class AbstractByteBufprotected void _setIntLE(int index,
int value)
_setIntLE in class AbstractByteBufprotected void _setLong(int index,
long value)
_setLong in class AbstractByteBufprotected void _setLongLE(int index,
long value)
_setLongLE in class AbstractByteBufpublic ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length)
ByteBufindex.
This method does not modify readerIndex or writerIndex
of both the source (i.e. this) and the destination.public ByteBuf setBytes(int index, byte[] src, int srcIndex, int length)
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer.public ByteBuf setBytes(int index, java.nio.ByteBuffer src)
ByteBufindex until the source buffer's position
reaches its limit.
This method does not modify readerIndex or writerIndex of
this buffer.public int setBytes(int index,
java.io.InputStream in,
int length)
throws java.io.IOException
ByteBufindex.
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
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer.public int setBytes(int index,
java.nio.channels.FileChannel in,
long position,
int length)
throws java.io.IOException
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer. This method does not modify the channel's position.setBytes in class ByteBufposition - the file position at which the transfer is to beginlength - the maximum number of bytes to transfer-1 if the specified channel is closed.java.io.IOException - if the specified channel threw an exception during I/Opublic ByteBuf copy(int index, int length)
ByteBufreaderIndex or writerIndex of
this buffer.public int nioBufferCount()
ByteBufByteBuffers that consist this buffer. Note that ByteBuf.nioBuffers()
or ByteBuf.nioBuffers(int, int) might return a less number of ByteBuffers.nioBufferCount in class ByteBuf-1 if this buffer has no underlying ByteBuffer.
the number of the underlying ByteBuffers 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 nioBuffer(int index,
int length)
ByteBufByteBuffer. The returned buffer
shares the content with 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.nioBuffer in class ByteBufByteBuf.nioBufferCount(),
ByteBuf.nioBuffers(),
ByteBuf.nioBuffers(int, int)public java.nio.ByteBuffer[] nioBuffers(int index,
int length)
ByteBufByteBuffer's for the specified index and length
The returned buffer shares the content with 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.nioBuffers in class ByteBufByteBuf.nioBufferCount(),
ByteBuf.nioBuffer(),
ByteBuf.nioBuffer(int, int)public java.nio.ByteBuffer internalNioBuffer(int index,
int length)
ByteBufinternalNioBuffer in class ByteBufpublic boolean hasArray()
ByteBuftrue 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()
ByteBufpublic int arrayOffset()
ByteBufarrayOffset in class ByteBufpublic boolean hasMemoryAddress()
ByteBuftrue if and only if this buffer has a reference to the low-level memory address that points
to the backing data.hasMemoryAddress in class ByteBufpublic long memoryAddress()
ByteBufmemoryAddress in class ByteBuf