Interface NativeBuffer<B extends NativeBuffer>

  • All Known Implementing Classes:
    AbstractBuffer, ElementBuffer, PointerBuffer

    public interface NativeBuffer<B extends NativeBuffer>
    Hardware independent container for various kinds of buffers.

    Implementations follow Buffer semantics, e.g.

           0 <= position <= limit <= capacity
     

    Author:
    Sven Gothel, Michael Bien
    • Method Detail

      • elementSize

        int elementSize()
        Returns byte size of one element
      • limit

        int limit()
        Returns this buffer's element limit.
      • limit

        B limit​(int newLim)
        Sets this buffer's element limit.
      • capacity

        int capacity()
        Returns this buffer's element capacity.
      • position

        int position()
        Returns this buffer's element position.
      • position

        B position​(int newPos)
        Sets this buffer's element position.
      • remaining

        int remaining()
        Returns this buffer's remaining element, i.e. limit - position.
      • hasRemaining

        boolean hasRemaining()
        Returns remaining() > 0
      • clear

        B clear()
        Sets the limit to the capacity and the position to zero.
      • flip

        B flip()
        Sets the limit to the current position and the position to zero.
      • rewind

        B rewind()
        Sets the position to zero.
      • hasArray

        boolean hasArray()
        Returns:
        true if this buffer has a primitive backup array, otherwise false
      • arrayOffset

        int arrayOffset()
        Returns:
        the array offset of the optional primitive backup array of the buffer if hasArray() is true, otherwise 0.
      • getBuffer

        Buffer getBuffer()
        Returns the underlying buffer object.
      • isDirect

        boolean isDirect()
        Return true if the underlying buffer is NIO direct, otherwise false.
      • getDirectBufferAddress

        long getDirectBufferAddress()
        Returns the native address of the underlying buffer if isDirect(), otherwise 0.
      • storeDirectAddress

        void storeDirectAddress​(ByteBuffer directDest)
        Store the getDirectBufferAddress() into the given ByteBuffer using relative put.

        The native pointer value is stored either as a 32bit (int) or 64bit (long) wide value, depending of the CPU pointer width.

      • storeDirectAddress

        void storeDirectAddress​(ByteBuffer directDest,
                                int destOffset)
        Store the getDirectBufferAddress() into the given ByteBuffer using absolute put.

        The native pointer value is stored either as a 32bit (int) or 64bit (long) wide value, depending of the CPU pointer width.

      • put

        B put​(B src)
        Relative bulk get method. Copy the source values src[position .. capacity] [ to this buffer and increment the position by capacity-position.