@InterfaceAudience.Private @InterfaceStability.Evolving public class ArrayBackedTag extends Object implements Tag
Tag implementation in which value is backed by an on heap byte array.| Modifier and Type | Field and Description |
|---|---|
private byte[] |
bytes |
private int |
length |
private int |
offset |
private byte |
type |
CUSTOM_TAG_TYPE_RANGE, INFRASTRUCTURE_SIZE, MAX_TAG_LENGTH, TAG_LENGTH_SIZE, TYPE_LENGTH_SIZE| Constructor and Description |
|---|
ArrayBackedTag(byte[] bytes,
int offset)
Creates a Tag from the specified byte array and offset.
|
ArrayBackedTag(byte[] bytes,
int offset,
int length)
Creates a Tag from the specified byte array, starting at offset, and for length
length. |
ArrayBackedTag(byte tagType,
byte[] tag)
Format for a tag :
<length of tag - 2 bytes><type code - 1 byte><tag> tag length is
serialized using 2 bytes only but as this will be unsigned, we can have max tag length of
(Short.MAX_SIZE * 2) +1. |
ArrayBackedTag(byte tagType,
String tag)
The special tag will write the length of each tag and that will be followed by the type and
then the actual tag.
|
| Modifier and Type | Method and Description |
|---|---|
private static int |
getLength(byte[] bytes,
int offset) |
byte |
getType()
Returns the tag type
|
byte[] |
getValueArray()
Returns The byte array backing this Tag.
|
ByteBuffer |
getValueByteBuffer()
Returns The
ByteBuffer containing the value bytes. |
int |
getValueLength()
Returns Length of actual tag bytes within the backed buffer
|
int |
getValueOffset()
Returns Offset of actual tag bytes within the backed buffer
|
boolean |
hasArray()
Return true if the tag is backed by a byte array
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcloneValue, copyValueTo, getValueAsByte, getValueAsLong, getValueAsString, matchingValueprivate final byte type
private final byte[] bytes
private int offset
private int length
public ArrayBackedTag(byte tagType, String tag)
public ArrayBackedTag(byte tagType, byte[] tag)
<length of tag - 2 bytes><type code - 1 byte><tag> tag length is
serialized using 2 bytes only but as this will be unsigned, we can have max tag length of
(Short.MAX_SIZE * 2) +1. It includes 1 byte type length and actual tag bytes length.public ArrayBackedTag(byte[] bytes, int offset)
bytes content
starting at offset is formatted as a Tag blob. The bytes to include the tag type,
tag length and actual tag bytes.offset - offset to start of Tagpublic ArrayBackedTag(byte[] bytes, int offset, int length)
length. Presumes bytes content starting at offset is
formatted as a Tag blob.private static int getLength(byte[] bytes, int offset)
public byte[] getValueArray()
getValueArray in interface Tagpublic int getValueLength()
getValueLength in interface Tagpublic int getValueOffset()
getValueOffset in interface Tagpublic boolean hasArray()
Tagpublic ByteBuffer getValueByteBuffer()
TagByteBuffer containing the value bytes.getValueByteBuffer in interface TagCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.