Class UnpooledUnsafeHeapByteBuf

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

public class UnpooledUnsafeHeapByteBuf extends UnpooledHeapByteBuf
Big endian Java heap buffer implementation. It is recommended to use AbstractByteBufAllocator.heapBuffer(int, int), Unpooled.buffer(int) and Unpooled.wrappedBuffer(byte[]) instead of calling the constructor explicitly.
  • Constructor Summary

    Constructors
    Constructor
    Description
    UnpooledUnsafeHeapByteBuf(ByteBufAllocator alloc, int initialCapacity, int maxCapacity)
    Creates a new heap buffer with a newly allocated byte array.
  • 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)
     
    protected byte[]
    allocateArray(int initialCapacity)
     
    byte
    getByte(int index)
    Gets a byte at the specified absolute index in this buffer.
    int
    getInt(int index)
    Gets a 32-bit integer 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
    getLong(int index)
    Gets a 64-bit long integer at the specified absolute index in this buffer.
    long
    getLongLE(int index)
    Gets a 64-bit long integer at the specified absolute index in this buffer in Little Endian Byte Order.
    short
    getShort(int index)
    Gets a 16-bit short integer at the specified absolute index in this buffer.
    short
    getShortLE(int index)
    Gets a 16-bit short integer at the specified absolute index in this buffer in Little Endian Byte Order.
    int
    getUnsignedMedium(int index)
    Gets an unsigned 24-bit medium integer at the specified absolute index in this buffer.
    int
    Gets an unsigned 24-bit medium integer at the specified absolute index in this buffer in Little Endian Byte Order.
    protected SwappedByteBuf
    Deprecated.
    setByte(int index, int value)
    Sets the specified byte at the specified absolute index in this buffer.
    setInt(int index, int value)
    Sets the specified 32-bit integer at the specified absolute index in this buffer.
    setIntLE(int index, int value)
    Sets the specified 32-bit integer at the specified absolute index in this buffer with Little Endian byte order .
    setLong(int index, long value)
    Sets the specified 64-bit long integer at the specified absolute index in this buffer.
    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.
    setMedium(int index, int value)
    Sets the specified 24-bit medium integer at the specified absolute index in this buffer.
    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.
    setShort(int index, int value)
    Sets the specified 16-bit short integer at the specified absolute index in this buffer.
    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.
    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 UnpooledHeapByteBuf

    alloc, array, arrayOffset, capacity, capacity, copy, deallocate, freeArray, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, hasArray, hasMemoryAddress, internalNioBuffer, isContiguous, isDirect, memoryAddress, nioBuffer, nioBufferCount, nioBuffers, order, readBytes, readBytes, setBytes, setBytes, setBytes, setBytes, setBytes, setBytes, unwrap
    Modifier and Type
    Method
    Description
    Returns the ByteBufAllocator which created this buffer.
    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.
    copy(int index, int length)
    Returns a copy of this buffer's sub-region.
    protected void
    protected void
    freeArray(byte[] array)
     
    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, ByteBuf 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.
    boolean
    Returns true if and only if this buffer has a reference to the low-level memory address that points to the backing data.
    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.
    long
    Returns the low-level memory address that point to the first byte of ths backing data.
    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.
    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.
    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.
    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, getMedium, getMediumLE, getUnsignedByte, getUnsignedInt, getUnsignedIntLE, 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, 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, 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
    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
    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
    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(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(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).
    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.
    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.
    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

    • UnpooledUnsafeHeapByteBuf

      public UnpooledUnsafeHeapByteBuf(ByteBufAllocator alloc, int initialCapacity, int maxCapacity)
      Creates a new heap buffer with a newly allocated byte array.
      Parameters:
      initialCapacity - the initial capacity of the underlying byte array
      maxCapacity - the max capacity of the underlying byte array
  • Method Details

    • allocateArray

      protected byte[] allocateArray(int initialCapacity)
      Overrides:
      allocateArray in class UnpooledHeapByteBuf
    • 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 UnpooledHeapByteBuf
    • _getByte

      protected byte _getByte(int index)
      Overrides:
      _getByte in class UnpooledHeapByteBuf
    • 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 UnpooledHeapByteBuf
    • _getShort

      protected short _getShort(int index)
      Overrides:
      _getShort in class UnpooledHeapByteBuf
    • getShortLE

      public short getShortLE(int index)
      Description copied from class: ByteBuf
      Gets a 16-bit short integer at the specified absolute index in this buffer in Little Endian Byte Order. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      getShortLE in class UnpooledHeapByteBuf
    • _getShortLE

      protected short _getShortLE(int index)
      Overrides:
      _getShortLE in class UnpooledHeapByteBuf
    • 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 UnpooledHeapByteBuf
    • _getUnsignedMedium

      protected int _getUnsignedMedium(int index)
      Overrides:
      _getUnsignedMedium in class UnpooledHeapByteBuf
    • getUnsignedMediumLE

      public int getUnsignedMediumLE(int index)
      Description copied from class: ByteBuf
      Gets an unsigned 24-bit medium integer at the specified absolute index in this buffer in Little Endian Byte Order. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      getUnsignedMediumLE in class UnpooledHeapByteBuf
    • _getUnsignedMediumLE

      protected int _getUnsignedMediumLE(int index)
      Overrides:
      _getUnsignedMediumLE in class UnpooledHeapByteBuf
    • 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 UnpooledHeapByteBuf
    • _getInt

      protected int _getInt(int index)
      Overrides:
      _getInt in class UnpooledHeapByteBuf
    • getIntLE

      public int getIntLE(int index)
      Description copied from class: ByteBuf
      Gets a 32-bit integer at the specified absolute index in this buffer with Little Endian Byte Order. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      getIntLE in class UnpooledHeapByteBuf
    • _getIntLE

      protected int _getIntLE(int index)
      Overrides:
      _getIntLE in class UnpooledHeapByteBuf
    • 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 UnpooledHeapByteBuf
    • _getLong

      protected long _getLong(int index)
      Overrides:
      _getLong in class UnpooledHeapByteBuf
    • getLongLE

      public long getLongLE(int index)
      Description copied from class: ByteBuf
      Gets a 64-bit long integer at the specified absolute index in this buffer in Little Endian Byte Order. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      getLongLE in class UnpooledHeapByteBuf
    • _getLongLE

      protected long _getLongLE(int index)
      Overrides:
      _getLongLE in class UnpooledHeapByteBuf
    • 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 UnpooledHeapByteBuf
    • _setByte

      protected void _setByte(int index, int value)
      Overrides:
      _setByte in class UnpooledHeapByteBuf
    • 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 UnpooledHeapByteBuf
    • _setShort

      protected void _setShort(int index, int value)
      Overrides:
      _setShort in class UnpooledHeapByteBuf
    • setShortLE

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

      protected void _setShortLE(int index, int value)
      Overrides:
      _setShortLE in class UnpooledHeapByteBuf
    • 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 UnpooledHeapByteBuf
    • _setMedium

      protected void _setMedium(int index, int value)
      Overrides:
      _setMedium in class UnpooledHeapByteBuf
    • setMediumLE

      public ByteBuf setMediumLE(int index, int value)
      Description copied from class: ByteBuf
      Sets the specified 24-bit medium integer at the specified absolute index in this buffer in the Little Endian Byte Order. 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:
      setMediumLE in class UnpooledHeapByteBuf
    • _setMediumLE

      protected void _setMediumLE(int index, int value)
      Overrides:
      _setMediumLE in class UnpooledHeapByteBuf
    • 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 UnpooledHeapByteBuf
    • _setInt

      protected void _setInt(int index, int value)
      Overrides:
      _setInt in class UnpooledHeapByteBuf
    • setIntLE

      public ByteBuf setIntLE(int index, int value)
      Description copied from class: ByteBuf
      Sets the specified 32-bit integer at the specified absolute index in this buffer with Little Endian byte order . This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      setIntLE in class UnpooledHeapByteBuf
    • _setIntLE

      protected void _setIntLE(int index, int value)
      Overrides:
      _setIntLE in class UnpooledHeapByteBuf
    • 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 UnpooledHeapByteBuf
    • _setLong

      protected void _setLong(int index, long value)
      Overrides:
      _setLong in class UnpooledHeapByteBuf
    • setLongLE

      public ByteBuf setLongLE(int index, long value)
      Description copied from class: ByteBuf
      Sets the specified 64-bit long integer at the specified absolute index in this buffer in Little Endian Byte Order. This method does not modify readerIndex or writerIndex of this buffer.
      Overrides:
      setLongLE in class UnpooledHeapByteBuf
    • _setLongLE

      protected void _setLongLE(int index, long value)
      Overrides:
      _setLongLE in class UnpooledHeapByteBuf
    • 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
    • newSwappedByteBuf

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