public class TLV extends Object
| Modifier and Type | Field and Description |
|---|---|
static byte |
CONSTRUCTED_FLAG
tag flag for the primitive/constructed bit - 0010 0000 - 0x20
|
private int |
expectedLength
The expected length of the TLV's elements, if the current TLV is a
constructed TLV.
|
private int |
id
An identity for the TLV.
|
private int |
length
The current Length being processed
|
static int |
LENGTH_EXTENSION_RESERVED
Value of the reserved extension
|
static int |
LENGTH_LONG_FORM
A mask to get the Length form
|
static int |
LENGTH_SHORT_MASK
A mask to get the long form value
|
private int |
lengthBytesRead
The number of length's bytes currently read
|
private int |
lengthNbBytes
The number of byte to store the Length being processed
|
private static byte[][] |
ONE_BYTE
A speedup for single bytes length
|
private TLV |
parent
Reference the TLV which contains the current TLV, if any.
|
static int |
SHORT_MASK
tag mask for the short tag format - 0001 1111 - 0x1F
|
private byte |
tag
The current Tag being processed
|
static byte |
TYPE_CLASS_MASK
mask to get the type class value
|
static byte |
TYPE_CLASS_UNIVERSAL
value for the universal type class
|
private BerValue |
value
The current Value being processed
|
| Constructor and Description |
|---|
TLV(int id)
Creates a new TLV object.
|
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
getBytes(int length)
Utility function that return a byte array representing the length
|
int |
getExpectedLength()
Get the TLV expected length.
|
int |
getId() |
int |
getLength() |
int |
getLengthBytesRead() |
int |
getLengthNbBytes() |
static int |
getNbBytes(int length)
Utility function that return the number of bytes necessary to store the
length
|
TLV |
getParent() |
int |
getSize()
The TLV size is calculated by adding the Tag's size, the Length's size
and the Value's length, if any.
|
byte |
getTag() |
BerValue |
getValue() |
void |
incLengthBytesRead()
Increment the number of bytes read for this TLV
|
boolean |
isConstructed()
Checks to see if the current tlv's tag is constructed.
|
static boolean |
isConstructed(byte tag)
Checks to see if the tag is constructed.
|
static boolean |
isPrimitive(byte tag)
Checks to see if the tag represented by this Tag is primitive or
constructed.
|
static boolean |
isUniversal(byte tag)
Tells if the tag is Universal or not
|
void |
reset()
Reset the TLV, so it can be reused for the next PDU decoding.
|
void |
setExpectedLength(int expectedLength)
Set the new expected length of the current TLV.
|
void |
setLength(int length)
Set the TLV's length
|
void |
setLengthBytesRead(int lengthBytesRead)
Set the currently read TLV's length bytes.
|
void |
setLengthNbBytes(int lengthNbBytes)
Set the number of bytes we should use to store the TLV's length.
|
void |
setParent(TLV parent) |
void |
setTag(byte tag)
Set a tag value for this TLV.
|
String |
toString()
Get a String representation of the TLV
|
private byte tag
private int length
private int lengthNbBytes
private int lengthBytesRead
private BerValue value
private int id
private TLV parent
private int expectedLength
public static final byte CONSTRUCTED_FLAG
public static final byte TYPE_CLASS_MASK
public static final byte TYPE_CLASS_UNIVERSAL
public static final int SHORT_MASK
public static final int LENGTH_LONG_FORM
public static final int LENGTH_EXTENSION_RESERVED
public static final int LENGTH_SHORT_MASK
private static final byte[][] ONE_BYTE
public static boolean isConstructed(byte tag)
tag - the TLV's tagpublic boolean isConstructed()
public static boolean isPrimitive(byte tag)
tag - the tag to be checkedpublic static boolean isUniversal(byte tag)
tag - the tag to be checkedpublic void reset()
public byte getTag()
public void setTag(byte tag)
tag - the tag field for this TLV.public BerValue getValue()
public int getSize()
public static int getNbBytes(int length)
length - The length to store in a byte arraypublic static byte[] getBytes(int length)
length - The length to store in a byte arraypublic TLV getParent()
public void setParent(TLV parent)
parent - The parent to set.public int getExpectedLength()
public void setExpectedLength(int expectedLength)
expectedLength - The expectedLength to set.public int getLengthNbBytes()
public void setLengthNbBytes(int lengthNbBytes)
lengthNbBytes - The number of bytes necessary to store the TLV's lengthpublic int getLength()
public void setLength(int length)
length - the TLV's lengthpublic int getLengthBytesRead()
public void setLengthBytesRead(int lengthBytesRead)
lengthBytesRead - the currently read TLV's length bytespublic void incLengthBytesRead()
public int getId()
Copyright © 2003–2020 The Apache Software Foundation. All rights reserved.