public class MutableByteBufferWrappingBytes extends AbstractBytes implements MutableBytes
| 限定符和类型 | 字段和说明 |
|---|---|
protected ByteBuffer |
byteBuffer |
protected int |
length |
protected int |
offset |
EMPTY| 限定符和类型 | 方法和说明 |
|---|---|
void |
appendTo(ByteBuffer byteBuffer)
Append the bytes of this value to the
ByteBuffer. |
Bytes |
copy()
Return a value equivalent to this one but guaranteed to 1) be deeply immutable
(i.e. the underlying value will be immutable) and 2) to not retain more bytes than
exposed by the value.
|
byte |
get(int i)
Retrieve a byte in this value.
|
int |
getInt(int i)
Retrieve the 4 bytes starting at the provided index in this value as an integer.
|
long |
getLong(int i)
Retrieves the 8 bytes starting at the provided index in this value as a long.
|
MutableBytes |
mutableCopy()
Return a new mutable value initialized with the content of this value.
|
MutableBytes |
mutableSlice(int i,
int length)
Create a mutable slice of the bytes of this value.
|
void |
set(int i,
byte b)
Set a byte in this value.
|
void |
setInt(int i,
int value)
Set the 4 bytes starting at the specified index to the specified integer value.
|
void |
setLong(int i,
long value)
Set the 8 bytes starting at the specified index to the specified long value.
|
int |
size()
Provides the number of bytes this value represents.
|
Bytes |
slice(int i,
int length)
Create a new value representing (a view of) a slice of the bytes of this value.
|
byte[] |
toArray()
Extract the bytes of this value into a byte array.
|
byte[] |
toArrayUnsafe()
Get the bytes represented by this value as byte array.
|
equals, hashCode, toStringclear, create, decrement, fill, increment, of, of, set, wrap, wrap, wrapBuffer, wrapBuffer, wrapByteBuf, wrapByteBuf, wrapByteBuffer, wrapByteBufferand, and, appendHexTo, appendTo, appendTo, bitLength, commonPrefix, commonPrefixLength, compareTo, concatenate, concatenate, copyTo, copyTo, fromBase64String, fromHexString, fromHexString, fromHexStringLenient, fromHexStringLenient, get, getInt, getInt, getLong, getLong, hasLeadingZero, hasLeadingZeroByte, isEmpty, isZero, minimalBytes, mutableCopy, not, not, numberOfLeadingZeroBytes, numberOfLeadingZeros, numberOfTrailingZeroBytes, ofUnsignedInt, ofUnsignedInt, ofUnsignedLong, ofUnsignedLong, ofUnsignedShort, ofUnsignedShort, or, or, random, random, reverse, shiftLeft, shiftLeft, shiftRight, shiftRight, size, slice, slice, toArray, toArray, toArrayUnsafe, toBase64String, toBigInteger, toBigInteger, toEllipsisHexString, toHexString, toInt, toInt, toLong, toLong, toQuantityHexString, toShortHexString, toString, toUnprefixedHexString, toUnsignedBigInteger, toUnsignedBigInteger, trimLeadingZeros, update, wrap, xor, xorprotected final ByteBuffer byteBuffer
protected final int offset
protected final int length
public void setInt(int i,
int value)
MutableBytessetInt 在接口中 MutableBytesi - The index, which must less than or equal to size() - 4.value - The integer value.public void setLong(int i,
long value)
MutableBytessetLong 在接口中 MutableBytesi - The index, which must less than or equal to size() - 8.value - The long value.public void set(int i,
byte b)
MutableBytesset 在接口中 MutableBytesi - The index of the byte to set.b - The value to set that byte to.public MutableBytes mutableSlice(int i, int length)
MutableBytes
Note: the resulting slice is only a view over the original value. Holding a
reference to the returned slice may hold more memory than the slide represents. Use
Bytes.copy() on the returned slice to avoid this.
mutableSlice 在接口中 MutableBytesi - The start index for the slice.length - The length of the resulting value.i
(included) to index i + length (excluded).public Bytes copy()
Bytespublic int size()
Bytespublic int getInt(int i)
Bytesi - The index from which to get the int, which must less than or equal to
size() - 4.i.public long getLong(int i)
Bytesi - The index from which to get the long, which must less than or equal to
size() - 8.i.public byte get(int i)
Bytesi - The index of the byte to fetch within the value (0-indexed).i in this value.public Bytes slice(int i, int length)
Bytes
Please note that the resulting slice is only a view and as such maintains a link to
the underlying full value. So holding a reference to the returned slice may hold
more memory than the slide represents. Use Bytes.copy() on the returned slice if
that is not what you want.
i - The start index for the slice.length - The length of the resulting value.i (included)
to i + length (excluded).public MutableBytes mutableCopy()
Bytespublic void appendTo(ByteBuffer byteBuffer)
BytesByteBuffer.byteBuffer - The ByteBuffer to which to append this value.public byte[] toArray()
Bytespublic byte[] toArrayUnsafe()
Bytes
Contrarily to Bytes.toArray(), this may avoid allocating a new array and
directly return the backing array of this value if said value is array backed and
doing so is possible. As such, modifications to the returned array may or may not
impact this value. As such, this method should be used with care and hence the
"unsafe" moniker.
Copyright © 2021. All rights reserved.