public SmiMib process(Object input) throws PhaseException { ASNMib asnMib = (ASNMib) input; SmiMib result = new SmiMib(new SmiJavaCodeNamingStrategy("org.jsmiparser.mib")); // TODO for (ASNModule am : asnMib.getModules()) { SmiModule sm = result.createModule(am.getIdToken()); processModule(result, am, sm); } return result; }
private void processModule(SmiMib mib, ASNModule m, SmiModule sm) { for (ASNAssignment a : m.getAssignments()) { final IdToken idToken = a.getIdToken(); if (a instanceof ASNTypeAssignment) { ASNTypeAssignment typeAssignment = (ASNTypeAssignment) a; ASNType asnType = typeAssignment.getEntityType(); SmiPrimitiveType pt = convertToPrimitiveType(asnType); if (pt != null) { SmiType st = sm.createType(idToken); st.setPrimitiveType(pt); convertType(asnType, st); } else if (asnType instanceof SMITextualConventionMacro) { // System.out.println("TC: " + m.getName() + ": " + idToken); SMITextualConventionMacro atc = (SMITextualConventionMacro) asnType; SmiTextualConvention stc = sm.createTextualConvention(idToken); ASNType at = atc.getSyntax(); // System.out.println(" is " + at.getClass().getName()); convertType(at, stc); if (!atc.getSyntaxNamedBits().isEmpty()) { for (SMINamedBit nb : atc.getSyntaxNamedBits()) { stc.addEnumValue(nb.getName(), BigInteger.valueOf(nb.getNumber())); } } } } else if (a instanceof ASNValueAssignment) { ASNValueAssignment va = (ASNValueAssignment) a; ASNType asnType = va.getEntityType(); if (asnType instanceof SMIObjectTypeMacro) { // System.out.println("ObjectType macro: " + idToken); SMIObjectTypeMacro otm = (SMIObjectTypeMacro) asnType; if (otm.getSyntax().getType() != SMIType.Enum.SEQUENCE && otm.getSyntax().getType() != SMIType.Enum.SEQUENCEOF) { // System.out.println(" is not SEQ(OF)"); if (!otm.getNamedBits().isEmpty()) { SmiType type = sm.createType(SmiUtil.ucFirst(idToken)); // System.out.println("Create attr type " + type.getId()); for (SMINamedBit nb : otm.getNamedBits()) { type.addEnumValue(nb.getName(), BigInteger.valueOf(nb.getNumber())); } } } } } } }