public class ArrayByteSequence extends ByteSequence implements Serializable
ByteSequence that uses a backing byte array.| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
data |
protected int |
length |
protected int |
offset |
| Constructor and Description |
|---|
ArrayByteSequence(byte[] data)
Creates a new sequence.
|
ArrayByteSequence(byte[] data,
int offset,
int length)
Creates a new sequence from a subsequence of the given byte array.
|
ArrayByteSequence(ByteBuffer buffer)
Creates a new sequence based on a byte buffer.
|
ArrayByteSequence(String s)
Creates a new sequence from the given string.
|
| Modifier and Type | Method and Description |
|---|---|
byte |
byteAt(int i)
Gets a byte within this sequence.
|
byte[] |
getBackingArray()
Gets the backing byte array for this sequence.
|
boolean |
isBackedByArray()
Determines whether this sequence is backed by a byte array.
|
int |
length()
Gets the length of this sequence.
|
int |
offset()
Gets the offset for this sequence.
|
ByteSequence |
subSequence(int start,
int end)
Returns a portion of this sequence.
|
byte[] |
toArray()
Returns a byte array containing the bytes in this sequence.
|
String |
toString() |
compareBytes, compareTo, equals, hashCodepublic ArrayByteSequence(byte[] data)
data - byte datapublic ArrayByteSequence(byte[] data,
int offset,
int length)
data - byte dataoffset - starting offset in byte array (inclusive)length - number of bytes to include in sequenceIllegalArgumentException - if the offset or length are out of bounds for the given byte arraypublic ArrayByteSequence(String s)
s - string to represent as bytespublic ArrayByteSequence(ByteBuffer buffer)
buffer - byte bufferpublic byte byteAt(int i)
ByteSequencebyteAt in class ByteSequencei - index into sequencepublic byte[] getBackingArray()
ByteSequencegetBackingArray in class ByteSequencepublic boolean isBackedByArray()
ByteSequenceisBackedByArray in class ByteSequencepublic int length()
ByteSequencelength in class ByteSequencepublic int offset()
ByteSequenceoffset in class ByteSequencepublic ByteSequence subSequence(int start, int end)
ByteSequencesubSequence in class ByteSequencestart - index of subsequence start (inclusive)end - index of subsequence end (exclusive)public byte[] toArray()
ByteSequencetoArray in class ByteSequenceCopyright © 2011–2019 The Apache Software Foundation. All rights reserved.