Class ReadOnlyByteBufferBuf.ReadOnlySlicedByteBuf

    • Constructor Detail

      • ReadOnlySlicedByteBuf

        ReadOnlySlicedByteBuf​(ByteBuf buffer,
                              int index,
                              int length)
    • Method Detail

      • slice

        public ByteBuf slice​(int index,
                             int length)
        Description copied from class: ByteBuf
        Returns a slice of this buffer's sub-region. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method does not modify readerIndex or writerIndex of this buffer.

        Also be aware that this method will NOT call ByteBuf.retain() and so the reference count will NOT be increased.

        Overrides:
        slice in class AbstractUnpooledSlicedByteBuf
      • duplicate

        public ByteBuf duplicate()
        Description copied from class: ByteBuf
        Returns a buffer which shares the whole region of this buffer. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method does not modify readerIndex or writerIndex of this buffer.

        The reader and writer marks will not be duplicated. Also be aware that this method will NOT call ByteBuf.retain() and so the reference count will NOT be increased.

        Overrides:
        duplicate in class AbstractUnpooledSlicedByteBuf
        Returns:
        A buffer whose readable content is equivalent to the buffer returned by ByteBuf.slice(). However this buffer will share the capacity of the underlying buffer, and therefore allows access to all of the underlying content if necessary.
      • isWritable

        public boolean isWritable()
        Description copied from class: ByteBuf
        Returns true if and only if (this.capacity - this.writerIndex) is greater than 0.
        Overrides:
        isWritable in class AbstractByteBuf
      • isWritable

        public boolean isWritable​(int numBytes)
        Description copied from class: ByteBuf
        Returns true if and only if this buffer has enough room to allow writing the specified number of elements.
        Overrides:
        isWritable in class AbstractByteBuf
      • ensureWritable

        public int ensureWritable​(int minWritableBytes,
                                  boolean force)
        Description copied from class: ByteBuf
        Expands the buffer ByteBuf.capacity() to make sure the number of writable bytes is equal to or greater than the specified value. Unlike ByteBuf.ensureWritable(int), this method returns a status code.
        Overrides:
        ensureWritable in class AbstractByteBuf
        Parameters:
        minWritableBytes - the expected minimum number of writable bytes
        force - When ByteBuf.writerIndex() + minWritableBytes > ByteBuf.maxCapacity():
        • true - the capacity of the buffer is expanded to ByteBuf.maxCapacity()
        • false - the capacity of the buffer is unchanged
        Returns:
        0 if the buffer has enough writable bytes, and its capacity is unchanged. 1 if the buffer does not have enough bytes, and its capacity is unchanged. 2 if the buffer has enough writable bytes, and its capacity has been increased. 3 if the buffer does not have enough bytes, but its capacity has been increased to its maximum.