Interface ByteSequence

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      byte byteAt​(int index)
      Returns the byte at the specified index.
      byte[] getBytes()
      Returns a byte array containing the bytes in this sequence in the same order as this sequence.
      void getBytes​(int srcBegin, int srcEnd, byte[] dst, int dstBegin)
      Returns a byte array containing the bytes in this sequence in the same order as this sequence and within the bounds given.
      int length()
      Returns the length of this byte sequence.
      ByteSequence subSequence​(int start, int end)
      Returns a new byte sequence that is a subsequence of this sequence.
    • Method Detail

      • byteAt

        byte byteAt​(int index)
        Returns the byte at the specified index. An index ranges from zero to length() - 1. The first byte of the sequence is at index zero, the next at index one, and so on, as for array indexing.

        Parameters:
        index - the index of the character to be returned
        Returns:
        the specified byte
        Throws:
        java.lang.IndexOutOfBoundsException - if the index argument is negative or not less than length()
      • length

        int length()
        Returns the length of this byte sequence. The length is the number of bytes in the sequence.

        Returns:
        the number of bytes in this sequence
      • subSequence

        ByteSequence subSequence​(int start,
                                 int end)
        Returns a new byte sequence that is a subsequence of this sequence. The subsequence starts with the byte at the specified index and ends with the byte at index end - 1. The length of the returned sequence is end - start, so if start == end then an empty sequence is returned.

        Parameters:
        start - the start index, inclusive
        end - the end index, exclusive
        Returns:
        the specified subsequence
        Throws:
        java.lang.IndexOutOfBoundsException - if start or end are negative, if end is greater than length(), or if start is greater than end
      • getBytes

        byte[] getBytes()
        Returns a byte array containing the bytes in this sequence in the same order as this sequence. The length of the byte array will be the length of this sequence.

        Returns:
        a byte array consisting of exactly this sequence of bytes
      • getBytes

        void getBytes​(int srcBegin,
                      int srcEnd,
                      byte[] dst,
                      int dstBegin)
        Returns a byte array containing the bytes in this sequence in the same order as this sequence and within the bounds given. The length of the byte array will be equal to srcEnd - srcBegin + 1.

        Parameters:
        srcBegin - the byte to start copying from
        srcEnd - the byte to end copying at
        dst - the destination to copy the bytes to
        dstBegin - the byte in the destination to begin the copying