Package de.cardcontact.tlv
Class Tag
- java.lang.Object
-
- de.cardcontact.tlv.Tag
-
public class Tag extends java.lang.ObjectClass representing a tag that is part of a TLV structure. This implementation supports invalid encodings which are common in EMV and ICAO specifications. Such tags encode a tag number in the range 0 to 30 in a two byte tag (e.g. 9F02).- Author:
- Andreas Schwier (www.cardcontact.de)
-
-
Field Summary
Fields Modifier and Type Field Description static byteAPPLICATIONstatic intBIT_STRINGstatic intBMPStringstatic intBOOLEANstatic byteCLASSstatic byteCONSTRUCTEDstatic byteCONTEXTstatic intEMBEDDED_PDVstatic intEND_OF_CONTENTSstatic intENUMERATEDstatic intEXTERNAL_TYPEstatic intGeneralizedTimestatic intGeneralStringstatic intIA5Stringstatic intINTEGERstatic intNULLstatic intNumericStringstatic intOBJECT_DESCRIPTORstatic intOBJECT_IDENTIFIERstatic intOCTET_STRINGstatic intPrintableStringstatic bytePRIVATEstatic intREALstatic intRELATIVE_OIDstatic intSEQUENCEstatic intSETstatic intT61Stringstatic byteTAGstatic TagTAG_BIT_STRINGstatic TagTAG_INTEGERstatic TagTAG_NumericStringstatic TagTAG_OBJECT_IDENTIFIERstatic TagTAG_OCTET_STRINGstatic TagTAG_PrintableStringstatic TagTAG_SEQUENCEstatic TagTAG_SETstatic TagTAG_UTF8Stringstatic byteUNIVERSALstatic intUniversalStringstatic intUTCTimestatic intUTF8String
-
Constructor Summary
Constructors Constructor Description Tag(byte[] value)Create tag from binary presentationTag(byte[] value, int offset)Create tag from binary presentationTag(int newTag)Create tag from integer representationTag(int newTag, byte newClass, boolean newConstructed)Create tag from given componentsTag(ParseBuffer pb)Create tag from binary presentation in ParseBuffer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object object)Test if Tags are equalbyte[]getBytes()Get byte array containing binary representation of tagbytegetClazz()Tag class getterintgetNumber()Tag number getterintgetSize()Get size of tag in number of bytesbooleanisConstructed()Test if Tag has constructed flag setinttoByteArray(byte[] buffer, int offset)Fill byte array at given position with binary representation of tag and return new offset.java.lang.StringtoString()Dump tag to string
-
-
-
Field Detail
-
CONSTRUCTED
public static final byte CONSTRUCTED
- See Also:
- Constant Field Values
-
CLASS
public static final byte CLASS
- See Also:
- Constant Field Values
-
TAG
public static final byte TAG
- See Also:
- Constant Field Values
-
UNIVERSAL
public static final byte UNIVERSAL
- See Also:
- Constant Field Values
-
APPLICATION
public static final byte APPLICATION
- See Also:
- Constant Field Values
-
CONTEXT
public static final byte CONTEXT
- See Also:
- Constant Field Values
-
PRIVATE
public static final byte PRIVATE
- See Also:
- Constant Field Values
-
END_OF_CONTENTS
public static final int END_OF_CONTENTS
- See Also:
- Constant Field Values
-
BOOLEAN
public static final int BOOLEAN
- See Also:
- Constant Field Values
-
INTEGER
public static final int INTEGER
- See Also:
- Constant Field Values
-
BIT_STRING
public static final int BIT_STRING
- See Also:
- Constant Field Values
-
OCTET_STRING
public static final int OCTET_STRING
- See Also:
- Constant Field Values
-
NULL
public static final int NULL
- See Also:
- Constant Field Values
-
OBJECT_IDENTIFIER
public static final int OBJECT_IDENTIFIER
- See Also:
- Constant Field Values
-
OBJECT_DESCRIPTOR
public static final int OBJECT_DESCRIPTOR
- See Also:
- Constant Field Values
-
EXTERNAL_TYPE
public static final int EXTERNAL_TYPE
- See Also:
- Constant Field Values
-
REAL
public static final int REAL
- See Also:
- Constant Field Values
-
ENUMERATED
public static final int ENUMERATED
- See Also:
- Constant Field Values
-
EMBEDDED_PDV
public static final int EMBEDDED_PDV
- See Also:
- Constant Field Values
-
UTF8String
public static final int UTF8String
- See Also:
- Constant Field Values
-
RELATIVE_OID
public static final int RELATIVE_OID
- See Also:
- Constant Field Values
-
SEQUENCE
public static final int SEQUENCE
- See Also:
- Constant Field Values
-
SET
public static final int SET
- See Also:
- Constant Field Values
-
NumericString
public static final int NumericString
- See Also:
- Constant Field Values
-
PrintableString
public static final int PrintableString
- See Also:
- Constant Field Values
-
T61String
public static final int T61String
- See Also:
- Constant Field Values
-
IA5String
public static final int IA5String
- See Also:
- Constant Field Values
-
UTCTime
public static final int UTCTime
- See Also:
- Constant Field Values
-
GeneralizedTime
public static final int GeneralizedTime
- See Also:
- Constant Field Values
-
GeneralString
public static final int GeneralString
- See Also:
- Constant Field Values
-
UniversalString
public static final int UniversalString
- See Also:
- Constant Field Values
-
BMPString
public static final int BMPString
- See Also:
- Constant Field Values
-
TAG_INTEGER
public static final Tag TAG_INTEGER
-
TAG_BIT_STRING
public static final Tag TAG_BIT_STRING
-
TAG_OCTET_STRING
public static final Tag TAG_OCTET_STRING
-
TAG_OBJECT_IDENTIFIER
public static final Tag TAG_OBJECT_IDENTIFIER
-
TAG_SEQUENCE
public static final Tag TAG_SEQUENCE
-
TAG_SET
public static final Tag TAG_SET
-
TAG_UTF8String
public static final Tag TAG_UTF8String
-
TAG_PrintableString
public static final Tag TAG_PrintableString
-
TAG_NumericString
public static final Tag TAG_NumericString
-
-
Constructor Detail
-
Tag
public Tag(int newTag, byte newClass, boolean newConstructed)Create tag from given components- Parameters:
newTag- Tag number. Range 0 to 30 are single byte tags, Range 31 to 127 are double byte tags, Range 128 to 16383 are triple byte tagsnewClass- Class of tag. Must be one of Tag.UNIVERSAL, Tag.APPLICATION, Tag.CONTEXT oder Tag.PRIVATEnewConstructed- Boolean flag indicating if TLV object is contructed or primitive
-
Tag
public Tag(ParseBuffer pb) throws TLVEncodingException
Create tag from binary presentation in ParseBuffer- Parameters:
pb- ParseBuffer- Throws:
TLVEncodingException
-
Tag
public Tag(byte[] value, int offset)Create tag from binary presentation- Parameters:
value- Byte array containing binary tagoffset- Offset in byte array to look at
-
Tag
public Tag(byte[] value)
Create tag from binary presentation- Parameters:
value- Byte array containing binary tag
-
Tag
public Tag(int newTag) throws TLVEncodingExceptionCreate tag from integer representation- Parameters:
newTag- Integer tag value (e.g. 0x5F32)- Throws:
TLVEncodingException
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object object)
Test if Tags are equal- Overrides:
equalsin classjava.lang.Object
-
isConstructed
public boolean isConstructed()
Test if Tag has constructed flag set- Returns:
- true if constructed
-
getNumber
public int getNumber()
Tag number getter- Returns:
- tag number
-
getClazz
public byte getClazz()
Tag class getter- Returns:
- class number
-
toByteArray
public int toByteArray(byte[] buffer, int offset)Fill byte array at given position with binary representation of tag and return new offset.- Parameters:
buffer- Byte arrays to receive binary tagoffset- Offset in byte array that receives the bytes- Returns:
- New offset after storing the tag
-
getBytes
public byte[] getBytes()
Get byte array containing binary representation of tag- Returns:
- Binary data for tag
-
getSize
public int getSize()
Get size of tag in number of bytes- Returns:
- Number of bytes
-
toString
public java.lang.String toString()
Dump tag to string- Overrides:
toStringin classjava.lang.Object
-
-