SnmpBindingConfigElement newElement = new SnmpBindingConfigElement();
if (outMatcher.matches()) {
String commandAsString = outMatcher.group(1).toString();
newElement.address = GenericAddress.parse("udp:" + outMatcher.group(2).toString() + "/161");
newElement.community = new OctetString(outMatcher.group(3).toString());
newElement.oid = new OID(outMatcher.group(4).toString());
// Only Integer commands accepted at this time.
newElement.value = new Integer32(Integer.parseInt(outMatcher.group(5).toString()));
Command command = TypeParser.parseCommand(item.getAcceptedCommandTypes(), commandAsString);
if (command == null) {
logger.error("SNMP can't resolve command {} for item {}", commandAsString, item);
} else {
config.put(command, newElement);
}
} else if (inMatcher.matches()) {
newElement.address = GenericAddress.parse("udp:" + inMatcher.group(1).toString() + "/161");
newElement.community = new OctetString(inMatcher.group(2).toString());
newElement.oid = new OID(inMatcher.group(3).toString());
newElement.refreshInterval = Integer.valueOf(inMatcher.group(4)).intValue();
if(inMatcher.groupCount() == 5)
newElement.setTransformationRule(inMatcher.group(5));
config.put(IN_BINDING_KEY, newElement);