public interface ByteSequence
bytevalues. This interface provides uniform, read-only access to many different kinds of
This interface does not refine the general contracts of the
hashCode methods. The result of comparing two objects that implement ByteSequence is
therefore, in general, undefined. Each object may be implemented by a different class, and there
is no guarantee that each class will be capable of testing its instances for equality with those
of the other. It is therefore inappropriate to use arbitrary ByteSequence instances as
elements in a set or as keys in a map.
|Modifier and Type||Method and Description|
Returns a stream of
Returns the length of this byte sequence.
bytes in this sequence
byte byteAt(int index)
bytevalue at the specified index. An index ranges from zero to length() - 1. The first
charvalue of the sequence is at index zero, the next at index one, and so on, as for array indexing.
index- the index of the
bytevalue to be returned
IndexOutOfBoundsException- if the index argument is negative or not less than length()
default ByteSequence subSequence(int startIndex, int endIndex)
ByteSequencethat is a subsequence of this sequence. The subsequence starts with the
bytevalue at the specified index and ends with the
bytevalue at index end - 1. The length (in
bytes) of the returned sequence is end - start, so if start == end then an empty sequence is returned.
startIndex- the start index, inclusive
endIndex- the end index, exclusive
IndexOutOfBoundsException- if start or end are negative, if end is greater than length(), or if start is greater than end
default byte toByteArray()
bytecontaining 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. Creates a new byte array with every invocation.
default IntStream bytes()
bytevalues from this sequence.
static ByteSequence create(byte buffer)
ByteSequencefrom an existing
byte. The byte array is not defensively copied, therefore the given bytes must not mutate to ensure the contract of an immutable ByteSequence.