public final class TLV
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.List<TLV> |
children
If this TLV has children: A List of children, null otherwise
|
private static int |
CLASS_APPLICATION |
private static int |
CLASS_CONTEXT |
private static int |
CLASS_MASK |
private static int |
CLASS_PRIVATE |
private static int |
CLASS_UNIVERSAL |
private static int |
CONSTRUCTED_MASK |
private byte[] |
content
If this TLV has no children: The content, null otherwise
|
private boolean |
hasChildren
Distinguish primitive from composed TLV
|
private byte[] |
header
Contains the header bytes
|
private static int |
IDENTIFIER_MASK |
private static int |
LENGTH_MASK |
private int |
lengthlength
Length of the Length part of the header
|
private int |
typelength
Length of the Type part of the header
|
Constructor and Description |
---|
TLV(byte[] data)
Default Constructor.
|
TLV(byte[] data,
int offset)
This constructor returns a TLV-Object representing the TLV-Formatted
message at position
offset in the data
-bytearray. |
Modifier and Type | Method and Description |
---|---|
private void |
addToStringBuilder(java.lang.StringBuilder sb,
int indent) |
private java.lang.String |
bufToString(byte[] buf,
int start,
int len) |
boolean |
equals(java.lang.Object obj)
Equals based on the raw bytes which were used to create this TLV-Object.
|
TLV |
getChildByNumber(int number)
Get a child of the current TLV by the index, ordered by their occurence
in the original bytearray.
|
TLV |
getChildByTag(byte[] header)
Get a specific child of this TLV, identified by its Type.
|
java.util.List<TLV> |
getChildren()
Returns an unmodifiable list containing all children of this TLV
|
byte[] |
getContent()
Returns a copy of the content (Value) of this TLV, if this TLV does not
contain children.
|
private java.lang.String |
getContentDescription(int bytevalue) |
byte[] |
getHeader()
Returns a copy of the header of this TLV
|
int |
getLength()
Returns the length of the byte-representation of this TLV, including
header and value.
|
byte[] |
getRaw()
Returns a bytearray containing the byte representation of this TLV.
|
private int |
getValueLength()
Returns the length of the value of this TLV as reported in the TLV
header.
|
java.lang.String |
toString()
Human-readable representation of this TLV.
|
private static final int CLASS_MASK
private static final int CLASS_UNIVERSAL
private static final int CLASS_APPLICATION
private static final int CLASS_CONTEXT
private static final int CLASS_PRIVATE
private static final int IDENTIFIER_MASK
private static final int LENGTH_MASK
private static final int CONSTRUCTED_MASK
private final byte[] header
private final java.util.List<TLV> children
private final byte[] content
private final boolean hasChildren
private final int typelength
private final int lengthlength
public TLV(byte[] data)
data
- bytearray of TLV-Encoded Datapublic TLV(byte[] data, int offset)
offset
in the data
-bytearray.data
- Bytearray containing the TLV-Coded message.offset
- Start of the TLV-Formatted message in the data-bytearray.java.lang.IllegalArgumentException
- If datapublic int getLength()
private int getValueLength()
public byte[] getContent()
java.lang.IllegalStateException
- If this TLV has childrenpublic byte[] getRaw()
public byte[] getHeader()
public java.util.List<TLV> getChildren()
private void addToStringBuilder(java.lang.StringBuilder sb, int indent)
public java.lang.String toString()
toString
in class java.lang.Object
private java.lang.String getContentDescription(int bytevalue)
public TLV getChildByNumber(int number)
number
- The Index of the child.java.lang.IllegalStateException
- If this method was called on a TLV without children.java.lang.IndexOutOfBoundsException
- If the index of the child is invalid.public TLV getChildByTag(byte[] header)
header
- A bytearray containing the type to search for.null
otherwiseprivate java.lang.String bufToString(byte[] buf, int start, int len)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object