Package io.netty.buffer
Class PooledDirectByteBuf
- java.lang.Object
-
- io.netty.buffer.ByteBuf
-
- io.netty.buffer.AbstractByteBuf
-
- io.netty.buffer.AbstractReferenceCountedByteBuf
-
- io.netty.buffer.PooledByteBuf<java.nio.ByteBuffer>
-
- io.netty.buffer.PooledDirectByteBuf
-
- All Implemented Interfaces:
ReferenceCounted,java.lang.Comparable<ByteBuf>
final class PooledDirectByteBuf extends PooledByteBuf<java.nio.ByteBuffer>
-
-
Field Summary
Fields Modifier and Type Field Description private static ObjectPool<PooledDirectByteBuf>RECYCLER-
Fields 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
Constructors Modifier Constructor Description privatePooledDirectByteBuf(ObjectPool.Handle<PooledDirectByteBuf> recyclerHandle, int maxCapacity)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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.intarrayOffset()Returns the offset of the first byte within the backing byte array of this buffer.ByteBufcopy(int index, int length)Returns a copy of this buffer's sub-region.ByteBufgetBytes(int index, byte[] dst, int dstIndex, int length)Transfers this buffer's data to the specified destination starting at the specified absoluteindex.ByteBufgetBytes(int index, ByteBuf dst, int dstIndex, int length)Transfers this buffer's data to the specified destination starting at the specified absoluteindex.ByteBufgetBytes(int index, java.io.OutputStream out, int length)Transfers this buffer's data to the specified stream starting at the specified absoluteindex.private voidgetBytes(int index, java.io.OutputStream out, int length, boolean internal)ByteBufgetBytes(int index, java.nio.ByteBuffer dst)Transfers this buffer's data to the specified destination starting at the specified absoluteindexuntil the destination's position reaches its limit.booleanhasArray()Returnstrueif and only if this buffer has a backing byte array.booleanhasMemoryAddress()Returnstrueif and only if this buffer has a reference to the low-level memory address that points to the backing data.booleanisDirect()Returnstrueif and only if this buffer is backed by an NIO direct buffer.longmemoryAddress()Returns the low-level memory address that point to the first byte of ths backing data.(package private) static PooledDirectByteBufnewInstance(int maxCapacity)protected java.nio.ByteBuffernewInternalNioBuffer(java.nio.ByteBuffer memory)ByteBufreadBytes(byte[] dst, int dstIndex, int length)Transfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length).ByteBufreadBytes(java.io.OutputStream out, int length)Transfers this buffer's data to the specified stream starting at the currentreaderIndex.ByteBufreadBytes(java.nio.ByteBuffer dst)Transfers this buffer's data to the specified destination starting at the currentreaderIndexuntil the destination's position reaches its limit, and increases thereaderIndexby the number of the transferred bytes.ByteBufsetBytes(int index, byte[] src, int srcIndex, int length)Transfers the specified source array's data to this buffer starting at the specified absoluteindex.ByteBufsetBytes(int index, ByteBuf src, int srcIndex, int length)Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex.intsetBytes(int index, java.io.InputStream in, int length)Transfers the content of the specified source stream to this buffer starting at the specified absoluteindex.ByteBufsetBytes(int index, java.nio.ByteBuffer src)Transfers the specified source buffer's data to this buffer starting at the specified absoluteindexuntil the source buffer's position reaches its limit.-
Methods inherited from class io.netty.buffer.PooledByteBuf
_internalNioBuffer, alloc, capacity, capacity, deallocate, duplicateInternalNioBuffer, 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, 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
getDoubleLE, getFloatLE, readDoubleLE, readFloatLE, setDoubleLE, setFloatLE, writeDoubleLE, writeFloatLE
-
-
-
-
Field Detail
-
RECYCLER
private static final ObjectPool<PooledDirectByteBuf> RECYCLER
-
-
Constructor Detail
-
PooledDirectByteBuf
private PooledDirectByteBuf(ObjectPool.Handle<PooledDirectByteBuf> recyclerHandle, int maxCapacity)
-
-
Method Detail
-
newInstance
static PooledDirectByteBuf newInstance(int maxCapacity)
-
newInternalNioBuffer
protected java.nio.ByteBuffer newInternalNioBuffer(java.nio.ByteBuffer memory)
- Specified by:
newInternalNioBufferin classPooledByteBuf<java.nio.ByteBuffer>
-
isDirect
public boolean isDirect()
Description copied from class:ByteBufReturnstrueif and only if this buffer is backed by an NIO direct buffer.
-
_getByte
protected byte _getByte(int index)
- Specified by:
_getBytein classAbstractByteBuf
-
_getShort
protected short _getShort(int index)
- Specified by:
_getShortin classAbstractByteBuf
-
_getShortLE
protected short _getShortLE(int index)
- Specified by:
_getShortLEin classAbstractByteBuf
-
_getUnsignedMedium
protected int _getUnsignedMedium(int index)
- Specified by:
_getUnsignedMediumin classAbstractByteBuf
-
_getUnsignedMediumLE
protected int _getUnsignedMediumLE(int index)
- Specified by:
_getUnsignedMediumLEin classAbstractByteBuf
-
_getInt
protected int _getInt(int index)
- Specified by:
_getIntin classAbstractByteBuf
-
_getIntLE
protected int _getIntLE(int index)
- Specified by:
_getIntLEin classAbstractByteBuf
-
_getLong
protected long _getLong(int index)
- Specified by:
_getLongin classAbstractByteBuf
-
_getLongLE
protected long _getLongLE(int index)
- Specified by:
_getLongLEin classAbstractByteBuf
-
getBytes
public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof both the source (i.e.this) and the destination.
-
getBytes
public ByteBuf getBytes(int index, byte[] dst, int dstIndex, int length)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
readBytes
public ByteBuf readBytes(byte[] dst, int dstIndex, int length)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length).- Overrides:
readBytesin classAbstractByteBufdstIndex- the first index of the destinationlength- the number of bytes to transfer
-
getBytes
public ByteBuf getBytes(int index, java.nio.ByteBuffer dst)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the specified absoluteindexuntil the destination's position reaches its limit. This method does not modifyreaderIndexorwriterIndexof this buffer while the destination'spositionwill be increased.
-
readBytes
public ByteBuf readBytes(java.nio.ByteBuffer dst)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the currentreaderIndexuntil the destination's position reaches its limit, and increases thereaderIndexby the number of the transferred bytes.- Overrides:
readBytesin classAbstractByteBuf
-
getBytes
public ByteBuf getBytes(int index, java.io.OutputStream out, int length) throws java.io.IOException
Description copied from class:ByteBufTransfers this buffer's data to the specified stream starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
getBytes
private void getBytes(int index, java.io.OutputStream out, int length, boolean internal) throws java.io.IOException- Throws:
java.io.IOException
-
readBytes
public ByteBuf readBytes(java.io.OutputStream out, int length) throws java.io.IOException
Description copied from class:ByteBufTransfers this buffer's data to the specified stream starting at the currentreaderIndex.- Overrides:
readBytesin classAbstractByteBuflength- the number of bytes to transfer- Throws:
java.io.IOException- if the specified stream threw an exception during I/O
-
_setByte
protected void _setByte(int index, int value)- Specified by:
_setBytein classAbstractByteBuf
-
_setShort
protected void _setShort(int index, int value)- Specified by:
_setShortin classAbstractByteBuf
-
_setShortLE
protected void _setShortLE(int index, int value)- Specified by:
_setShortLEin classAbstractByteBuf
-
_setMedium
protected void _setMedium(int index, int value)- Specified by:
_setMediumin classAbstractByteBuf
-
_setMediumLE
protected void _setMediumLE(int index, int value)- Specified by:
_setMediumLEin classAbstractByteBuf
-
_setInt
protected void _setInt(int index, int value)- Specified by:
_setIntin classAbstractByteBuf
-
_setIntLE
protected void _setIntLE(int index, int value)- Specified by:
_setIntLEin classAbstractByteBuf
-
_setLong
protected void _setLong(int index, long value)- Specified by:
_setLongin classAbstractByteBuf
-
_setLongLE
protected void _setLongLE(int index, long value)- Specified by:
_setLongLEin classAbstractByteBuf
-
setBytes
public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length)
Description copied from class:ByteBufTransfers the specified source buffer's data to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof both the source (i.e.this) and the destination.
-
setBytes
public ByteBuf setBytes(int index, byte[] src, int srcIndex, int length)
Description copied from class:ByteBufTransfers the specified source array's data to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setBytes
public ByteBuf setBytes(int index, java.nio.ByteBuffer src)
Description copied from class:ByteBufTransfers the specified source buffer's data to this buffer starting at the specified absoluteindexuntil the source buffer's position reaches its limit. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setBytes
public int setBytes(int index, java.io.InputStream in, int length) throws java.io.IOExceptionDescription copied from class:ByteBufTransfers the content of the specified source stream to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
copy
public ByteBuf copy(int index, int length)
Description copied from class:ByteBufReturns 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 modifyreaderIndexorwriterIndexof this buffer.
-
hasArray
public boolean hasArray()
Description copied from class:ByteBufReturnstrueif and only if this buffer has a backing byte array. If this method returns true, you can safely callByteBuf.array()andByteBuf.arrayOffset().
-
array
public byte[] array()
Description copied from class:ByteBufReturns the backing byte array of this buffer.
-
arrayOffset
public int arrayOffset()
Description copied from class:ByteBufReturns the offset of the first byte within the backing byte array of this buffer.- Specified by:
arrayOffsetin classByteBuf
-
hasMemoryAddress
public boolean hasMemoryAddress()
Description copied from class:ByteBufReturnstrueif and only if this buffer has a reference to the low-level memory address that points to the backing data.- Specified by:
hasMemoryAddressin classByteBuf
-
memoryAddress
public long memoryAddress()
Description copied from class:ByteBufReturns the low-level memory address that point to the first byte of ths backing data.- Specified by:
memoryAddressin classByteBuf
-
-