use of org.opennms.netmgt.xml.eventconf.Varbindsdecode in project opennms by OpenNMS.
the class Mib2Events method getTrapVarbindsDecode.
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());
}
Aggregations