Class UnpooledUnsafeDirectByteBuf

    • Constructor Detail

      • 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,
                                              java.nio.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 Detail

      • 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
      • 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
      • 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
      • 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
      • 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
      • 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
        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
      • 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
      • 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
      • 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
      • 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
      • 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
        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,
                                java.nio.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,
                            java.io.InputStream in,
                            int length)
                     throws java.io.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
        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:
        java.io.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
      • 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
        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