Class ByteSequence

    • Constructor Detail

      • ByteSequence

        public ByteSequence()
    • Method Detail

      • byteAt

        public abstract byte byteAt​(int i)
        Gets a byte within this sequence.
        Parameters:
        i - index into sequence
        Returns:
        byte
        Throws:
        IllegalArgumentException - if i is out of range
      • length

        public abstract int length()
        Gets the length of this sequence.
        Returns:
        sequence length
      • subSequence

        public abstract ByteSequence subSequence​(int start,
                                                 int end)
        Returns a portion of this sequence.
        Parameters:
        start - index of subsequence start (inclusive)
        end - index of subsequence end (exclusive)
      • toArray

        public abstract byte[] toArray()
        Returns a byte array containing the bytes in this sequence. This method may copy the sequence data or may return a backing byte array directly.
        Returns:
        byte array
      • isBackedByArray

        public abstract boolean isBackedByArray()
        Determines whether this sequence is backed by a byte array.
        Returns:
        true if sequence is backed by a byte array
      • getBackingArray

        public abstract byte[] getBackingArray()
        Gets the backing byte array for this sequence.
        Returns:
        byte array
      • offset

        public abstract int offset()
        Gets the offset for this sequence. This value represents the starting point for the sequence in the backing array, if there is one.
        Returns:
        offset (inclusive)
      • compareBytes

        public static int compareBytes​(ByteSequence bs1,
                                       ByteSequence bs2)
        Compares the two given byte sequences, byte by byte, returning a negative, zero, or positive result if the first sequence is less than, equal to, or greater than the second. The comparison is performed starting with the first byte of each sequence, and proceeds until a pair of bytes differs, or one sequence runs out of byte (is shorter). A shorter sequence is considered less than a longer one.
        Parameters:
        bs1 - first byte sequence to compare
        bs2 - second byte sequence to compare
        Returns:
        comparison result
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object