Search in sources :

Example 1 with AsnDefinedType

use of org.openmuc.jasn1.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, sanitizeModuleName(module.moduleIdentifier.name).replace('-', '/').toLowerCase());
    this.module = module;
    tagDefault = module.tagDefault;
    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(org.openmuc.jasn1.compiler.model.AsnTaggedType) AsnConstructedType(org.openmuc.jasn1.compiler.model.AsnConstructedType) AsnBitString(org.openmuc.jasn1.compiler.model.AsnBitString) AsnCharacterString(org.openmuc.jasn1.compiler.model.AsnCharacterString) AsnOctetString(org.openmuc.jasn1.compiler.model.AsnOctetString) BerTag(org.openmuc.jasn1.ber.BerTag) AsnTag(org.openmuc.jasn1.compiler.model.AsnTag) File(java.io.File) AsnDefinedType(org.openmuc.jasn1.compiler.model.AsnDefinedType) AsnType(org.openmuc.jasn1.compiler.model.AsnType)

Aggregations

File (java.io.File)1 BerTag (org.openmuc.jasn1.ber.BerTag)1 AsnBitString (org.openmuc.jasn1.compiler.model.AsnBitString)1 AsnCharacterString (org.openmuc.jasn1.compiler.model.AsnCharacterString)1 AsnConstructedType (org.openmuc.jasn1.compiler.model.AsnConstructedType)1 AsnDefinedType (org.openmuc.jasn1.compiler.model.AsnDefinedType)1 AsnOctetString (org.openmuc.jasn1.compiler.model.AsnOctetString)1 AsnTag (org.openmuc.jasn1.compiler.model.AsnTag)1 AsnTaggedType (org.openmuc.jasn1.compiler.model.AsnTaggedType)1 AsnType (org.openmuc.jasn1.compiler.model.AsnType)1