public interface ByteSequence
| Modifier and Type | Interface and Description |
|---|---|
static class |
ByteSequence.Of
An immutable implementation of the
ByteSequence. |
| Modifier and Type | Field and Description |
|---|---|
static ByteSequence |
EMPTY
The empty
ByteSequence of length 0. |
| Modifier and Type | Method and Description |
|---|---|
byte |
byteAt(int index)
Returns the byte at the specified offset.
|
static ByteSequence |
copyOf(ByteSequence sequence)
Returns an immutable ByteSequence that is a copy of the specified ByteSequence.
|
boolean |
equals(java.lang.Object obj)
Compares the specified object with this byte sequence for equality.
|
static ByteSequence |
from(java.lang.String text)
Creates a ByteSequence from the specified String using the UTF-8 charset.
|
static ByteSequence |
from(java.lang.String text,
java.nio.charset.Charset charset)
Creates a ByteSequence from the specified String using the specified Charset.
|
int |
hashCode()
Returns a hash code value for this byte sequence.
|
int |
length()
Returns the length of the byte sequence.
|
static ByteSequence |
of(byte[] bytes)
Returns a new ByteSequence instance containing the specified byte array.
|
ByteSequence |
subSequence(int start,
int end)
Returns a new ByteSequence that is a sub-sequence of the current byte sequence.
|
byte[] |
toByteArray()
Returns a byte array representation of this byte sequence.
|
java.lang.String |
toString(java.nio.charset.Charset charset)
Converts the byte sequence to a String using the specified Charset.
|
static final ByteSequence EMPTY
ByteSequence of length 0.byte byteAt(int index)
index - the zero-based byte offset within the sequence of bytes (0 <= index < length())java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= length())int length()
ByteSequence subSequence(int start, int end) throws java.lang.IndexOutOfBoundsException
start index and
extends to the byte value at index end - 1.start - the beginning index, inclusiveend - the ending index, exclusivejava.lang.IndexOutOfBoundsException - if the start or end index is invalidint hashCode()
hashCode in class java.lang.Objectboolean equals(java.lang.Object obj)
true if and only if the specified object is also a byte sequence
and both byte sequences have the same bytes in the same order.equals in class java.lang.Objectobj - the object to be compared for equality with this byte sequencetrue if the specified object is equal to this byte sequence, false otherwisebyte[] toByteArray()
java.lang.String toString(java.nio.charset.Charset charset)
charset - the Charset to be used for the conversionstatic ByteSequence of(byte[] bytes)
bytes - the byte array to be used for the new ByteSequencejava.lang.NullPointerException - if the provided byte array is nullstatic ByteSequence copyOf(ByteSequence sequence)
sequence - the ByteSequence to be copiedjava.lang.NullPointerException - if the provided ByteSequence is nullstatic ByteSequence from(java.lang.String text)
text - the String to be converted to a ByteSequencejava.lang.NullPointerException - if the provided text is nullstatic ByteSequence from(java.lang.String text, java.nio.charset.Charset charset)
text - the String to be converted to a ByteSequencecharset - the Charset to be used for the conversionjava.lang.NullPointerException - if the provided text or charset is nullCopyright © 2023. All Rights Reserved.