Class UnpooledUnsafeDirectByteBuf

All Implemented Interfaces:
ByteBufConvertible, ReferenceCounted, Comparable<ByteBuf>

public class UnpooledUnsafeDirectByteBuf extends UnpooledDirectByteBuf
A NIO ByteBuffer based buffer. It is recommended to use AbstractByteBufAllocator.directBuffer(int, int), Unpooled.directBuffer(int) and Unpooled.wrappedBuffer(ByteBuffer) instead of calling the constructor explicitly.}
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    UnpooledUnsafeDirectByteBuf(ByteBufAllocator alloc, int initialCapacity, int maxCapacity)
    Creates a new direct buffer.
    protected
    UnpooledUnsafeDirectByteBuf(ByteBufAllocator alloc, ByteBuffer initialBuffer, int maxCapacity)
    Creates a new direct buffer by wrapping the specified initial buffer.
  • Method Summary

    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
     
    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)
     
    copy(int index, int length)
    Returns a copy of this buffer's sub-region.
    byte
    getByte(int index)
    Gets a byte at the specified absolute index in this buffer.
    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
    getInt(int index)
    Gets a 32-bit integer at the specified absolute index in this buffer.
    long
    getLong(int index)
    Gets a 64-bit long integer at the specified absolute index in this buffer.
    short
    getShort(int index)
    Gets a 16-bit short integer at the specified absolute index in this buffer.
    int
    getUnsignedMedium(int index)
    Gets an unsigned 24-bit medium integer at the specified absolute index in this buffer.
    boolean
    Returns true if and only if this buffer has a reference to the low-level memory address that points to the backing data.
    long
    Returns the low-level memory address that point to the first byte of ths backing data.
    protected SwappedByteBuf
    Creates a new SwappedByteBuf for this ByteBuf instance.
    setByte(int index, int value)
    Sets the specified byte at the specified absolute index in this buffer.
    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.
    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, InputStream in, int length)
    Transfers the content of the specified source stream to this buffer starting at the specified absolute index.
    setBytes(int index, 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.
    setInt(int index, int value)
    Sets the specified 32-bit integer at the specified absolute index in this buffer.
    setLong(int index, long value)
    Sets the specified 64-bit long integer at the specified absolute index in this buffer.
    setMedium(int index, int value)
    Sets the specified 24-bit medium integer at the specified absolute index in this buffer.
    setShort(int index, int value)
    Sets the specified 16-bit short integer at the specified absolute index in this buffer.
    setZero(int index, int length)
    Fills this buffer with NUL (0x00) starting at the specified absolute index.
    writeZero(int length)
    Fills this buffer with NUL (0x00) starting at the current writerIndex and increases the writerIndex by the specified length.

    Methods inherited from class UnpooledDirectByteBuf

    alloc, allocateDirect, array, arrayOffset, capacity, capacity, deallocate, freeDirect, getBytes, getBytes, getBytes, getBytes, getBytes, hasArray, internalNioBuffer, isContiguous, isDirect, nioBuffer, nioBufferCount, nioBuffers, order, readBytes, readBytes, readBytes, readBytes, readBytes, setBytes, setBytes, unwrap
    Modifier and Type
    Method
    Description
    Returns the ByteBufAllocator which created this buffer.
    protected ByteBuffer
    allocateDirect(int initialCapacity)
    Allocate a new direct ByteBuffer with the given initialCapacity.
    byte[]
    Returns the backing byte array of this buffer.
    int
    Returns the offset of the first byte within the backing byte array of this buffer.
    int
    Returns the number of bytes (octets) this buffer can contain.
    capacity(int newCapacity)
    Adjusts the capacity of this buffer.
    protected void
    protected void
    Free a direct ByteBuffer
    getBytes(int index, byte[] dst, int dstIndex, int length)
    Transfers this buffer's data to the specified destination starting at the specified absolute index.
    getBytes(int index, OutputStream out, int length)
    Transfers this buffer's data to the specified stream starting at the specified absolute index.
    getBytes(int index, 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.
    int
    getBytes(int index, 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.
    int
    getBytes(int index, GatheringByteChannel out, int length)
    Transfers this buffer's data to the specified channel starting at the specified absolute index.
    boolean
    Returns true if and only if this buffer has a backing byte array.
    internalNioBuffer(int index, int length)
    Internal use only: Exposes the internal NIO buffer.
    final boolean
    Returns true if this ByteBuf implementation is backed by a single memory region.
    boolean
    Returns true if and only if this buffer is backed by an NIO direct buffer.
    nioBuffer(int index, int length)
    Exposes this buffer's sub-region as an NIO ByteBuffer.
    int
    Returns the maximum number of NIO ByteBuffers that consist this buffer.
    nioBuffers(int index, int length)
    Exposes this buffer's bytes as an NIO ByteBuffer's for the specified index and length The returned buffer either share or contains the copied content of this buffer, while changing the position and limit of the returned NIO buffer does not affect the indexes and marks of this buffer.
    Returns the endianness of this buffer.
    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).
    readBytes(OutputStream out, int length)
    Transfers this buffer's data to the specified stream starting at the current readerIndex.
    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(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(GatheringByteChannel out, int length)
    Transfers this buffer's data to the specified stream starting at the current readerIndex.
    int
    setBytes(int index, 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, ScatteringByteChannel in, int length)
    Transfers the content of the specified source channel to this buffer starting at the specified absolute index.
    Return the underlying buffer instance if this buffer is a wrapper of another buffer.

    Methods inherited from class AbstractReferenceCountedByteBuf

    refCnt, release, release, resetRefCnt, retain, retain, setRefCnt, touch, touch
    Modifier and Type
    Method
    Description
    int
    Returns the reference count of this object.
    boolean
    Decreases the reference count by 1 and deallocates this object if the reference count reaches at 0.
    boolean
    release(int decrement)
    Decreases the reference count by the specified decrement and deallocates this object if the reference count reaches at 0.
    protected final void
    An unsafe operation intended for use by a subclass that resets the reference count of the buffer to 1
    Increases the reference count by 1.
    retain(int increment)
    Increases the reference count by the specified increment.
    protected final void
    setRefCnt(int refCnt)
    An unsafe operation intended for use by a subclass that sets the reference count of the buffer directly
    Records the current access location of this object for debugging purposes.
    touch(Object hint)
    Records the current access location of this object with an additional arbitrary information for debugging purposes.

    Methods inherited from class AbstractByteBuf

    adjustMarkers, asReadOnly, bytesBefore, bytesBefore, bytesBefore, checkDstIndex, checkDstIndex, checkIndex, checkIndex, checkNewCapacity, checkReadableBytes, checkSrcIndex, clear, compareTo, copy, discardReadBytes, discardSomeReadBytes, duplicate, ensureAccessible, ensureWritable, ensureWritable, equals, forEachByte, forEachByte, forEachByteDesc, forEachByteDesc, getBoolean, getBytes, getBytes, getBytes, getChar, getCharSequence, getDouble, getFloat, getIntLE, getLongLE, getMedium, getMediumLE, getShortLE, getUnsignedByte, getUnsignedInt, getUnsignedIntLE, 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, 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, setBytes, setBytes, setBytes, setChar, setCharSequence, setDouble, setFloat, setIndex, setIntLE, setLongLE, setMediumLE, setShortLE, 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
    Modifier and Type
    Method
    Description
    protected final void
    adjustMarkers(int decrement)
     
    Returns a read-only version of this buffer.
    int
    bytesBefore(byte value)
    Locates the first occurrence of the specified value in this buffer.
    int
    bytesBefore(int length, byte value)
    Locates the first occurrence of the specified value in this buffer.
    int
    bytesBefore(int index, int length, byte value)
    Locates the first occurrence of the specified value in this buffer.
    protected final void
    checkDstIndex(int length, int dstIndex, int dstCapacity)
     
    protected final void
    checkDstIndex(int index, int length, int dstIndex, int dstCapacity)
     
    protected final void
    checkIndex(int index)
     
    protected final void
    checkIndex(int index, int fieldLength)
     
    protected final void
    checkNewCapacity(int newCapacity)
     
    protected final void
    checkReadableBytes(int minimumReadableBytes)
    Throws an IndexOutOfBoundsException if the current readable bytes of this buffer is less than the specified value.
    protected final void
    checkSrcIndex(int index, int length, int srcIndex, int srcCapacity)
     
    Sets the readerIndex and writerIndex of this buffer to 0.
    int
    Compares the content of the specified buffer to the content of this buffer.
    Returns a copy of this buffer's readable bytes.
    Discards the bytes between the 0th index and readerIndex.
    Similar to ByteBuf.discardReadBytes() except that this method might discard some, all, or none of read bytes depending on its internal implementation to reduce overall memory bandwidth consumption at the cost of potentially additional memory consumption.
    Returns a buffer which shares the whole region of this buffer.
    protected final void
    Should be called by every method that tries to access the buffers content to check if the buffer was released before.
    ensureWritable(int minWritableBytes)
    Expands the buffer ByteBuf.capacity() to make sure the number of writable bytes is equal to or greater than the specified value.
    int
    ensureWritable(int minWritableBytes, boolean force)
    Expands the buffer ByteBuf.capacity() to make sure the number of writable bytes is equal to or greater than the specified value.
    boolean
    Determines if the content of the specified buffer is identical to the content of this array.
    int
    forEachByte(int index, int length, ByteProcessor processor)
    Iterates over the specified area of this buffer with the specified processor in ascending order.
    int
    Iterates over the readable bytes of this buffer with the specified processor in ascending order.
    int
    forEachByteDesc(int index, int length, ByteProcessor processor)
    Iterates over the specified area of this buffer with the specified processor in descending order.
    int
    Iterates over the readable bytes of this buffer with the specified processor in descending order.
    boolean
    getBoolean(int index)
    Gets a boolean at the specified absolute (@code index) in this buffer.
    getBytes(int index, byte[] dst)
    Transfers this buffer's data to the specified destination starting at the specified absolute index.
    getBytes(int index, ByteBuf dst)
    Transfers this buffer's data to the specified destination starting at the specified absolute index until the destination becomes non-writable.
    getBytes(int index, ByteBuf dst, int length)
    Transfers this buffer's data to the specified destination starting at the specified absolute index.
    char
    getChar(int index)
    Gets a 2-byte UTF-16 character at the specified absolute index in this buffer.
    getCharSequence(int index, int length, Charset charset)
    Gets a CharSequence with the given length at the given index.
    double
    getDouble(int index)
    Gets a 64-bit floating point number at the specified absolute index in this buffer.
    float
    getFloat(int index)
    Gets a 32-bit floating point number at the specified absolute index in this buffer.
    int
    getIntLE(int index)
    Gets a 32-bit integer at the specified absolute index in this buffer with Little Endian Byte Order.
    long
    getLongLE(int index)
    Gets a 64-bit long integer at the specified absolute index in this buffer in Little Endian Byte Order.
    int
    getMedium(int index)
    Gets a 24-bit medium integer at the specified absolute index in this buffer.
    int
    getMediumLE(int index)
    Gets a 24-bit medium integer at the specified absolute index in this buffer in the Little Endian Byte Order.
    short
    getShortLE(int index)
    Gets a 16-bit short integer at the specified absolute index in this buffer in Little Endian Byte Order.
    short
    getUnsignedByte(int index)
    Gets an unsigned byte at the specified absolute index in this buffer.
    long
    getUnsignedInt(int index)
    Gets an unsigned 32-bit integer at the specified absolute index in this buffer.
    long
    getUnsignedIntLE(int index)
    Gets an unsigned 32-bit integer at the specified absolute index in this buffer in Little Endian Byte Order.
    int
    Gets an unsigned 24-bit medium integer at the specified absolute index in this buffer in Little Endian Byte Order.
    int
    getUnsignedShort(int index)
    Gets an unsigned 16-bit short integer at the specified absolute index in this buffer.
    int
    getUnsignedShortLE(int index)
    Gets an unsigned 16-bit short integer at the specified absolute index in this buffer in Little Endian Byte Order.
    int
    Returns a hash code which was calculated from the content of this buffer.
    int
    indexOf(int fromIndex, int toIndex, byte value)
    Locates the first occurrence of the specified value in this buffer.
    boolean
    Returns true if and only if (this.writerIndex - this.readerIndex) is greater than 0.
    boolean
    isReadable(int numBytes)
    Returns true if and only if this buffer contains equal to or more than the specified number of elements.
    boolean
    Returns true if and only if this buffer is read-only.
    boolean
    Returns true if and only if (this.capacity - this.writerIndex) is greater than 0.
    boolean
    isWritable(int numBytes)
    Returns true if and only if this buffer has enough room to allow writing the specified number of elements.
    Marks the current readerIndex in this buffer.
    Marks the current writerIndex in this buffer.
    int
    Returns the maximum allowed capacity of this buffer.
    protected final void
    maxCapacity(int maxCapacity)
     
    int
    Returns the maximum possible number of writable bytes, which is equal to (this.maxCapacity - this.writerIndex).
    Exposes this buffer's readable bytes as an NIO ByteBuffer.
    Exposes this buffer's readable bytes as an NIO ByteBuffer's.
    order(ByteOrder endianness)
    Returns a buffer with the specified endianness which shares the whole region, indexes, and marks of this buffer.
    int
    Returns the number of readable bytes which is equal to (this.writerIndex - this.readerIndex).
    boolean
    Gets a boolean at the current readerIndex and increases the readerIndex by 1 in this buffer.
    byte
    Gets a byte at the current readerIndex and increases the readerIndex by 1 in this buffer.
    readBytes(byte[] dst)
    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 (= dst.length).
    readBytes(int length)
    Transfers this buffer's data to a newly created buffer starting at the current readerIndex and increases the readerIndex by the number of the transferred bytes (= length).
    Transfers this buffer's data to the specified destination starting at the current readerIndex until the destination becomes non-writable, and increases the readerIndex by the number of the transferred bytes.
    readBytes(ByteBuf dst, 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).
    readBytes(ByteBuf 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).
    char
    Gets a 2-byte UTF-16 character at the current readerIndex and increases the readerIndex by 2 in this buffer.
    readCharSequence(int length, Charset charset)
    Gets a CharSequence with the given length at the current readerIndex and increases the readerIndex by the given length.
    double
    Gets a 64-bit floating point number at the current readerIndex and increases the readerIndex by 8 in this buffer.
    int
    Returns the readerIndex of this buffer.
    readerIndex(int readerIndex)
    Sets the readerIndex of this buffer.
    float
    Gets a 32-bit floating point number at the current readerIndex and increases the readerIndex by 4 in this buffer.
    int
    Gets a 32-bit integer at the current readerIndex and increases the readerIndex by 4 in this buffer.
    int
    Gets a 32-bit integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 4 in this buffer.
    long
    Gets a 64-bit integer at the current readerIndex and increases the readerIndex by 8 in this buffer.
    long
    Gets a 64-bit integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 8 in this buffer.
    int
    Gets a 24-bit medium integer at the current readerIndex and increases the readerIndex by 3 in this buffer.
    int
    Gets a 24-bit medium integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 3 in this buffer.
    readRetainedSlice(int length)
    Returns a new retained slice of this buffer's sub-region starting at the current readerIndex and increases the readerIndex by the size of the new slice (= length).
    short
    Gets a 16-bit short integer at the current readerIndex and increases the readerIndex by 2 in this buffer.
    short
    Gets a 16-bit short integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 2 in this buffer.
    readSlice(int length)
    Returns a new slice of this buffer's sub-region starting at the current readerIndex and increases the readerIndex by the size of the new slice (= length).
    short
    Gets an unsigned byte at the current readerIndex and increases the readerIndex by 1 in this buffer.
    long
    Gets an unsigned 32-bit integer at the current readerIndex and increases the readerIndex by 4 in this buffer.
    long
    Gets an unsigned 32-bit integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 4 in this buffer.
    int
    Gets an unsigned 24-bit medium integer at the current readerIndex and increases the readerIndex by 3 in this buffer.
    int
    Gets an unsigned 24-bit medium integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 3 in this buffer.
    int
    Gets an unsigned 16-bit short integer at the current readerIndex and increases the readerIndex by 2 in this buffer.
    int
    Gets an unsigned 16-bit short integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 2 in this buffer.
    Repositions the current readerIndex to the marked readerIndex in this buffer.
    Repositions the current writerIndex to the marked writerIndex in this buffer.
    Returns a retained buffer which shares the whole region of this buffer.
    Returns a retained slice of this buffer's readable bytes.
    retainedSlice(int index, int length)
    Returns a retained slice of this buffer's sub-region.
    setBoolean(int index, boolean value)
    Sets the specified boolean at the specified absolute index in this buffer.
    setBytes(int index, byte[] src)
    Transfers the specified source array's data to this buffer starting at the specified absolute index.
    setBytes(int index, ByteBuf src)
    Transfers the specified source buffer's data to this buffer starting at the specified absolute index until the source buffer becomes unreadable.
    setBytes(int index, ByteBuf src, int length)
    Transfers the specified source buffer's data to this buffer starting at the specified absolute index.
    setChar(int index, int value)
    Sets the specified 2-byte UTF-16 character at the specified absolute index in this buffer.
    int
    setCharSequence(int index, CharSequence sequence, Charset charset)
    Writes the specified CharSequence at the given index.
    setDouble(int index, double value)
    Sets the specified 64-bit floating-point number at the specified absolute index in this buffer.
    setFloat(int index, float value)
    Sets the specified 32-bit floating-point number at the specified absolute index in this buffer.
    setIndex(int readerIndex, int writerIndex)
    Sets the readerIndex and writerIndex of this buffer in one shot.
    setIntLE(int index, int value)
    Sets the specified 32-bit integer at the specified absolute index in this buffer with Little Endian byte order .
    setLongLE(int index, long value)
    Sets the specified 64-bit long integer at the specified absolute index in this buffer in Little Endian Byte Order.
    setMediumLE(int index, int value)
    Sets the specified 24-bit medium integer at the specified absolute index in this buffer in the Little Endian Byte Order.
    setShortLE(int index, int value)
    Sets the specified 16-bit short integer at the specified absolute index in this buffer with the Little Endian Byte Order.
    skipBytes(int length)
    Increases the current readerIndex by the specified length in this buffer.
    Returns a slice of this buffer's readable bytes.
    slice(int index, int length)
    Returns a slice of this buffer's sub-region.
    Returns the string representation of this buffer.
    toString(int index, int length, Charset charset)
    Decodes this buffer's sub-region into a string with the specified character set.
    toString(Charset charset)
    Decodes this buffer's readable bytes into a string with the specified character set name.
    protected final void
    trimIndicesToCapacity(int newCapacity)
     
    int
    Returns the number of writable bytes which is equal to (this.capacity - this.writerIndex).
    writeBoolean(boolean value)
    Sets the specified boolean at the current writerIndex and increases the writerIndex by 1 in this buffer.
    writeByte(int value)
    Sets the specified byte at the current writerIndex and increases the writerIndex by 1 in this buffer.
    writeBytes(byte[] src)
    Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= src.length).
    writeBytes(byte[] src, int srcIndex, int length)
    Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
    Transfers the specified source buffer's data to this buffer starting at the current writerIndex until the source buffer becomes unreadable, and increases the writerIndex by the number of the transferred bytes.
    writeBytes(ByteBuf src, int length)
    Transfers the specified source buffer's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
    writeBytes(ByteBuf src, int srcIndex, int length)
    Transfers the specified source buffer's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
    int
    writeBytes(InputStream in, int length)
    Transfers the content of the specified stream to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes.
    Transfers the specified source buffer's data to this buffer starting at the current writerIndex until the source buffer's position reaches its limit, and increases the writerIndex by the number of the transferred bytes.
    int
    writeBytes(FileChannel in, long position, int length)
    Transfers the content of the specified channel starting at the given file position to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes.
    int
    Transfers the content of the specified channel to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes.
    writeChar(int value)
    Sets the specified 2-byte UTF-16 character at the current writerIndex and increases the writerIndex by 2 in this buffer.
    int
    Writes the specified CharSequence at the current writerIndex and increases the writerIndex by the written bytes. in this buffer.
    writeDouble(double value)
    Sets the specified 64-bit floating point number at the current writerIndex and increases the writerIndex by 8 in this buffer.
    writeFloat(float value)
    Sets the specified 32-bit floating point number at the current writerIndex and increases the writerIndex by 4 in this buffer.
    writeInt(int value)
    Sets the specified 32-bit integer at the current writerIndex and increases the writerIndex by 4 in this buffer.
    writeIntLE(int value)
    Sets the specified 32-bit integer at the current writerIndex in the Little Endian Byte Order and increases the writerIndex by 4 in this buffer.
    writeLong(long value)
    Sets the specified 64-bit long integer at the current writerIndex and increases the writerIndex by 8 in this buffer.
    writeLongLE(long value)
    Sets the specified 64-bit long integer at the current writerIndex in the Little Endian Byte Order and increases the writerIndex by 8 in this buffer.
    writeMedium(int value)
    Sets the specified 24-bit medium integer at the current writerIndex and increases the writerIndex by 3 in this buffer.
    writeMediumLE(int value)
    Sets the specified 24-bit medium integer at the current writerIndex in the Little Endian Byte Order and increases the writerIndex by 3 in this buffer.
    int
    Returns the writerIndex of this buffer.
    writerIndex(int writerIndex)
    Sets the writerIndex of this buffer.
    writeShort(int value)
    Sets the specified 16-bit short integer at the current writerIndex and increases the writerIndex by 2 in this buffer.
    writeShortLE(int value)
    Sets the specified 16-bit short integer in the Little Endian Byte Order at the current writerIndex and increases the writerIndex by 2 in this buffer.

    Methods inherited from class ByteBuf

    asByteBuf, getDoubleLE, getFloatLE, maxFastWritableBytes, readDoubleLE, readFloatLE, setDoubleLE, setFloatLE, writeDoubleLE, writeFloatLE
    Modifier and Type
    Method
    Description
    A ByteBuf can turn into itself.
    double
    getDoubleLE(int index)
    Gets a 64-bit floating point number at the specified absolute index in this buffer in Little Endian Byte Order.
    float
    getFloatLE(int index)
    Gets a 32-bit floating point number at the specified absolute index in this buffer in Little Endian Byte Order.
    int
    Returns the maximum number of bytes which can be written for certain without involving an internal reallocation or data-copy.
    double
    Gets a 64-bit floating point number at the current readerIndex in Little Endian Byte Order and increases the readerIndex by 8 in this buffer.
    float
    Gets a 32-bit floating point number at the current readerIndex in Little Endian Byte Order and increases the readerIndex by 4 in this buffer.
    setDoubleLE(int index, double value)
    Sets the specified 64-bit floating-point number at the specified absolute index in this buffer in Little Endian Byte Order.
    setFloatLE(int index, float value)
    Sets the specified 32-bit floating-point number at the specified absolute index in this buffer in Little Endian Byte Order.
    writeDoubleLE(double value)
    Sets the specified 64-bit floating point number at the current writerIndex in Little Endian Byte Order and increases the writerIndex by 8 in this buffer.
    writeFloatLE(float value)
    Sets the specified 32-bit floating point number at the current writerIndex in Little Endian Byte Order and increases the writerIndex by 4 in this buffer.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • UnpooledUnsafeDirectByteBuf

      public UnpooledUnsafeDirectByteBuf(ByteBufAllocator alloc, int initialCapacity, int maxCapacity)
      Creates a new direct buffer.
      Parameters:
      initialCapacity - the initial capacity of the underlying direct buffer
      maxCapacity - the maximum capacity of the underlying direct buffer
    • UnpooledUnsafeDirectByteBuf

      protected UnpooledUnsafeDirectByteBuf(ByteBufAllocator alloc, ByteBuffer initialBuffer, int maxCapacity)
      Creates a new direct buffer by wrapping the specified initial buffer.
      Parameters:
      maxCapacity - the maximum capacity of the underlying direct buffer
  • Method Details

    • hasMemoryAddress

      public boolean hasMemoryAddress()
      Description copied from class: ByteBuf
      Returns true if and only if this buffer has a reference to the low-level memory address that points to the backing data.
      Overrides:
      hasMemoryAddress in class UnpooledDirectByteBuf
    • memoryAddress

      public long memoryAddress()
      Description copied from class: ByteBuf
      Returns the low-level memory address that point to the first byte of ths backing data.
      Overrides:
      memoryAddress in class UnpooledDirectByteBuf
    • getByte

      public byte getByte(int index)
      Description copied from class: ByteBuf
      Gets a byte at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      getByte in class UnpooledDirectByteBuf
    • _getByte

      protected byte _getByte(int index)
      Overrides:
      _getByte in class UnpooledDirectByteBuf
    • getShort

      public short getShort(int index)
      Description copied from class: ByteBuf
      Gets a 16-bit short integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      getShort in class UnpooledDirectByteBuf
    • _getShort

      protected short _getShort(int index)
      Overrides:
      _getShort in class UnpooledDirectByteBuf
    • _getShortLE

      protected short _getShortLE(int index)
      Overrides:
      _getShortLE in class UnpooledDirectByteBuf
    • getUnsignedMedium

      public int getUnsignedMedium(int index)
      Description copied from class: ByteBuf
      Gets an unsigned 24-bit medium integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      getUnsignedMedium in class UnpooledDirectByteBuf
    • _getUnsignedMedium

      protected int _getUnsignedMedium(int index)
      Overrides:
      _getUnsignedMedium in class UnpooledDirectByteBuf
    • _getUnsignedMediumLE

      protected int _getUnsignedMediumLE(int index)
      Overrides:
      _getUnsignedMediumLE in class UnpooledDirectByteBuf
    • getInt

      public int getInt(int index)
      Description copied from class: ByteBuf
      Gets a 32-bit integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      getInt in class UnpooledDirectByteBuf
    • _getInt

      protected int _getInt(int index)
      Overrides:
      _getInt in class UnpooledDirectByteBuf
    • _getIntLE

      protected int _getIntLE(int index)
      Overrides:
      _getIntLE in class UnpooledDirectByteBuf
    • getLong

      public long getLong(int index)
      Description copied from class: ByteBuf
      Gets a 64-bit long integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      getLong in class UnpooledDirectByteBuf
    • _getLong

      protected long _getLong(int index)
      Overrides:
      _getLong in class UnpooledDirectByteBuf
    • _getLongLE

      protected long _getLongLE(int index)
      Overrides:
      _getLongLE in class UnpooledDirectByteBuf
    • getBytes

      public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length)
      Description copied from class: ByteBuf
      Transfers this buffer's data to the specified destination starting at the specified absolute index. This method does not modify readerIndex or writerIndex of both the source (i.e. this) and the destination.
      Overrides:
      getBytes in class UnpooledDirectByteBuf
      Parameters:
      dstIndex - the first index of the destination
      length - the number of bytes to transfer
    • setByte

      public ByteBuf setByte(int index, int value)
      Description copied from class: ByteBuf
      Sets the specified byte at the specified absolute index in this buffer. The 24 high-order bits of the specified value are ignored. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      setByte in class UnpooledDirectByteBuf
    • _setByte

      protected void _setByte(int index, int value)
      Overrides:
      _setByte in class UnpooledDirectByteBuf
    • setShort

      public ByteBuf setShort(int index, int value)
      Description copied from class: ByteBuf
      Sets the specified 16-bit short integer at the specified absolute index in this buffer. The 16 high-order bits of the specified value are ignored. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      setShort in class UnpooledDirectByteBuf
    • _setShort

      protected void _setShort(int index, int value)
      Overrides:
      _setShort in class UnpooledDirectByteBuf
    • _setShortLE

      protected void _setShortLE(int index, int value)
      Overrides:
      _setShortLE in class UnpooledDirectByteBuf
    • setMedium

      public ByteBuf setMedium(int index, int value)
      Description copied from class: ByteBuf
      Sets the specified 24-bit medium integer at the specified absolute index in this buffer. Please note that the most significant byte is ignored in the specified value. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      setMedium in class UnpooledDirectByteBuf
    • _setMedium

      protected void _setMedium(int index, int value)
      Overrides:
      _setMedium in class UnpooledDirectByteBuf
    • _setMediumLE

      protected void _setMediumLE(int index, int value)
      Overrides:
      _setMediumLE in class UnpooledDirectByteBuf
    • setInt

      public ByteBuf setInt(int index, int value)
      Description copied from class: ByteBuf
      Sets the specified 32-bit integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      setInt in class UnpooledDirectByteBuf
    • _setInt

      protected void _setInt(int index, int value)
      Overrides:
      _setInt in class UnpooledDirectByteBuf
    • _setIntLE

      protected void _setIntLE(int index, int value)
      Overrides:
      _setIntLE in class UnpooledDirectByteBuf
    • setLong

      public ByteBuf setLong(int index, long value)
      Description copied from class: ByteBuf
      Sets the specified 64-bit long integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      setLong in class UnpooledDirectByteBuf
    • _setLong

      protected void _setLong(int index, long value)
      Overrides:
      _setLong in class UnpooledDirectByteBuf
    • _setLongLE

      protected void _setLongLE(int index, long value)
      Overrides:
      _setLongLE in class UnpooledDirectByteBuf
    • setBytes

      public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length)
      Description copied from class: ByteBuf
      Transfers the specified source buffer's data to this buffer starting at the specified absolute index. This method does not modify readerIndex or writerIndex of both the source (i.e. this) and the destination.
      Overrides:
      setBytes in class UnpooledDirectByteBuf
      Parameters:
      srcIndex - the first index of the source
      length - the number of bytes to transfer
    • setBytes

      public ByteBuf setBytes(int index, byte[] src, int srcIndex, int length)
      Description copied from class: ByteBuf
      Transfers the specified source array's data to this buffer starting at the specified absolute index. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      setBytes in class UnpooledDirectByteBuf
    • setBytes

      public ByteBuf setBytes(int index, ByteBuffer src)
      Description copied from class: ByteBuf
      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. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      setBytes in class UnpooledDirectByteBuf
    • setBytes

      public int setBytes(int index, InputStream in, int length) throws IOException
      Description copied from class: ByteBuf
      Transfers the content of the specified source stream to this buffer starting at the specified absolute index. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      setBytes in class UnpooledDirectByteBuf
      Parameters:
      length - the number of bytes to transfer
      Returns:
      the actual number of bytes read in from the specified channel. -1 if the specified InputStream reached EOF.
      Throws:
      IOException - if the specified stream threw an exception during I/O
    • copy

      public ByteBuf copy(int index, int length)
      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 modify readerIndex or writerIndex of this buffer.
      Overrides:
      copy in class UnpooledDirectByteBuf
    • newSwappedByteBuf

      protected SwappedByteBuf newSwappedByteBuf()
      Description copied from class: AbstractByteBuf
      Creates a new SwappedByteBuf for this ByteBuf instance.
      Overrides:
      newSwappedByteBuf in class AbstractByteBuf
    • setZero

      public ByteBuf setZero(int index, int length)
      Description copied from class: ByteBuf
      Fills this buffer with NUL (0x00) starting at the specified absolute index. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      setZero in class AbstractByteBuf
      Parameters:
      length - the number of NULs to write to the buffer
    • writeZero

      public ByteBuf writeZero(int length)
      Description copied from class: ByteBuf
      Fills this buffer with NUL (0x00) starting at the current writerIndex and increases the writerIndex by the specified length. If this.writableBytes is less than length, ByteBuf.ensureWritable(int) will be called in an attempt to expand capacity to accommodate.
      Overrides:
      writeZero in class AbstractByteBuf
      Parameters:
      length - the number of NULs to write to the buffer