@InterfaceAudience.Private @InterfaceStability.Evolving public abstract class AbstractByteRange extends Object implements ByteRange
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
bytes
The array containing the bytes in this range.
|
protected int |
hash
Variable for lazy-caching the hashCode of this range.
|
protected int |
length
The number of bytes in the range.
|
protected int |
offset
The index of the first byte in this range.
|
static int |
UNSET_HASH_VALUE |
| Constructor and Description |
|---|
AbstractByteRange() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
clearHashCache() |
int |
compareTo(ByteRange other)
Bitwise comparison of each byte in the array.
|
void |
deepCopySubRangeTo(int innerOffset,
int copyLength,
byte[] destination,
int destinationOffset)
Wrapper for System.arraycopy.
|
void |
deepCopyTo(byte[] destination,
int destinationOffset)
Wrapper for System.arraycopy.
|
byte[] |
deepCopyToNewArray()
Instantiate a new byte[] with exact length, which is at least 24 bytes +
length.
|
byte |
get(int index)
Retrieve the byte at
index. |
ByteRange |
get(int index,
byte[] dst)
Fill
dst with bytes from the range, starting from index. |
ByteRange |
get(int index,
byte[] dst,
int offset,
int length)
Fill
dst with bytes from the range, starting from index. |
byte[] |
getBytes()
The underlying byte[].
|
int |
getInt(int index)
Retrieve the int value at
index |
int |
getLength()
The length of the range.
|
long |
getLong(int index)
Retrieve the long value at
index |
int |
getOffset()
The offset, the index into the underlying byte[] at which this range
begins.
|
short |
getShort(int index)
Retrieve the short value at
index |
long |
getVLong(int index)
Retrieve the long value at
index which is stored as VLong |
static int |
getVLongSize(long val) |
int |
hashCode() |
boolean |
isEmpty() |
static boolean |
isEmpty(ByteRange range) |
protected boolean |
isHashCached() |
abstract ByteRange |
put(int index,
byte val)
Store
val at index. |
abstract ByteRange |
put(int index,
byte[] val)
Store
val at index. |
abstract ByteRange |
put(int index,
byte[] val,
int offset,
int length)
Store
length bytes from val into this range, starting at
index. |
abstract ByteRange |
putInt(int index,
int val)
Store the int value at
index |
abstract ByteRange |
putLong(int index,
long val)
Store the long value at
index |
abstract ByteRange |
putShort(int index,
short val)
Store the short value at
index |
abstract int |
putVLong(int index,
long val)
Store the long value at
index as a VLong |
ByteRange |
set(byte[] bytes)
Reuse this
ByteRange over a new byte[]. |
ByteRange |
set(byte[] bytes,
int offset,
int length)
Reuse this
ByteRange over a new byte[]. |
ByteRange |
set(int capacity)
Reuse this
ByteRange over a new byte[]. |
ByteRange |
setLength(int length)
Update the length of this range.
|
ByteRange |
setOffset(int offset)
Update the beginning of this range.
|
String |
toString() |
abstract ByteRange |
unset()
Nullifies this ByteRange.
|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, waitdeepCopy, shallowCopy, shallowCopySubRangepublic static final int UNSET_HASH_VALUE
protected byte[] bytes
protected int offset
ByteRange.get(0) will
return bytes[offset].protected int length
protected int hash
public byte[] getBytes()
ByteRangepublic abstract ByteRange unset()
ByteRangepublic ByteRange set(int capacity)
ByteRangeByteRange over a new byte[]. offset is set to
0 and length is set to capacity.public ByteRange set(byte[] bytes)
ByteRangeByteRange over a new byte[]. offset is set to
0 and length is set to bytes.length. A null bytes
IS supported, in which case this method will behave equivalently to
ByteRange.unset().public ByteRange set(byte[] bytes, int offset, int length)
ByteRangeByteRange over a new byte[]. A null bytes IS
supported, in which case this method will behave equivalently to
ByteRange.unset(), regardless of the values of offset and
length.public int getOffset()
ByteRangegetOffset in interface ByteRangeByteRange.getBytes()public ByteRange setOffset(int offset)
ByteRangeoffset + length may not be
greater than bytes.length.public int getLength()
ByteRangepublic ByteRange setLength(int length)
ByteRangeoffset + length should not be
greater than bytes.length.public boolean isEmpty()
public static boolean isEmpty(ByteRange range)
range is of zero length, false otherwise.public byte get(int index)
ByteRangeindex.public ByteRange get(int index, byte[] dst)
ByteRangedst with bytes from the range, starting from index.public ByteRange get(int index, byte[] dst, int offset, int length)
ByteRangedst with bytes from the range, starting from index.
length bytes are copied into dst, starting at offset.public short getShort(int index)
ByteRangeindexpublic int getInt(int index)
ByteRangeindexpublic long getLong(int index)
ByteRangeindexpublic long getVLong(int index)
ByteRangeindex which is stored as VLongpublic static int getVLongSize(long val)
public abstract ByteRange put(int index, byte val)
ByteRangeval at index.public abstract ByteRange put(int index, byte[] val)
ByteRangeval at index.public abstract ByteRange put(int index, byte[] val, int offset, int length)
ByteRangelength bytes from val into this range, starting at
index. Bytes from val are copied starting at offset
into the range.public abstract ByteRange putInt(int index, int val)
ByteRangeindexpublic abstract ByteRange putLong(int index, long val)
ByteRangeindexpublic abstract ByteRange putShort(int index, short val)
ByteRangeindexpublic abstract int putVLong(int index,
long val)
ByteRangeindex as a VLongpublic byte[] deepCopyToNewArray()
ByteRangedeepCopyToNewArray in interface ByteRangepublic void deepCopyTo(byte[] destination,
int destinationOffset)
ByteRangedeepCopyTo in interface ByteRangedestination - Copy to this arraydestinationOffset - First index in the destination array.public void deepCopySubRangeTo(int innerOffset,
int copyLength,
byte[] destination,
int destinationOffset)
ByteRangedeepCopySubRangeTo in interface ByteRangeinnerOffset - Start copying from this index in this source
ByteRange. First byte copied is bytes[offset + innerOffset]copyLength - Copy this many bytesdestination - Copy to this arraydestinationOffset - First index in the destination array.protected boolean isHashCached()
protected void clearHashCache()
public int compareTo(ByteRange other)
compareTo in interface Comparable<ByteRange>Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.