use of org.snmp4j.smi.AssignableFromString in project nifi by apache.
the class SetSNMP method stringToVariable.
/**
* Method to create the variable from the attribute value and the given SMI syntax value
* @param value attribute value
* @param smiSyntax attribute SMI Syntax
* @return variable
*/
private Variable stringToVariable(String value, int smiSyntax) {
Variable var = AbstractVariable.createFromSyntax(smiSyntax);
try {
if (var instanceof AssignableFromString) {
((AssignableFromString) var).setValue(value);
} else if (var instanceof AssignableFromInteger) {
((AssignableFromInteger) var).setValue(Integer.valueOf(value));
} else if (var instanceof AssignableFromLong) {
((AssignableFromLong) var).setValue(Long.valueOf(value));
} else {
this.getLogger().error("Unsupported conversion of [" + value + "] to " + var.getSyntaxString());
var = null;
}
} catch (IllegalArgumentException e) {
this.getLogger().error("Unsupported conversion of [" + value + "] to " + var.getSyntaxString(), e);
var = null;
}
return var;
}
Aggregations