/** * <p>toString</p> * * @param value a {@link org.opennms.netmgt.xml.event.Value} object. * @return a {@link java.lang.String} object. */ public static String toString(Value value) { return value.getType() + "(" + value.getEncoding() + "): " + value.getContent(); }
String encoding = pValue.getEncoding();
/** * Converts the value of a parm ('Value') of the instance to a string * * @param pvalue a {@link org.opennms.netmgt.xml.event.Value} object. * @return a {@link java.lang.String} object. */ public static String getValueAsString(Value pvalue) { if (pvalue == null) return null; if (pvalue.getContent() == null) return null; String result = ""; String encoding = pvalue.getEncoding(); if (encoding.equals(EventConstants.XML_ENCODING_TEXT)) { result = pvalue.getContent(); } else if (encoding.equals(EventConstants.XML_ENCODING_BASE64)) { byte[] bytes = Base64.decodeBase64(pvalue.getContent().toCharArray()); result = "0x"+toHexString(bytes); } else if (encoding.equals(EventConstants.XML_ENCODING_MAC_ADDRESS)) { result = pvalue.getContent(); } else { throw new IllegalStateException("Unknown encoding for parm value: " + encoding); } return result.trim(); }
String encoding = pValue.getEncoding();
/** * Converts the value of a parm ('Value') of the instance to a string * * @param pvalue a {@link org.opennms.netmgt.xml.event.Value} object. * @return a {@link java.lang.String} object. */ public static String getValueAsString(Value pvalue) { if (pvalue == null) return null; if (pvalue.getContent() == null) return null; String result = ""; String encoding = pvalue.getEncoding(); if (encoding.equals(EventConstants.XML_ENCODING_TEXT)) { result = pvalue.getContent(); } else if (encoding.equals(EventConstants.XML_ENCODING_BASE64)) { byte[] bytes = Base64.decodeBase64(pvalue.getContent().toCharArray()); result = "0x"+toHexString(bytes); } else if (encoding.equals(EventConstants.XML_ENCODING_MAC_ADDRESS)) { result = pvalue.getContent(); } else { throw new IllegalStateException("Unknown encoding for parm value: " + encoding); } return result.trim(); }
/** * Adds the parameters. * * @param builder the trap builder object * @param trapConfig the trap configuration object * @throws SnmpTrapException the SNMP trap exception */ private void addParameters(SnmpTrapBuilder builder, SnmpTrapConfig trapConfig) throws SnmpTrapException { int i = 0; for (Parm parm : trapConfig.getParameters()) { try { Value value = parm.getValue(); addVarBinding(builder, parm.getParmName(), value.getType(), value.getEncoding(), value.getContent()); } catch (SnmpTrapException e) { throw new SnmpTrapException(e.getMessage() + " in event parm[" + i + "]"); } finally { i++; } } }
addVarBinding(packet, parm.getParmName(), value.getType(), value.getEncoding(), value.getContent()); addVarBinding(packet, parm.getParmName(), value.getType(), value.getEncoding(), value.getContent());
try { Value value = parm.getValue(); addVarBinding(trap, parm.getParmName(), value.getType(), value.getEncoding(), value.getContent()); } catch (SnmpTrapHelperException e) { throw new SnmpTrapHelperException(e.getMessage() + " in event parm[" + i + "]"); addVarBinding(trap, parm.getParmName(), value.getType(), value.getEncoding(), value.getContent());