Interface ByteBank

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default void appendBytes​(byte[] bytes, int length)
      Appends the given bytes to the buffer
      default void appendBytes​(byte[] bytes, int offset, int length)
      Appends the given bytes to the buffer
      default void basicRangeCheck​(long start, long end)
      Ensures that the requested range satisfies basic sanity criteria.
      default void checkReadPos​(long start, long end)
      Check if we can read from the specified range
      default void checkWritePos​(long start, long end)
      Check if we can write to the specified range
      void clear()
      Clears the buffer
      byte getByte​(long pos)  
      default int getBytes​(long startPos, byte[] bytes)  
      int getBytes​(long startPos, byte[] bytes, int offset, int length)  
      long getMaxBufferSize()  
      default boolean isReadOnly()  
      void setByte​(long pos, byte b)
      Sets the byte at the given position
      void setBytes​(long startPos, byte[] bytes, int offset, int length)
      Sets the bytes starting form the given position to the values form the provided array.
      long size()  
      default byte[] toByteArray()
      Copies this entire buffer into a newly allocated byte array.
      default byte[] toByteArray​(long offset, int len)
      Copies part of this buffer into a newly allocated byte array.
    • Method Detail

      • getByte

        byte getByte​(long pos)
        Parameters:
        pos - the position to read from
        Returns:
        the byte at the given position
      • getBytes

        default int getBytes​(long startPos,
                             byte[] bytes)
        Parameters:
        startPos - the position in the buffer to start reading from
        bytes - the byte array to read into
        Returns:
        the number of bytes read
      • getBytes

        int getBytes​(long startPos,
                     byte[] bytes,
                     int offset,
                     int length)
        Parameters:
        startPos - the position in the buffer to start reading from
        bytes - the byte array to read into
        offset - the offset in the bytes array
        length - the number of elements to read into the bytes array
        Returns:
        number of bytes read
      • toByteArray

        default byte[] toByteArray​(long offset,
                                   int len)
        Copies part of this buffer into a newly allocated byte array.
        Parameters:
        offset - the initial position in the buffer
        len - the number of bytes to copy
        Returns:
        The newly allocated byte array containing the data.
      • toByteArray

        default byte[] toByteArray()
        Copies this entire buffer into a newly allocated byte array.
        Returns:
        The newly allocated byte array containing the data.
      • setBytes

        void setBytes​(long startPos,
                      byte[] bytes,
                      int offset,
                      int length)
        Sets the bytes starting form the given position to the values form the provided array.
        Parameters:
        startPos - the position in the buffer to start writing from
        bytes - the byte array to write
        offset - the offset in the bytes array
        length - the number of bytes to read
      • appendBytes

        default void appendBytes​(byte[] bytes,
                                 int length)
        Appends the given bytes to the buffer
        Parameters:
        bytes - the array containing the bytes to append to the buffer
        length - the number of elements to append from the bytes array
      • appendBytes

        default void appendBytes​(byte[] bytes,
                                 int offset,
                                 int length)
        Appends the given bytes to the buffer
        Parameters:
        bytes - the array containing the bytes to append to the buffer
        offset - the offset in the bytes array
        length - the number of elements to append from the bytes array
      • checkReadPos

        default void checkReadPos​(long start,
                                  long end)
        Check if we can read from the specified range
        Parameters:
        start - the start position of the range
        end - the end position of the range
      • checkWritePos

        default void checkWritePos​(long start,
                                   long end)
        Check if we can write to the specified range
        Parameters:
        start - the start position of the range
        end - the end position of the range
        Throws:
        IndexOutOfBoundsException - if
      • basicRangeCheck

        default void basicRangeCheck​(long start,
                                     long end)
        Ensures that the requested range satisfies basic sanity criteria.
        Parameters:
        start - the start of the range
        end - the end of the range
      • clear

        void clear()
        Clears the buffer
      • size

        long size()
        Returns:
        the offset which follows the last byte stored in this ByteBank
      • setByte

        void setByte​(long pos,
                     byte b)
        Sets the byte at the given position
        Parameters:
        pos - the position
        b - the value to set
      • getMaxBufferSize

        long getMaxBufferSize()
        Returns:
        the maximal size of the buffer
      • isReadOnly

        default boolean isReadOnly()
        Returns:
        True iff the buffer is read-only.