Interface ArrayView

    • Method Detail

      • array

        byte[] array()
        Gets a reference to the backing array for this ArrayView. This should be used in conjunction with arrayOffset() in order to determine where in the array this ArrayView starts at. NOTE: Care must be taken when using this array. Just like any other array in Java, it is modifiable and changes to it will be reflected in this ArrayView.
        Returns:
        The backing array.
      • arrayOffset

        int arrayOffset()
        Gets a value indicating the offset in the backing array where this ArrayView starts at.
        Returns:
        The offset in the backing array.
      • copyTo

        void copyTo​(byte[] target,
                    int targetOffset,
                    int length)
        Copies a specified number of bytes from this ArrayView into the given target array.
        Parameters:
        target - The target array.
        targetOffset - The offset within the target array to start copying data at.
        length - The number of bytes to copy.
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - If targetOffset or length are invalid.
      • slice

        ArrayView slice​(int offset,
                        int length)
        Creates a new ArrayView that represents a sub-range of this ArrayView instance. The new instance will share the same backing array as this one, so a change to one will be reflected in the other.
        Specified by:
        slice in interface BufferView
        Parameters:
        offset - The starting offset to begin the slice at.
        length - The sliced length.
        Returns:
        A new ArrayView.
      • asByteBuffer

        java.nio.ByteBuffer asByteBuffer()
        Returns a new ByteBuffer that wraps the contents of this ArrayView.
        Returns:
        A ByteBuffer that shares the same backing array as this ArrayView. Any changes made to the ByteBuffer will be reflected in this ArrayView and viceversa.