@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() |
byte[] |
getValueArray() |
ByteBuffer |
getValueByteBuffer() |
int |
getValueLength() |
int |
getValueOffset() |
boolean |
hasArray()
Tells whether or not this Tag is backed by a byte array.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
cloneValue, copyValueTo, getValueAsByte, getValueAsLong, getValueAsString, matchingValue
private 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 Tag
public int getValueLength()
getValueLength
in interface Tag
public int getValueOffset()
getValueOffset
in interface Tag
public boolean hasArray()
Tag
public ByteBuffer getValueByteBuffer()
getValueByteBuffer
in interface Tag
ByteBuffer
containing the value bytes.Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.