Package com.oss.metadata
Class TypeInfo
java.lang.Object
com.oss.metadata.TypeInfo
- Direct Known Subclasses:
CollectionInfo
,DeferredComponentInfo
,EnumeratedInfo
,IntegerInfo
,OpenTypeInfo
,RealInfo
,TimeInfo
,VectorInfo
The TypeInfo class represents the properties of generic ASN.1 types.
Every ASN.1 type has:
- tags,
- a Java class to represent it,
- an ASN.1 name (module name and typereference),
- flags to mark certain properties of the type such as extensibility etc., and
- constraints imposed on the type values.
The TypeInfo class by itself is used to represent type descriptors of the ASN.1 BOOLEAN, NULL and REAL types. That is only these types do not require additional metadata information.
- Since:
- ASN.1/Java 2.1
-
Method Summary
Modifier and TypeMethodDescriptionReturns an instance of a Java class that implements an ASN.1 type, described by the TypeInfo.createInstance
(Object context) Returns an instance of a Java class that implements an ASN.1 type, described by the TypeInfo.static TypeInfo
Returns the TypeInfo object associated with the subclass of AbstractData with the given string name.static TypeInfo
Returns the TypeInfo object associated with the subclass of AbstractData with the given string name.Returns the name of the ASN.1 module where this type has been defined.Returns the ASN.1 type name for the type.Returns a fully qualified name of the Java class associated with the type.Returns a list of constraints defined for this type.Returns the class object for the Java class associated with the type.getJavaClass
(Object context) Returns the class object for the Java class associated with the type.getName()
Returns the ASN.1 module and type name.getTags()
Returns the tags for the classboolean
Returns true if the type is defined as extensible, and false otherwise.boolean
Indicates if 'null' JSON encoder option is permitted for this type when it occurs as OPTIONAL component nested within a SEQUENCE or SET.boolean
Returns true if the type is a primitive type.boolean
Return true if the type is a simple type.boolean
isSorted()
Return true if SetInfo fields are sorted in canonical order.boolean
Returns true if BER coding can be performed with this type, false otherwise.boolean
Returns true if CER coding can be performed with this type, false otherwise.boolean
Returns true if DER coding can be performed with this type, false otherwise.boolean
Returns true if EXER coding can be performed with this type, false otherwise.boolean
Returns true if JSON coding can be performed with this type, false otherwise.boolean
Returns true if OER coding can be performed with this type, false otherwise.boolean
Returns true if PER coding can be performed with this type, false otherwise.boolean
Returns true if XER coding can be performed with this type, false otherwise.boolean
Return true if UserClass directive was applied to the type.static boolean
Return true if thread context class loader is used to load classes, or false if default class loader is used.static void
setUseThreadContextClassLoader
(boolean flag) The method is used for specifying class loader that will be used to load compiler-generated classes at runtime.
-
Method Details
-
forName
Returns the TypeInfo object associated with the subclass of AbstractData with the given string name.- Parameters:
className
- the fully qualified name of the desired class- Returns:
- TypeInfo
- Throws:
MetadataException
- if attempt to extract the TypeInfo fails: class could not be found or TypeInfo was not available.
-
forName
Returns the TypeInfo object associated with the subclass of AbstractData with the given string name.- Parameters:
className
- the fully qualified name of the desired classcontext
- project environment- Returns:
- TypeInfo
- Throws:
MetadataException
- if attempt to extract the TypeInfo fails: class could not be found or TypeInfo was not available.
-
getTags
Returns the tags for the class- Returns:
- the tags for the class
-
getClassName
Returns a fully qualified name of the Java class associated with the type.- Returns:
- a fully qualified name of the Java class associated with the type.
-
getJavaClass
Returns the class object for the Java class associated with the type.- Returns:
- the class object for the Java class associated with the type.
- Throws:
ClassNotFoundException
- if it could not find definition of the class
-
getJavaClass
Returns the class object for the Java class associated with the type.- Parameters:
context
- project environment- Returns:
- the class object for the Java class associated with the type.
- Throws:
ClassNotFoundException
- if it could not find definition of the class
-
getName
Returns the ASN.1 module and type name. If the name is not found then the literal string:"Module.Type"
is used.- Returns:
- the ASN.1 name for the type in the form
Modulename.Typename
.
-
getASN1TypeName
Returns the ASN.1 type name for the type. The module name is not included. Use getName() if you want to include the module name.- Returns:
- the ASN.1 name for the type (not including the module name).
-
getASN1ModuleName
Returns the name of the ASN.1 module where this type has been defined.- Returns:
- the name of the ASN.1 module where this type has been defined.
-
isExtensible
public boolean isExtensible()Returns true if the type is defined as extensible, and false otherwise.- Returns:
- true if the type is defined as extensible in the ASN.1 spec.
-
isPrimitive
public boolean isPrimitive()Returns true if the type is a primitive type.- Returns:
- true if the type is primitive (i.e if it is encoded using definite length form in BER).
-
isUseableByPER
public boolean isUseableByPER()Returns true if PER coding can be performed with this type, false otherwise.- Returns:
- true if the type descriptor has enough information to perform PER coding
-
isUseableByBER
public boolean isUseableByBER()Returns true if BER coding can be performed with this type, false otherwise.- Returns:
- true if the type descriptor has enough information to perform BER coding
-
isUseableByXER
public boolean isUseableByXER()Returns true if XER coding can be performed with this type, false otherwise.- Returns:
- true if the type descriptor has enough information to perform XER coding
-
isUseableByEXER
public boolean isUseableByEXER()Returns true if EXER coding can be performed with this type, false otherwise.- Returns:
- true if the type descriptor has enough information to perform EXER coding
-
isUseableByDER
public boolean isUseableByDER()Returns true if DER coding can be performed with this type, false otherwise.- Returns:
- true if the type descriptor has enough information to perform DER coding
-
isUseableByCER
public boolean isUseableByCER()Returns true if CER coding can be performed with this type, false otherwise.- Returns:
- true if the type descriptor has enough information to perform CER coding
-
isUseableByOER
public boolean isUseableByOER()Returns true if OER coding can be performed with this type, false otherwise.- Returns:
- true if the type descriptor has enough information to perform OER coding
-
isUseableByJSON
public boolean isUseableByJSON()Returns true if JSON coding can be performed with this type, false otherwise.- Returns:
- true if the type descriptor has enough information to perform JSON coding
-
isNullable
public boolean isNullable()Indicates if 'null' JSON encoder option is permitted for this type when it occurs as OPTIONAL component nested within a SEQUENCE or SET. The 'null' encoder option permits the JSON encoder to include an additional member in the encoding of a SEQUENCE or a SET for each optional component whose type is neither the null type nor an open type and which is absent in the sequence value. The Unicode character string denoted by the name of the member shall be the identifier of the component and the value of the member shall be the JSON token null.- Returns:
- true if the 'null' encoder option is permitted.
-
isSorted
public boolean isSorted()Return true if SetInfo fields are sorted in canonical order.- Returns:
- true if SET fields in metadata are sorted in canonical tag order.
-
isUserClass
public boolean isUserClass()Return true if UserClass directive was applied to the type.- Returns:
- true if UserClass directive was applied to the type.
-
isSimpleType
public boolean isSimpleType()Return true if the type is a simple type. The type is simple if it is not a set, sequence, set-of, sequence-of, choice, embedded-pdv, external or unrestricted character string type.- Returns:
- true if the type is a simple type.
-
getConstraints
Returns a list of constraints defined for this type.- Returns:
- list of imposed constraints.
-
createInstance
public AbstractData createInstance() throws ClassNotFoundException, InstantiationException, IllegalAccessExceptionReturns an instance of a Java class that implements an ASN.1 type, described by the TypeInfo.- Returns:
- an instance of Java class that implements an ASN.1 type, described by the TypeInfo.
- Throws:
ClassNotFoundException
- if it could not find definition of the classInstantiationException
- if an application tries to instantiate an abstract class or an interface, or if the instantiation fails for some other reasonIllegalAccessException
- if the class or initializer is not accessible
-
createInstance
public AbstractData createInstance(Object context) throws ClassNotFoundException, InstantiationException, IllegalAccessException Returns an instance of a Java class that implements an ASN.1 type, described by the TypeInfo.- Parameters:
context
- project environment- Returns:
- an instance of Java class that implements an ASN.1 type, described by the TypeInfo.
- Throws:
ClassNotFoundException
- if it could not find definition of the classInstantiationException
- if an application tries to instantiate an abstract class or an interface, or if the instantiation fails for some other reasonIllegalAccessException
- if the class or initializer is not accessible
-
isUseThreadContextClassLoader
public static boolean isUseThreadContextClassLoader()Return true if thread context class loader is used to load classes, or false if default class loader is used.- Returns:
- true if thread context class loader is used.
-
setUseThreadContextClassLoader
public static void setUseThreadContextClassLoader(boolean flag) The method is used for specifying class loader that will be used to load compiler-generated classes at runtime. By default the class loader that was used to load current typeinfo class is used. That is also specified by passing 'false' flag parameter value to the method call. Passing 'true' flag parameter to the method call specifies that thread context class loader will be used.- Parameters:
flag
- indication of whether to use thread context class loader when loading classes.
-