Search in sources :

Example 1 with AsnDefinedType

use of com.beanit.asn1bean.compiler.model.AsnDefinedType in project jasn1 by openmuc.

the class BerClassWriter method translateModule.

public void translateModule(AsnModule module) throws IOException {
    System.out.println("Generating classes for module \"" + module.moduleIdentifier.name + "\"");
    outputDirectory = new File(outputBaseDir, moduleToPackageName(module.moduleIdentifier.name).replace('.', '/'));
    this.module = module;
    tagDefault = module.tagDefault;
    extensibilityImplied = module.extensible;
    for (AsnType typeDefinition : module.typesByName.values()) {
        if (typeDefinition instanceof AsnDefinedType) {
            if (getInformationObjectClass(((AsnDefinedType) typeDefinition).typeName, module) != null) {
                continue;
            }
        }
        String typeName = cleanUpName(typeDefinition.name);
        writeClassHeader(typeName, module);
        if (typeDefinition instanceof AsnTaggedType) {
            AsnTaggedType asnTaggedType = (AsnTaggedType) typeDefinition;
            Tag tag = getTag(asnTaggedType);
            if (asnTaggedType.definedType != null) {
                writeRetaggingTypeClass(typeName, asnTaggedType.definedType.typeName, typeDefinition, tag);
            } else {
                AsnType assignedAsnType = asnTaggedType.typeReference;
                if (assignedAsnType instanceof AsnConstructedType) {
                    writeConstructedTypeClass(typeName, assignedAsnType, tag, false, null);
                } else {
                    writeRetaggingTypeClass(typeName, getBerType(assignedAsnType), typeDefinition, tag);
                }
            }
        } else if (typeDefinition instanceof AsnDefinedType) {
            writeRetaggingTypeClass(typeName, ((AsnDefinedType) typeDefinition).typeName, typeDefinition, null);
        } else if (typeDefinition instanceof AsnConstructedType) {
            writeConstructedTypeClass(typeName, typeDefinition, null, false, null);
        } else {
            writeRetaggingTypeClass(typeName, getBerType(typeDefinition), typeDefinition, null);
        }
        out.close();
    }
    writeOidValues(module);
}
Also used : AsnTaggedType(com.beanit.asn1bean.compiler.model.AsnTaggedType) AsnConstructedType(com.beanit.asn1bean.compiler.model.AsnConstructedType) AsnCharacterString(com.beanit.asn1bean.compiler.model.AsnCharacterString) AsnOctetString(com.beanit.asn1bean.compiler.model.AsnOctetString) HexString(com.beanit.asn1bean.util.HexString) AsnBitString(com.beanit.asn1bean.compiler.model.AsnBitString) BerTag(com.beanit.asn1bean.ber.BerTag) AsnTag(com.beanit.asn1bean.compiler.model.AsnTag) File(java.io.File) AsnDefinedType(com.beanit.asn1bean.compiler.model.AsnDefinedType) AsnType(com.beanit.asn1bean.compiler.model.AsnType)

Aggregations

BerTag (com.beanit.asn1bean.ber.BerTag)1 AsnBitString (com.beanit.asn1bean.compiler.model.AsnBitString)1 AsnCharacterString (com.beanit.asn1bean.compiler.model.AsnCharacterString)1 AsnConstructedType (com.beanit.asn1bean.compiler.model.AsnConstructedType)1 AsnDefinedType (com.beanit.asn1bean.compiler.model.AsnDefinedType)1 AsnOctetString (com.beanit.asn1bean.compiler.model.AsnOctetString)1 AsnTag (com.beanit.asn1bean.compiler.model.AsnTag)1 AsnTaggedType (com.beanit.asn1bean.compiler.model.AsnTaggedType)1 AsnType (com.beanit.asn1bean.compiler.model.AsnType)1 HexString (com.beanit.asn1bean.util.HexString)1 File (java.io.File)1