Package de.cardcontact.tlv
Class ConstructedTLV
- java.lang.Object
-
- de.cardcontact.tlv.TLV
-
- de.cardcontact.tlv.ConstructedTLV
-
- All Implemented Interfaces:
TreeNode
- Direct Known Subclasses:
AuthenticatedRequest,CertificateBody,CertificateHolderAuthorizationTemplate,ChipAuthenticationCommandData,ChipAuthenticationResponseData,CVCertificate,Extension,Extensions,PublicKeyTLV,Sequence
public class ConstructedTLV extends TLV
Base class for all constructed TLV objects- Author:
- Andreas Schwier (info@cardcontact.de)
-
-
Constructor Summary
Constructors Constructor Description ConstructedTLV(byte[] buffer)Create constructed TLV object from byte arrayConstructedTLV(int tagValue)Create empty constructed tlv object and given Tag valueConstructedTLV(ParseBuffer pb)Create a constructed tlv object from binary data in ParseBufferConstructedTLV(Tag newtag)Create empty constructed tlv object with given Tag objectConstructedTLV(TLV tlv)Copy constructor Initialize with existing ConstructedTLV object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConstructedTLVadd(int index, TLV tlv)Add tlv object to constructed TLV at indexConstructedTLVadd(TLV tlv)Add tlv object to constructed TLVjava.lang.Stringdump(int indent)Return dump of constructed TLV object using a given left indentationTLVfindTag(Tag tag, TLV cursor)Find matching tag in constructed TLVTLVget(int index)Return tlv object at indexTreeNodegetChildAt(int index)Get Child at index positionintgetChildCount()Return number of childs, of object is constructedintgetElements()Return number of child elementsintgetIndex(TreeNode child)Get index position for childintgetLength()Determine length of value fieldTreeNodegetParent()Get parent if it is knownbooleanisLeaf()Return truevoidremove(int index)>Remove tlv element at indexprotected inttoByteArray(byte[] buffer, int offset)Store constructed object to binary bufferprotected intvalueToByteArray(byte[] buffer, int offset)Store value from constructed object to binary buffer-
Methods inherited from class de.cardcontact.tlv.TLV
dump, dumpSingleLine, factory, factory, factory, getBytes, getLengthFieldAsByteArray, getLengthFieldSize, getLengthFieldSizeHelper, getName, getSize, getTag, getValue, lengthFromByteArray, lengthToByteArray, setName, setTag, toString, useAlternateLengthEncoding
-
-
-
-
Field Detail
-
childs
protected java.util.ArrayList<TLV> childs
-
-
Constructor Detail
-
ConstructedTLV
public ConstructedTLV(Tag newtag)
Create empty constructed tlv object with given Tag object- Parameters:
newtag- Tag for constructed TLV object
-
ConstructedTLV
public ConstructedTLV(int tagValue) throws TLVEncodingExceptionCreate empty constructed tlv object and given Tag value- Parameters:
tagValue- Tag value for constructed TLV object- Throws:
TLVEncodingException
-
ConstructedTLV
public ConstructedTLV(ParseBuffer pb) throws TLVEncodingException
Create a constructed tlv object from binary data in ParseBuffer- Parameters:
pb- Byte array containing TLV structure- Throws:
TLVEncodingException
-
ConstructedTLV
public ConstructedTLV(byte[] buffer) throws TLVEncodingExceptionCreate constructed TLV object from byte array- Parameters:
buffer- Byte array containing data object- Throws:
TLVEncodingException
-
ConstructedTLV
public ConstructedTLV(TLV tlv) throws java.lang.UnsupportedOperationException
Copy constructor Initialize with existing ConstructedTLV object. Does not perform a deep copy. The tag and list of contained objects are reassigned. Caution: If applied to a TLV object embedded in a complex structure remember to update the reference to this object in the parent node.- Parameters:
tlv- ConstructedTLV- Throws:
java.lang.UnsupportedOperationException
-
-
Method Detail
-
valueToByteArray
protected int valueToByteArray(byte[] buffer, int offset)Store value from constructed object to binary buffer- Specified by:
valueToByteArrayin classTLV- Parameters:
buffer- Byte array that received the binary dataoffset- Offset in byte array- Returns:
- New offset behind the stored object
-
toByteArray
protected int toByteArray(byte[] buffer, int offset)Store constructed object to binary buffer- Specified by:
toByteArrayin classTLV- Parameters:
buffer- Byte array that received the binary dataoffset- Offset in byte array- Returns:
- New offset behind the stored object
-
getLength
public int getLength()
Determine length of value field
-
add
public ConstructedTLV add(TLV tlv)
Add tlv object to constructed TLV- Parameters:
tlv- TLV object to be added
-
add
public ConstructedTLV add(int index, TLV tlv)
Add tlv object to constructed TLV at index- Parameters:
index- the zero based index for insertiontlv- the TLV object to be added
-
remove
public void remove(int index)
>Remove tlv element at index- Parameters:
index- the index of the element to be removed
-
get
public TLV get(int index)
Return tlv object at index- Parameters:
index-- Returns:
- tlv object
-
getElements
public int getElements()
Return number of child elements- Returns:
- number of child elements
-
findTag
public TLV findTag(Tag tag, TLV cursor)
Find matching tag in constructed TLV- Parameters:
tag- Tag to searchcursor- null to start at the beginning or result of last search to continue- Returns:
- null if tag not found or TLV object
-
dump
public java.lang.String dump(int indent)
Return dump of constructed TLV object using a given left indentation
-
getChildCount
public int getChildCount()
Return number of childs, of object is constructed- Returns:
- Number of childs
- See Also:
TreeNode.getChildCount()
-
isLeaf
public boolean isLeaf()
Return true- Returns:
- Node is leaf node
- See Also:
TreeNode.isLeaf()
-
getParent
public TreeNode getParent()
Get parent if it is known- Returns:
- Parent or null if root or unknown
- See Also:
TreeNode.getParent()
-
getChildAt
public TreeNode getChildAt(int index)
Get Child at index position- Returns:
- Child node
- See Also:
TreeNode.getChildAt(int)
-
getIndex
public int getIndex(TreeNode child)
Get index position for child- Parameters:
child- to look for- Returns:
- Child index or -1
- See Also:
TreeNode.getIndex(de.cardcontact.tlv.TreeNode)
-
-