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, hashCode
public 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)
ByteSequence
byteAt
in class ByteSequence
i
- index into sequencepublic byte[] getBackingArray()
ByteSequence
getBackingArray
in class ByteSequence
public boolean isBackedByArray()
ByteSequence
isBackedByArray
in class ByteSequence
public int length()
ByteSequence
length
in class ByteSequence
public int offset()
ByteSequence
offset
in class ByteSequence
public ByteSequence subSequence(int start, int end)
ByteSequence
subSequence
in class ByteSequence
start
- index of subsequence start (inclusive)end
- index of subsequence end (exclusive)public byte[] toArray()
ByteSequence
toArray
in class ByteSequence
Copyright © 2011–2019 The Apache Software Foundation. All rights reserved.