Interface ReadableComponent

    • Method Detail

      • hasReadableArray

        boolean hasReadableArray()
        Check if this component is backed by a cached byte array that can be accessed cheaply.

        Note that regardless of what this method returns, the array should not be used to modify the contents of this buffer component.

        Returns:
        true if readableArray() is a cheap operation, otherwise false.
      • readableArray

        byte[] readableArray()
        Get a byte array of the contents of this component.

        Note that the array is meant to be read-only. It may either be a direct reference to the concrete array instance that is backing this component, or it is a fresh copy. Writing to the array may produce undefined behaviour.

        Returns:
        A byte array of the contents of this component.
        Throws:
        UnsupportedOperationException - if hasReadableArray() returns false.
        See Also:
        readableArrayOffset(), readableArrayLength()
      • readableNativeAddress

        long readableNativeAddress()
        Give the native memory address backing this buffer, or return 0 if this buffer has no native memory address.

        Note that the address should not be used for writing to the buffer memory, and doing so may produce undefined behaviour.

        Returns:
        The native memory address, if any, otherwise 0.
      • readableBytes

        int readableBytes()
        Get the number of readable bytes from this component.
        Returns:
        The number of bytes that can be read from this readable component.
      • openCursor

        ByteCursor openCursor()
        Open a cursor to iterate the readable bytes of this component. Any offsets internal to the component are not modified by the cursor.

        Care should be taken to ensure that the buffers lifetime extends beyond the cursor and the iteration, and that the internal offsets of the component (such as Buffer.readerOffset() and Buffer.writerOffset()) are not modified while the iteration takes place. Otherwise, unpredictable behaviour might result.

        Returns:
        A ByteCursor for iterating the readable bytes of this buffer.
        See Also:
        Buffer.openCursor()
      • skipReadableBytes

        ReadableComponent skipReadableBytes​(int byteCount)
        Move the read-offset to indicate that the given number of bytes were read from this component.
        Parameters:
        byteCount - The number of bytes read from this component.
        Returns:
        itself.
        See Also:
        Buffer.skipReadableBytes(int)