private static int[] parseDottedString(String oid) { try { return SNMP4JSettings.getOIDTextFormat().parse(oid); } catch (ParseException ex) { throw new RuntimeException("OID '" + oid + "' cannot be parsed", ex); } }
/** * Returns the OID as dotted string (e.g., "1.3.6.1.4.1") regardless of what * {@link OIDTextFormat} instance is set in {@link SNMP4JSettings}. * @return * a dotted string representation of this OID value. * @since 2.2 */ public String toDottedString() { return oidTextFormat.format(value); }
/** * Return a string representation that can be parsed again to this {@link OID} * by {@link #OID(String)}. * @return * a formatted string representation of this OID (e.g. "ifDescr.1") that * can be parsed again as defined by {@link OIDTextFormat#formatForRoundTrip(int[])} * in {@link SNMP4JSettings}. */ public String toString() { return SNMP4JSettings.getOIDTextFormat().formatForRoundTrip(value); }
private static int[] parseDottedString(String oid) { try { return SNMP4JSettings.getOIDTextFormat().parse(oid); } catch (ParseException ex) { throw new RuntimeException("OID '"+oid+"' cannot be parsed", ex); } }
/** * Returns the OID as dotted string (e.g., "1.3.6.1.4.1") regardless of what * {@link OIDTextFormat} instance is set in {@link SNMP4JSettings}. * * @return a dotted string representation of this OID value. * @since 2.2 */ public String toDottedString() { return oidTextFormat.format(value); }
/** * Return a string representation that can be parsed again to this {@link OID} * by {@link #OID(String)}. * * @return a formatted string representation of this OID (e.g. "ifDescr.1") that * can be parsed again as defined by {@link OIDTextFormat#formatForRoundTrip(int[])} * in {@link SNMP4JSettings}. */ public String toString() { return SNMP4JSettings.getOIDTextFormat().formatForRoundTrip(value); }
private static int[] parseDottedString(String oid) { try { return SNMP4JSettings.getOIDTextFormat().parse(oid); } catch (ParseException ex) { throw new RuntimeException("OID '"+oid+"' cannot be parsed", ex); } }
/** * Format the OID as text. This could return to same result as {@link #toString()} * but also fully converted index-to-text values like * {@code snmp4jLogLoggerIndex.org.snmp4j.MessageDispatcherImpl}. * * @return a string representation of this OID as defined by the * {@link OIDTextFormat#format(int[])} in {@link SNMP4JSettings}. * @since 2.2 */ public String format() { return SNMP4JSettings.getOIDTextFormat().format(value); }
private OID parseOID(String oid) { try { return new OID(oidTextFormat.parse(oid)); } catch (ParseException pex) { throw new RuntimeException("OID '"+oid+"' cannot be parsed", pex); } }
/** * Format the OID as text. This could return to same result as {@link #toString()} * but also fully converted index-to-text values like * {@code snmp4jLogLoggerIndex.org.snmp4j.MessageDispatcherImpl}. * @return * a string representation of this OID as defined by the * {@link OIDTextFormat#format(int[])} in {@link SNMP4JSettings}. * @since 2.2 */ public String format() { return SNMP4JSettings.getOIDTextFormat().format(value); }
public VariableBinding parseVariableBinding(String text) throws ParseException { int assignmentPos = text.indexOf(" = "); if (assignmentPos <= 0) { throw new ParseException("Could not locate assignment ' = ' string in '"+ text, 0); } OID oid = new OID(SNMP4JSettings.getOIDTextFormat(). parse(text.substring(0, assignmentPos))); Variable var = parse(oid, text.substring(assignmentPos+3)); return new VariableBinding(oid, var); } }
public String toString() { return SNMP4JSettings.getOIDTextFormat().format(value); }
public VariableBinding parseVariableBinding(String text) throws ParseException { int assignmentPos = text.indexOf(" = "); if (assignmentPos <= 0) { throw new ParseException("Could not locate assignment ' = ' string in '"+ text, 0); } OID oid = new OID(SNMP4JSettings.getOIDTextFormat(). parse(text.substring(0, assignmentPos))); Variable var = parse(oid, text.substring(assignmentPos+3)); return new VariableBinding(oid, var); } }
/** * Returns a textual representation of the supplied variable against the * optionally supplied instance OID. * * @param instanceOID the instance OID <code>variable</code> is associated * with. If <code>null</code> the formatting cannot take any MIB * specification of the variable into account and has to format it based * on its type only. * @param variable * the variable to format. * @param withOID * if <code>true</code> the <code>instanceOID</code> should be included * in the textual representation to form a {@link VariableBinding} * representation. * @return the textual representation. */ public String format(OID instanceOID, Variable variable, boolean withOID) { return (withOID) ? SNMP4JSettings.getOIDTextFormat().format(instanceOID.getValue())+ " = "+variable : variable.toString(); }
public VariableBinding parseVariableBinding(String text) throws ParseException { String[] tokens = text.split(SEPARATOR, 3); if (tokens.length != 3) { throw new ParseException("Invalid format: "+ text, 0); } OID oid = new OID(oidFormat.parse(tokens[0])); String typeName = tokens[1]; String valueString = tokens[2]; if (typeName.equals(TYPE_NAME_4_OCTETSTRING_IN_HEX)) { OctetString os = (OctetString)parse(SMIConstants.SYNTAX_OCTET_STRING, ""); os.setValue(OctetString.fromHexString(valueString).getValue()); return new VariableBinding(oid, os); } else if (typeName.equals(AbstractVariable.getSyntaxString(BER.BITSTRING))) { BitString bs = (BitString)parse(BER.BITSTRING, ""); bs.setValue(BitString.fromHexString(valueString).getValue()); return new VariableBinding(oid, bs); } else { return new VariableBinding( oid, parse(AbstractVariable.getSyntaxFromString(typeName), valueString) ); } }
/** * Returns a textual representation of the supplied variable against the * optionally supplied instance OID. * * @param instanceOID the instance OID <code>variable</code> is associated * with. If <code>null</code> the formatting cannot take any MIB * specification of the variable into account and has to format it based * on its type only. * @param variable * the variable to format. * @param withOID * if <code>true</code> the <code>instanceOID</code> should be included * in the textual representation to form a {@link VariableBinding} * representation. * @return the textual representation. */ public String format(OID instanceOID, Variable variable, boolean withOID) { return (withOID) ? SNMP4JSettings.getOIDTextFormat().format(instanceOID.getValue())+ " = "+variable : variable.toString(); }
/** * Returns a textual representation of the supplied variable against the * optionally supplied instance OID. * * @param instanceOID the instance OID <code>variable</code> is associated * with. If <code>null</code> the formatting cannot take any MIB * specification of the variable into account and has to format it based * on its type only. * @param variable * the variable to format. * @param withOID * if <code>true</code> the <code>instanceOID</code> should be included * in the textual representation to form a {@link VariableBinding} * representation. * @return the textual representation. */ public String format(OID instanceOID, Variable variable, boolean withOID) { return (withOID) ? SNMP4JSettings.getOIDTextFormat().format(instanceOID.getValue())+ " = "+variable : variable.toString(); }
return oidFormat.format(instanceOID.getValue()) + SEPARATOR + typeString + SEPARATOR + valueString;