|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectopencard.opt.util.TLV
public class TLV
This class represents a TLV (Tag Length Value) structure. There are methods for creating trees consisting of TLV objects from ASN.1 BER encoded byte sequences and for creating byte sequences from TLV object trees. All manipulations are done on the tree structure.
Tag
Constructor Summary | |
---|---|
TLV()
Create an empty TLV. |
|
TLV(byte[] binary)
Create a TLV object from an ASN.1 BER encoded byte array. |
|
TLV(byte[] binary,
int[] offset)
Create a TLV object from an ASN.1 BER encoded byte array. |
|
TLV(Tag tag,
byte[] value)
Create a TLV object from the given Tag object and data. |
|
TLV(Tag tag,
int number)
Create a primitive TLV object from a given tag and positive integer. |
|
TLV(Tag tag,
TLV tlv)
Create a constructed TLV object from the given Tag object and TLV object to be contained. |
Method Summary | |
---|---|
TLV |
add(TLV tlv)
Add the given TLV object to this TLV instance (only if constructed). |
TLV |
findTag(Tag tag,
TLV cursor)
Search for a given tag value and return the first TLV found. |
static void |
fromBinary(byte[] binary,
int[] offset,
TLV tlv,
TLV parent)
Read a TLV object from a binary representation. |
static int |
lenBytes(int length)
Return the number of bytes required for coding the passed integer value as described in the ASN.1 Basic Encoding Rules. |
int |
length()
Get the length of this TLV's value field in bytes. |
static byte[] |
lengthToBinary(int length)
BER-code the length of this TLV. |
void |
setValue(byte[] newValue)
Set the value field of this TLV from the byte array. |
Tag |
tag()
Get the tag of this TLV. |
byte[] |
toBinary()
BER-code this TLV. |
byte[] |
toBinaryContent()
BER-code this TLV's value field. |
java.lang.String |
toString()
Convert a TLV to a string. |
java.lang.String |
toString(java.util.Hashtable ht,
int level)
Convert a TLV to a string. |
byte[] |
valueAsByteArray()
Get the value field of this TLV as a byte array. |
int |
valueAsNumber()
Get the value of this TLV as a positive integer number. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TLV()
public TLV(byte[] binary)
binary
- A byte array containing the binary representation of a TLV
structure, encoded conforming to the ASN.1 Basic Encoding
Rules defined in ISO 8825.public TLV(byte[] binary, int[] offset)
binary
- A byte array containing the binary representation of a TLV
structure, encoded conforming to the ASN.1 Basic Encoding
Rules defined in ISO 8825.public TLV(Tag tag, byte[] value)
If the given Tag object has the constructed bit set, the result will be a TLV tree, otherwise it's just a primitive TLV that contains the data given in value field.
tag
- An instance of class Tag representing the tag
field of the TLV to be created.value
- An array of bytes representing the Value field of the TLV
to be created.public TLV(Tag tag, int number)
tag
- An instance of class Tag representing the tag
field of the TLV to be created.number
- An integer representing the Value field of the TLV
to be created.public TLV(Tag tag, TLV tlv)
tag
- An instance of class Tag representing the tag
field of the TLV to be created.tlv
- An instance of class TLV representing the Value
field of the TLV to be created.Method Detail |
---|
public TLV add(TLV tlv)
tlv
- The TLV object to be concatenated to this
TLV instance.public TLV findTag(Tag tag, TLV cursor)
tag
- The Tag object representing the tag to be searched for,
null for any tag.cursor
- A reference to a TLV object where the search should start;
if null, the search is started with the child of this
TLV instance.
public static void fromBinary(byte[] binary, int[] offset, TLV tlv, TLV parent)
binary
- A byte array containing the binary representation of a TLV
structure, encoded conforming to the ASN.1 Basic Encoding
Rules defined in ISO 8825.offset
- An integer value giving the offset, where the binary
representation starts.tlv
- The TLV object to be read from the binary representation.parent
- The TLV object representing the parent of the object to be read.public static int lenBytes(int length)
length
- An integer value.
public int length()
public static byte[] lengthToBinary(int length)
length
- The length to be encoded
public void setValue(byte[] newValue)
newValue
- The byte array for the value field.public Tag tag()
public byte[] toBinary()
public byte[] toBinaryContent()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(java.util.Hashtable ht, int level)
ht
- A Hashtable object mapping Tag objects to
level
- An integer value giving the indention leve to be used.
public byte[] valueAsByteArray()
public int valueAsNumber()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |