@InterfaceAudience.Private @InterfaceStability.Evolving public abstract class AbstractPositionedByteRange extends AbstractByteRange implements PositionedByteRange
SimpleByteRange
implementation with position
support. position
is considered transient, not fundamental to the
definition of the range, and does not participate in
AbstractByteRange.compareTo(ByteRange)
, AbstractByteRange.hashCode()
, or
Object.equals(Object)
. Position
is retained by copy operations.限定符和类型 | 字段和说明 |
---|---|
protected int |
limit |
protected int |
position
The current index into the range.
|
bytes, hash, length, offset, UNSET_HASH_VALUE
构造器和说明 |
---|
AbstractPositionedByteRange() |
限定符和类型 | 方法和说明 |
---|---|
byte |
get()
Retrieve the next byte from this range.
|
PositionedByteRange |
get(byte[] dst)
Fill
dst with bytes from the range, starting from position . |
PositionedByteRange |
get(byte[] dst,
int offset,
int length)
Fill
dst with bytes from the range, starting from the current
position . |
PositionedByteRange |
get(int index,
byte[] dst)
Fill
dst with bytes from the range, starting from index . |
PositionedByteRange |
get(int index,
byte[] dst,
int offset,
int length)
Fill
dst with bytes from the range, starting from index . |
int |
getInt()
Retrieve the next int value from this range.
|
int |
getLimit()
Return the current limit
|
long |
getLong()
Retrieve the next long value from this range.
|
int |
getPosition()
The current
position marker. |
int |
getRemaining()
The number of bytes remaining between position and the end of the range.
|
short |
getShort()
Retrieve the next short value from this range.
|
long |
getVLong()
Retrieve the next long value, which is stored as VLong, from this range
|
byte |
peek()
Retrieve the next byte from this range without incrementing position.
|
PositionedByteRange |
set(byte[] bytes)
Reuse this
ByteRange over a new byte[]. |
PositionedByteRange |
set(byte[] bytes,
int offset,
int length)
Reuse this
ByteRange over a new byte[]. |
PositionedByteRange |
set(int capacity)
Reuse this
ByteRange over a new byte[]. |
PositionedByteRange |
setLength(int length)
Update the length of this range.
|
PositionedByteRange |
setLimit(int limit)
Limits the byte range upto a specified value.
|
PositionedByteRange |
setOffset(int offset)
Update the beginning of this range.
|
PositionedByteRange |
setPosition(int position)
Update the
position index. |
clearHashCache, compareTo, deepCopySubRangeTo, deepCopyTo, deepCopyToNewArray, get, getBytes, getInt, getLength, getLong, getOffset, getShort, getVLong, getVLongSize, hashCode, isEmpty, isEmpty, isHashCached, toString
deepCopy, put, put, put, put, put, put, putInt, putInt, putLong, putLong, putShort, putShort, putVLong, shallowCopy, shallowCopySubRange, unset
deepCopySubRangeTo, deepCopyTo, deepCopyToNewArray, get, getBytes, getInt, getLength, getLong, getOffset, getShort, getVLong, isEmpty, putVLong
compareTo
protected int position
ByteBuffer
position, it
points to the next value that will be read/written in the array. It
provides the appearance of being 0-indexed, even though its value is
calculated according to offset.
Position is considered transient and does not participate in
Object.equals(Object)
or AbstractByteRange.hashCode()
comparisons.
protected int limit
public PositionedByteRange set(int capacity)
ByteRange
ByteRange
over a new byte[]. offset
is set to
0 and length
is set to capacity
.set
在接口中 ByteRange
set
在接口中 PositionedByteRange
set
在类中 AbstractByteRange
capacity
- the size of a new byte[].public PositionedByteRange set(byte[] bytes)
ByteRange
ByteRange
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()
.set
在接口中 ByteRange
set
在接口中 PositionedByteRange
set
在类中 AbstractByteRange
bytes
- the array to wrap.public PositionedByteRange set(byte[] bytes, int offset, int length)
ByteRange
ByteRange
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
.set
在接口中 ByteRange
set
在接口中 PositionedByteRange
set
在类中 AbstractByteRange
bytes
- The array to wrap.offset
- The offset into bytes
considered the beginning of
this range.length
- The length of this range.public PositionedByteRange setOffset(int offset)
offset + length
may not be
greater than bytes.length
. Resets position
to 0.setOffset
在接口中 ByteRange
setOffset
在接口中 PositionedByteRange
setOffset
在类中 AbstractByteRange
offset
- the new start of this range.public PositionedByteRange setLength(int length)
offset + length
should not be
greater than bytes.length
. If position
is greater than the
new length
, sets position
to length
.setLength
在接口中 ByteRange
setLength
在接口中 PositionedByteRange
setLength
在类中 AbstractByteRange
length
- The new length of this range.public int getPosition()
PositionedByteRange
position
marker. This valuae is 0-indexed, relative to
the beginning of the range.getPosition
在接口中 PositionedByteRange
public PositionedByteRange setPosition(int position)
PositionedByteRange
position
index. May not be greater than length
.setPosition
在接口中 PositionedByteRange
position
- the new position in this range.public int getRemaining()
PositionedByteRange
getRemaining
在接口中 PositionedByteRange
public byte peek()
PositionedByteRange
peek
在接口中 PositionedByteRange
public byte get()
PositionedByteRange
get
在接口中 PositionedByteRange
public PositionedByteRange get(byte[] dst)
PositionedByteRange
dst
with bytes from the range, starting from position
.
This range's position
is incremented by the length of dst
,
the number of bytes copied.get
在接口中 PositionedByteRange
dst
- the destination of the copy.public PositionedByteRange get(byte[] dst, int offset, int length)
PositionedByteRange
dst
with bytes from the range, starting from the current
position
. length
bytes are copied into dst
,
starting at offset
. This range's position
is incremented
by the number of bytes copied.get
在接口中 PositionedByteRange
dst
- the destination of the copy.offset
- the offset into dst
to start the copy.length
- the number of bytes to copy into dst
.public PositionedByteRange get(int index, byte[] dst)
ByteRange
dst
with bytes from the range, starting from index
.get
在接口中 ByteRange
get
在接口中 PositionedByteRange
get
在类中 AbstractByteRange
index
- zero-based index into this range.dst
- the destination of the copy.public PositionedByteRange get(int index, byte[] dst, int offset, int length)
ByteRange
dst
with bytes from the range, starting from index
.
length
bytes are copied into dst
, starting at offset
.get
在接口中 ByteRange
get
在接口中 PositionedByteRange
get
在类中 AbstractByteRange
index
- zero-based index into this range.dst
- the destination of the copy.offset
- the offset into dst
to start the copy.length
- the number of bytes to copy into dst
.public short getShort()
PositionedByteRange
getShort
在接口中 PositionedByteRange
public int getInt()
PositionedByteRange
getInt
在接口中 PositionedByteRange
public long getLong()
PositionedByteRange
getLong
在接口中 PositionedByteRange
public long getVLong()
PositionedByteRange
getVLong
在接口中 PositionedByteRange
public PositionedByteRange setLimit(int limit)
PositionedByteRange
setLimit
在接口中 PositionedByteRange
public int getLimit()
PositionedByteRange
getLimit
在接口中 PositionedByteRange
Copyright © 2007–2022 The Apache Software Foundation. All rights reserved.