Interface ByteSequence
- All Known Implementing Classes:
ByteArrayBuffer, EmptyByteSequence, RecycledByteArrayBuffer
public interface ByteSequence
An immutable sequence of bytes.
-
Field Summary
Fields -
Method Summary
-
Field Details
-
EMPTY
An empty byte sequence.
-
-
Method Details
-
length
int length()Returns the length of this byte sequence.- Returns:
- the number of
bytes in this sequence.
-
byteAt
byte byteAt(int index) Returns thebytevalue at the specified index.- Parameters:
index- the index of thebytevalue to be returned.- Returns:
- the corresponding
bytevalue - Throws:
IndexOutOfBoundsException- ifindex < 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.
-