Package io.netty.buffer
Class PooledHeapByteBuf
java.lang.Object
io.netty.buffer.ByteBuf
io.netty.buffer.AbstractByteBuf
io.netty.buffer.AbstractReferenceCountedByteBuf
io.netty.buffer.PooledByteBuf<byte[]>
io.netty.buffer.PooledHeapByteBuf
- All Implemented Interfaces:
ByteBufConvertible
,ReferenceCounted
,Comparable<ByteBuf>
- Direct Known Subclasses:
PooledUnsafeHeapByteBuf
-
Field Summary
FieldsFields inherited from class io.netty.buffer.PooledByteBuf
cache, chunk, handle, length, maxLength, memory, offset, tmpNioBuf
Fields inherited from class io.netty.buffer.AbstractByteBuf
checkAccessible, leakDetector, readerIndex, writerIndex
-
Constructor Summary
ConstructorsConstructorDescriptionPooledHeapByteBuf
(ObjectPool.Handle<? extends PooledHeapByteBuf> recyclerHandle, int maxCapacity) -
Method Summary
Modifier and TypeMethodDescriptionprotected 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) final byte[]
array()
Returns the backing byte array of this buffer.final int
Returns the offset of the first byte within the backing byte array of this buffer.final ByteBuf
copy
(int index, int length) Returns a copy of this buffer's sub-region.(package private) final ByteBuffer
duplicateInternalNioBuffer
(int index, int length) final ByteBuf
getBytes
(int index, byte[] dst, int dstIndex, int length) Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.final ByteBuf
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.final ByteBuf
getBytes
(int index, OutputStream out, int length) Transfers this buffer's data to the specified stream starting at the specified absoluteindex
.final ByteBuf
getBytes
(int index, ByteBuffer dst) Transfers this buffer's data to the specified destination starting at the specified absoluteindex
until the destination's position reaches its limit.final boolean
hasArray()
Returnstrue
if and only if this buffer has a backing byte array.final boolean
Returnstrue
if and only if this buffer has a reference to the low-level memory address that points to the backing data.final boolean
isDirect()
Returnstrue
if and only if this buffer is backed by an NIO direct buffer.final long
Returns the low-level memory address that point to the first byte of ths backing data.(package private) static PooledHeapByteBuf
newInstance
(int maxCapacity) protected final ByteBuffer
newInternalNioBuffer
(byte[] memory) final ByteBuf
setBytes
(int index, byte[] src, int srcIndex, int length) Transfers the specified source array's data to this buffer starting at the specified absoluteindex
.final ByteBuf
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
.final int
setBytes
(int index, InputStream in, int length) Transfers the content of the specified source stream to this buffer starting at the specified absoluteindex
.final ByteBuf
setBytes
(int index, ByteBuffer src) Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
until the source buffer's position reaches its limit.Methods inherited from class io.netty.buffer.PooledByteBuf
_internalNioBuffer, alloc, capacity, capacity, deallocate, getBytes, getBytes, idx, init, initUnpooled, internalNioBuffer, internalNioBuffer, isContiguous, maxFastWritableBytes, nioBuffer, nioBufferCount, nioBuffers, order, readBytes, readBytes, retainedDuplicate, retainedSlice, retainedSlice, reuse, setBytes, setBytes, unwrap
Methods inherited from class io.netty.buffer.AbstractReferenceCountedByteBuf
isAccessible, refCnt, release, release, resetRefCnt, retain, retain, setRefCnt, touch, touch
Methods inherited from class io.netty.buffer.AbstractByteBuf
adjustMarkers, asReadOnly, bytesBefore, bytesBefore, bytesBefore, checkDstIndex, checkDstIndex, checkIndex, checkIndex, checkIndex0, checkNewCapacity, checkReadableBytes, checkSrcIndex, clear, compareTo, copy, discardMarks, discardReadBytes, discardSomeReadBytes, duplicate, ensureAccessible, ensureWritable, ensureWritable, ensureWritable0, equals, forEachByte, forEachByte, forEachByteAsc0, forEachByteDesc, forEachByteDesc, forEachByteDesc0, 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, 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, trimIndicesToCapacity, 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, writeZero
Methods inherited from class io.netty.buffer.ByteBuf
asByteBuf, getDoubleLE, getFloatLE, readDoubleLE, readFloatLE, setDoubleLE, setFloatLE, writeDoubleLE, writeFloatLE
-
Field Details
-
RECYCLER
-
-
Constructor Details
-
PooledHeapByteBuf
PooledHeapByteBuf(ObjectPool.Handle<? extends PooledHeapByteBuf> recyclerHandle, int maxCapacity)
-
-
Method Details
-
newInstance
-
isDirect
public final boolean isDirect()Description copied from class:ByteBuf
Returnstrue
if and only if this buffer is backed by an NIO direct buffer. -
_getByte
protected byte _getByte(int index) - Specified by:
_getByte
in classAbstractByteBuf
-
_getShort
protected short _getShort(int index) - Specified by:
_getShort
in classAbstractByteBuf
-
_getShortLE
protected short _getShortLE(int index) - Specified by:
_getShortLE
in classAbstractByteBuf
-
_getUnsignedMedium
protected int _getUnsignedMedium(int index) - Specified by:
_getUnsignedMedium
in classAbstractByteBuf
-
_getUnsignedMediumLE
protected int _getUnsignedMediumLE(int index) - Specified by:
_getUnsignedMediumLE
in classAbstractByteBuf
-
_getInt
protected int _getInt(int index) - Specified by:
_getInt
in classAbstractByteBuf
-
_getIntLE
protected int _getIntLE(int index) - Specified by:
_getIntLE
in classAbstractByteBuf
-
_getLong
protected long _getLong(int index) - Specified by:
_getLong
in classAbstractByteBuf
-
_getLongLE
protected long _getLongLE(int index) - Specified by:
_getLongLE
in classAbstractByteBuf
-
getBytes
Description copied from class:ByteBuf
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of both the source (i.e.this
) and the destination. -
getBytes
Description copied from class:ByteBuf
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer. -
getBytes
Description copied from class:ByteBuf
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
until the destination's position reaches its limit. This method does not modifyreaderIndex
orwriterIndex
of this buffer while the destination'sposition
will be increased. -
getBytes
Description copied from class:ByteBuf
Transfers this buffer's data to the specified stream starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
getBytes
in classByteBuf
- Parameters:
length
- the number of bytes to transfer- Throws:
IOException
- if the specified stream threw an exception during I/O
-
_setByte
protected void _setByte(int index, int value) - Specified by:
_setByte
in classAbstractByteBuf
-
_setShort
protected void _setShort(int index, int value) - Specified by:
_setShort
in classAbstractByteBuf
-
_setShortLE
protected void _setShortLE(int index, int value) - Specified by:
_setShortLE
in classAbstractByteBuf
-
_setMedium
protected void _setMedium(int index, int value) - Specified by:
_setMedium
in classAbstractByteBuf
-
_setMediumLE
protected void _setMediumLE(int index, int value) - Specified by:
_setMediumLE
in classAbstractByteBuf
-
_setInt
protected void _setInt(int index, int value) - Specified by:
_setInt
in classAbstractByteBuf
-
_setIntLE
protected void _setIntLE(int index, int value) - Specified by:
_setIntLE
in classAbstractByteBuf
-
_setLong
protected void _setLong(int index, long value) - Specified by:
_setLong
in classAbstractByteBuf
-
_setLongLE
protected void _setLongLE(int index, long value) - Specified by:
_setLongLE
in classAbstractByteBuf
-
setBytes
Description copied from class:ByteBuf
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of both the source (i.e.this
) and the destination. -
setBytes
Description copied from class:ByteBuf
Transfers the specified source array's data to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer. -
setBytes
Description copied from class:ByteBuf
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
until the source buffer's position reaches its limit. This method does not modifyreaderIndex
orwriterIndex
of this buffer. -
setBytes
Description copied from class:ByteBuf
Transfers the content of the specified source stream to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
setBytes
in classByteBuf
- Parameters:
length
- the number of bytes to transfer- Returns:
- the actual number of bytes read in from the specified channel.
-1
if the specifiedInputStream
reached EOF. - Throws:
IOException
- if the specified stream threw an exception during I/O
-
copy
Description copied from class:ByteBuf
Returns a copy of this buffer's sub-region. Modifying the content of the returned buffer or this buffer does not affect each other at all. This method does not modifyreaderIndex
orwriterIndex
of this buffer. -
duplicateInternalNioBuffer
- Overrides:
duplicateInternalNioBuffer
in classPooledByteBuf<byte[]>
-
hasArray
public final boolean hasArray()Description copied from class:ByteBuf
Returnstrue
if and only if this buffer has a backing byte array. If this method returns true, you can safely callByteBuf.array()
andByteBuf.arrayOffset()
. -
array
public final byte[] array()Description copied from class:ByteBuf
Returns the backing byte array of this buffer. -
arrayOffset
public final int arrayOffset()Description copied from class:ByteBuf
Returns the offset of the first byte within the backing byte array of this buffer.- Specified by:
arrayOffset
in classByteBuf
-
hasMemoryAddress
public final boolean hasMemoryAddress()Description copied from class:ByteBuf
Returnstrue
if and only if this buffer has a reference to the low-level memory address that points to the backing data.- Specified by:
hasMemoryAddress
in classByteBuf
-
memoryAddress
public final long memoryAddress()Description copied from class:ByteBuf
Returns the low-level memory address that point to the first byte of ths backing data.- Specified by:
memoryAddress
in classByteBuf
-
newInternalNioBuffer
- Specified by:
newInternalNioBuffer
in classPooledByteBuf<byte[]>
-