Interface ByteSequence

  • All Known Implementing Classes:
    ByteArrayBuffer

    public interface ByteSequence
    An immutable sequence of bytes.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static ByteSequence EMPTY
      An empty byte sequence.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      byte byteAt​(int index)
      Returns the byte value at the specified index.
      int length()
      Returns the length of this byte sequence.
      byte[] toByteArray()
      Copies the contents of this byte sequence into a newly allocated byte array and returns that array.
    • Field Detail

      • EMPTY

        static final ByteSequence EMPTY
        An empty byte sequence.
    • Method Detail

      • length

        int length()
        Returns the length of this byte sequence.
        Returns:
        the number of bytes in this sequence.
      • byteAt

        byte byteAt​(int index)
        Returns the byte value at the specified index.
        Parameters:
        index - the index of the byte value to be returned.
        Returns:
        the corresponding byte value
        Throws:
        IndexOutOfBoundsException - if index < 0 || index >= length().
      • toByteArray

        byte[] toByteArray()
        Copies the contents of this byte sequence into a newly allocated byte array and returns that array.
        Returns:
        a byte array holding a copy of this byte sequence.