/** * Gets the trap varbinds decode. * * @param trap the trap object * @return the trap varbinds decode */ protected List<Varbindsdecode> getTrapVarbindsDecode(Notification trap) { Map<String, Varbindsdecode> decode = new LinkedHashMap<String, Varbindsdecode>(); int vbNum = 1; for (SmiVariable var : trap.getObjects()) { String parmName = "parm[#" + vbNum + "]"; SmiPrimitiveType type = var.getType().getPrimitiveType(); if (type.equals(SmiPrimitiveType.ENUM)) { SortedMap<BigInteger, String> map = new TreeMap<BigInteger, String>(); for (SmiNamedNumber v : var.getType().getEnumValues()) { map.put(v.getValue(), v.getId()); } for (Entry<BigInteger, String> entry : map.entrySet()) { if (!decode.containsKey(parmName)) { Varbindsdecode newVarbind = new Varbindsdecode(); newVarbind.setParmid(parmName); decode.put(newVarbind.getParmid(), newVarbind); } Decode d = new Decode(); d.setVarbinddecodedstring(entry.getValue()); d.setVarbindvalue(entry.getKey().toString()); decode.get(parmName).addDecode(d); } } vbNum++; } return new ArrayList<Varbindsdecode>(decode.values()); }
private static List<Varbindsdecode> getTrapVarbindsDecode(MibValueSymbol trapValueSymbol) { Map<String, Varbindsdecode> decode = new LinkedHashMap<String, Varbindsdecode>(); int vbNum = 1; for (MibValue vb : getTrapVars(trapValueSymbol)) { String parmName = "parm[#" + vbNum + "]"; SnmpObjectType snmpObjectType = ((SnmpObjectType) ((ObjectIdentifierValue) vb).getSymbol().getType()); if (snmpObjectType.getSyntax().getClass().equals(IntegerType.class)) { IntegerType integerType = (IntegerType) snmpObjectType.getSyntax(); if (integerType.getAllSymbols().length > 0) { SortedMap<Integer, String> map = new TreeMap<Integer, String>(); for (MibValueSymbol sym : integerType.getAllSymbols()) { map.put(new Integer(sym.getValue().toString()), sym.getName()); } for (Entry<Integer, String> entry : map.entrySet()) { if (!decode.containsKey(parmName)) { Varbindsdecode newVarbind = new Varbindsdecode(); newVarbind.setParmid(parmName); decode.put(newVarbind.getParmid(), newVarbind); } Decode d = new Decode(); d.setVarbinddecodedstring(entry.getValue()); d.setVarbindvalue(entry.getKey().toString()); decode.get(parmName).addDecode(d); } } } vbNum++; } return new ArrayList<Varbindsdecode>(decode.values()); }