Package org.asnlab.asndt.runtime.type
Class AsnType
java.lang.Object
org.asnlab.asndt.runtime.type.AsnType
- All Implemented Interfaces:
EncodingRules
,org.asnlab.asndt.runtime.type.Constants
public abstract class AsnType
extends Object
implements org.asnlab.asndt.runtime.type.Constants, EncodingRules
Instances of the class
AsnType
represent the metadata
of ASN.1 type. The metadata type is independent of any concrete value
which may be represent by anything. Value object is related to metadata
type by means of AsnConverter
.
The following example uses a AsnType
object
and a AsnConverter
to encode a value object:
object = ... type = ... converter = ... type.encode(object, buffer, converter);
- Since:
- 3.0
- Version:
- 3.14159
- Author:
- Ryan
-
Field Summary
FieldsFields inherited from interface org.asnlab.asndt.runtime.type.Constants
CLASS_APPLICATION, CLASS_CONTEXT, CLASS_MASK, CLASS_PRIVATE, CLASS_UNIVERSAL, FORM_CONSTRUCTED, FORM_MASK, FORM_PRIMITIVE, IndentStep, LEN_EOC, LEN_INDEF, NUMBER_ESCAPE, NUMBER_MASK, TAG_BIT_STRING, TAG_BMP_STRING, TAG_BOOLEAN, TAG_CHARACTER_STRING, TAG_EMBEDDED_PDV, TAG_ENUMERATED, TAG_EOC, TAG_EXTERNAL, TAG_GENERAL_STRING, TAG_GENERALIZED_TIME, TAG_GRAPHIC_STRING, TAG_IA5_STRING, TAG_INTEGER, TAG_NULL, TAG_NUMERIC_STRING, TAG_OBJECT_DESCRIPTOR, TAG_OBJECT_IDENTIFIER, TAG_OCTET_STRING, TAG_PRINTABLE_STRING, TAG_REAL, TAG_RELATIVE_OID, TAG_SEQUENCE, TAG_SEQUENCE_OF, TAG_SET, TAG_SET_OF, TAG_TELETEX_STRING, TAG_UNIVERSAL_STRING, TAG_UTC_TIME, TAG_UTF8_STRING, TAG_VIDEOTEX_STRING, TAG_VISIBLE_STRING, TYPE_ID_BITSTRING, TYPE_ID_BMPSTRING, TYPE_ID_BOOLEAN, TYPE_ID_CHARACTERSTRING, TYPE_ID_CHOICE, TYPE_ID_ENUMERATED, TYPE_ID_EXPLICIT, TYPE_ID_GENERALIZEDTIME, TYPE_ID_GENERALSTRING, TYPE_ID_GRAPHICSTRING, TYPE_ID_IA5STRING, TYPE_ID_IMPLICIT, TYPE_ID_INTEGER, TYPE_ID_NULL, TYPE_ID_NUMERICSTRING, TYPE_ID_OBJECTDESCRIPTOR, TYPE_ID_OBJECTIDENTIFIER, TYPE_ID_OCTETSTRING, TYPE_ID_PRINTABLESTRING, TYPE_ID_REAL, TYPE_ID_REFERENCE, TYPE_ID_RELATIVEOID, TYPE_ID_SEQUENCE, TYPE_ID_SEQUENCEOF, TYPE_ID_SET, TYPE_ID_SETOF, TYPE_ID_TABLE_CONSTRAINT_OPEN, TYPE_ID_TELETEXSTRING, TYPE_ID_TYPE_CONSTRAINT_OPEN, TYPE_ID_UNIVERSALSTRING, TYPE_ID_UTCTIME, TYPE_ID_UTF8STRING, TYPE_ID_VIDEOTEXSTRING, TYPE_ID_VISIBLESTRING, ZERO
Fields inherited from interface org.asnlab.asndt.runtime.conv.EncodingRules
ALIGNED_PACKED_ENCODING_RULES, BASIC_ENCODING_RULES, CANONICAL_ENCODING_RULES, DISTINGUISHED_ENCODING_RULES, OCTET_ENCODING_RULES, UNALIGNED_PACKED_ENCODING_RULES, XML_ENCODING_RULES
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static long
bytes2unsignedlong
(byte[] bytes) clone
(Object object, AsnConverter converter) Clone a copy of the objectReturn the "generic" AsnConverter for this ASN.1 typeprotected abstract AsnConverter
computeConverter
(Hashtable<Object, Object> dejavu) decode
(byte[] content, byte encodingRules, AsnConverter converter) Decode object from byte arraydecode
(byte[] content, AsnConverter converter) Decode object from byte array usingUNALIGNED_PACKED_ENCODING_RULES
decode
(InputStream in, byte encodingRules, AsnConverter converter) Decode the object from input streamdecode
(Buffer buffer, AsnConverter converter) Decode object from buffer.protected abstract Object
decode
(org.asnlab.asndt.runtime.type.Codec codec, AsnConverter converter) static int[]
decodeTag
(int tag) byte[]
encode
(Object object, byte encodingRules, AsnConverter converter) Encode object into byte arrayvoid
encode
(Object object, byte encodingRules, AsnConverter converter, OutputStream out) Encode the object into output streambyte[]
encode
(Object object, AsnConverter converter) Encode object into byte array usingUNALIGNED_PACKED_ENCODING_RULES
void
encode
(Object object, Buffer buffer, AsnConverter converter) Encode the object into buffer.protected abstract void
encode
(Object object, org.asnlab.asndt.runtime.type.Codec codec, AsnConverter converter) static int
encodeTag
(short tagClass, short tagForm, int tagNumber) boolean
equals
(Object o1, Object o2, AsnConverter converter) Tells whether the two objectso1
,o2
is equal from the point of view of ASN.1.boolean
equals
(Object o1, Object o2, AsnConverter c1, AsnConverter c2) Tells whether the two objectso1
,o2
is equal from the point of view of ASN.1.abstract int
getTag
(Object object, AsnConverter converter) abstract int
Return the id of this typegetXmlTag
(AsnConverter converter) protected static byte[]
int2bytes
(int number) json
(Object object, AsnConverter converter, PrintStream out) protected static byte[]
long2bytes
(long number) abstract String
protected static int
numOfBits
(int n) protected static int
numOfBits
(long n) protected static int
numOfBytes
(int number) protected static int
numOfBytes
(long number) protected static int
numOfBytes
(short number) protected static int
numOfOcts
(int n) protected static int
numOfOcts
(long n) static byte[]
parseHexString
(String hex) print
(Object object, AsnConverter converter, PrintStream out) Print out the readable message of this object.print
(Object object, AsnConverter converter, PrintStream out, boolean trimNulls) Print out the readable message of this object.protected AsnType
realType()
protected static byte[]
short2bytes
(short number) static String
toHexString
(byte[] octets) static String
toHexString
(byte[] octets, String separator) toString()
protected static byte[]
unsignedint2bytes
(int number) protected static byte[]
unsignedlong2bytes
(long number) protected static byte[]
unsignint2seplets
(int value)
-
Field Details
-
name
-
CONV
-
-
Constructor Details
-
AsnType
public AsnType()
-
-
Method Details
-
getTypeId
public abstract int getTypeId()Return the id of this type- Returns:
- The type id
-
getXmlTag
-
nativeName
-
toString
-
encode
Encode object into byte array usingUNALIGNED_PACKED_ENCODING_RULES
- Parameters:
object
- The object to encodeconverter
- The ASN.1 object converter- Returns:
- The byte array of encoding result
-
decode
Decode object from byte array usingUNALIGNED_PACKED_ENCODING_RULES
- Parameters:
content
- The encoding content to decodeconverter
- The ASN.1 object converter- Returns:
- The decoding result
-
encode
Encode object into byte array- Parameters:
object
- The object to encodeencodingRules
- The encoding rulesconverter
- The ASN.1 object converter- Returns:
- The byte array of encoding result
-
decode
Decode object from byte array- Parameters:
content
- The encoding content to decodeencodingRules
- The encoding rulesconverter
- The ASN.1 object converter- Returns:
- The decoding result
-
encode
public void encode(Object object, byte encodingRules, AsnConverter converter, OutputStream out) throws IOException Encode the object into output stream- Parameters:
object
- The object to encodeencodingRules
- The encoding rulesconverter
- The converter specific to the objectout
- The output stream to encode into- Throws:
IOException
- If error in writing to output stream
-
decode
Decode the object from input stream- Parameters:
in
- The input stream to decode fromencodingRules
- The encoding rulesconverter
- The converter specific to the object- Returns:
- The decoded object
- Throws:
IOException
- If error in reading from input stream
-
encode
Encode the object into buffer. The buffer will be flipped.- Parameters:
object
- The object to encodebuffer
- The working bufferconverter
- The converter specific to the object
-
decode
Decode object from buffer.- Parameters:
buffer
- The working bufferconverter
- The object specific converter- Returns:
- The decoded object
-
encode
protected abstract void encode(Object object, org.asnlab.asndt.runtime.type.Codec codec, AsnConverter converter) -
decode
-
realType
-
computeConverter
Return the "generic" AsnConverter for this ASN.1 type- Returns:
- the "generic" AsnConverter for this ASN.1 type
-
computeConverter
-
clone
Clone a copy of the object- Parameters:
object
- The object to cloneconverter
- The object specific converter- Returns:
- The cloned object
-
equals
Tells whether the two objectso1
,o2
is equal from the point of view of ASN.1.- Parameters:
o1
- The 1st objecto2
- The 2nd objectconverter
- The metadata converter- Returns:
true
if, and only if, two objects equal to each other.
-
equals
Tells whether the two objectso1
,o2
is equal from the point of view of ASN.1.- Parameters:
o1
- The 1st objecto2
- The 2nd objectc1
- The 1st converterc2
- The 2nd converter- Returns:
true
if, and only if, two objects equal to each other.
-
print
Print out the readable message of this object.- Parameters:
object
- The object to printconverter
- The converter specific to the objectout
- The output print stream- Returns:
- The PrintStream
-
print
Print out the readable message of this object.- Parameters:
object
- The object to printconverter
- The converter specific to the objectout
- The output print streamtrimNulls
- Whether trim nulls in the output- Returns:
- The PrintStream
-
json
-
encodeTag
public static int encodeTag(short tagClass, short tagForm, int tagNumber) -
decodeTag
public static int[] decodeTag(int tag) -
getTag
-
short2bytes
protected static byte[] short2bytes(short number) -
int2bytes
protected static byte[] int2bytes(int number) -
unsignedint2bytes
protected static byte[] unsignedint2bytes(int number) -
long2bytes
protected static byte[] long2bytes(long number) -
unsignedlong2bytes
protected static byte[] unsignedlong2bytes(long number) -
bytes2unsignedlong
protected static long bytes2unsignedlong(byte[] bytes) -
unsignint2seplets
protected static byte[] unsignint2seplets(int value) -
numOfBytes
protected static int numOfBytes(short number) -
numOfBytes
protected static int numOfBytes(int number) -
numOfBytes
protected static int numOfBytes(long number) -
numOfOcts
protected static int numOfOcts(int n) -
numOfOcts
protected static int numOfOcts(long n) -
numOfBits
protected static int numOfBits(int n) -
numOfBits
protected static int numOfBits(long n) -
toHexString
-
toHexString
-
parseHexString
-