Module org.snmp4j

Class DictionaryOIDTextFormat

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String format​(int[] value)
      Returns a textual representation of a raw object ID as dotted string ("1.3.6.1.4").
      int[] parse​(java.lang.String text)
      Parses a textual representation of an object ID as dotted string (e.g.
      OID put​(java.lang.String objectNameEqualsDottedNumberString)
      Put an object name to oid mapping into the internal dictionary used for the OID/text formatting that is parsed from a string of the form 'sysDescr = 1.3.6.1.2.1.1.1' or 'sysDescr=1.3.6.1.2.1.1.1'.
      OID put​(java.lang.String objectName, java.lang.String dottedNumbersOidString)
      Put an object name to oid mapping into the internal dictionary used for the OID/text formatting.
      int size()
      Return the size of the dictionary.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DictionaryOIDTextFormat

        public DictionaryOIDTextFormat()
        Creates an empty DictionaryOIDTextFormat that acts like its superclass SimpleOIDTextFormat unless dictionary entries are added with put(String) or put(String, String). dictionaryOIOTextFormat.parse("ifAdminStatus") will return new int[] { 1,3,6,1,2,1,2,2,1,7 } if dictionaryOIOTextFormat.put("ifAdminStatus=1.3.6.1.2.1.2.2.1.7") was called before. Otherwise, a ParseException will be thrown. An the other hand, dictionaryOIOTextFormat.format(new int[] { 1,3,6,1,2,1,2,2,1,7,1000 }) will return "ifAdminStatus.1000" in the first case, i.e. with dictionary entry.
      • DictionaryOIDTextFormat

        public DictionaryOIDTextFormat​(java.lang.String... objectNameToDottedNumbers)
        Create a dictionary based OID formatter from a list of object name to OID mappings of the form 'sysDescr=1.3.6.1.2.1.1.1'.
        Parameters:
        objectNameToDottedNumbers - an object name to OID mapping of the form "<oid>=<object-name>
    • Method Detail

      • put

        public OID put​(java.lang.String objectName,
                       java.lang.String dottedNumbersOidString)
        Put an object name to oid mapping into the internal dictionary used for the OID/text formatting.
        Parameters:
        objectName - an SMI object name like 'sysDescr'.
        dottedNumbersOidString - the SMI object identifier registered for the given objectName in dotted number format, e.g. '1.3.6.1.2.1.1.1' for 'sysDescr'.
        Returns:
        the parsed OID or null if the oid string contains characters other than digits and '.'. In that case, the dictionary is not changed.
      • put

        public OID put​(java.lang.String objectNameEqualsDottedNumberString)
        Put an object name to oid mapping into the internal dictionary used for the OID/text formatting that is parsed from a string of the form 'sysDescr = 1.3.6.1.2.1.1.1' or 'sysDescr=1.3.6.1.2.1.1.1'.
        Parameters:
        objectNameEqualsDottedNumberString - a string with an SMI object name, a single equals sign, and after that equals sign a dotted number OID string: e.g. 'sysDescr=1.3.6.1.2.1.1.1'.
        Returns:
        the parsed OID or null if the oid string contains characters other than digits and '.'. In that case, the dictionary is not changed.
      • size

        public int size()
        Return the size of the dictionary.
        Returns:
        the number of entries in the OID formatting dictionary.
      • format

        public java.lang.String format​(int[] value)
        Description copied from class: SimpleOIDTextFormat
        Returns a textual representation of a raw object ID as dotted string ("1.3.6.1.4").
        Specified by:
        format in interface OIDTextFormat
        Overrides:
        format in class SimpleOIDTextFormat
        Parameters:
        value - the OID value to format.
        Returns:
        the textual representation.
      • parse

        public int[] parse​(java.lang.String text)
                    throws java.text.ParseException
        Description copied from class: SimpleOIDTextFormat
        Parses a textual representation of an object ID as dotted string (e.g. "1.3.6.1.2.1.1") and returns its raw value.
        Specified by:
        parse in interface OIDTextFormat
        Overrides:
        parse in class SimpleOIDTextFormat
        Parameters:
        text - a textual representation of an OID.
        Returns:
        the raw OID value.
        Throws:
        java.text.ParseException - if the OID cannot be parsed successfully.