Enum Class SmiManager.OIDFormat

java.lang.Object
java.lang.Enum<SmiManager.OIDFormat>
com.snmp4j.smi.SmiManager.OIDFormat
All Implemented Interfaces:
Serializable, Comparable<SmiManager.OIDFormat>, java.lang.constant.Constable
Enclosing class:
SmiManager

public static enum SmiManager.OIDFormat extends Enum<SmiManager.OIDFormat>
The OIDFormat defines the formatting of OID values.
  • Enum Constant Details

    • Numbers

      public static final SmiManager.OIDFormat Numbers
      Formats the OID as dotted number string, e.g. "1.3.6.1.2.1.1.1.0" for the sysDescr object name. This format can be used with round-trip parsing. That is, an OID can be formatted and then parsed again using this format. This means also that OID.toString() and OID.format() return the same formatted value.
    • ObjectNameNumIndex

      public static final SmiManager.OIDFormat ObjectNameNumIndex
      Formats the OID as combination of object (last) name and a numeric index, e.g. sysDescr.0 or snmpNotifyTag.102.105.108.116.101.114.101.100. This format can be used with round-trip parsing. That is, an OID can be formatted and then parsed again using this format. This means also that OID.toString() and OID.format() return the same formatted value.
    • ObjectNameAndDecodedIndex

      public static final SmiManager.OIDFormat ObjectNameAndDecodedIndex
      Formats the OID as combination of object (last) name and a formatted index, e.g. sysDescr.0 or snmpNotifyTag.filtered. This format cannot be used with round-trip parsing. Thus, an OID cannot be formatted and then parsed again using this format. This means also that OID.toString() and OID.format() return different values:
      • OID.toString() will return the same value as with {#ObjectNameNumIndex} (snmpNotifyTag.102.105.108.116.101.114.101.100).
      • OID.format() will instead return the fully formatted value (e.g. snmpNotifyTag.filtered).
      Non-printable characters in the will not be escaped or handled in a special way. The format also does not use string quotes and is thus not suited for parsing OIDs. If you need to parse OIDs, then use ObjectNameAndDecodedIndex4RoundTrip instead.
    • ObjectNameAndDecodedIndex4RoundTrip

      public static final SmiManager.OIDFormat ObjectNameAndDecodedIndex4RoundTrip
      Fully formats the OID as object (last) name of (sub)index values. Each sub-index value is encoded as quoted string if one of the following is true:
      • the sub-index value contains dots ('.')
      • the sub-index' base syntax is OCTET-STRING
      • the sub-index has a variable length syntax
      • the value is an enumerated value (INTEGER {..})
      This format uses double quotes (") to enclose strings with variable length and non-implied length. It uses single quotes (') to enclose other strings and OIDs (with implied or fixed length). Examples:
      • new OID("1.3.6.1.6.3.16.1.5.2.1.4.12.100.101.109.111.82.101.97.100.86.105.101.119.6.1.3.6.1.2.1").toString()
           .equals("vacmViewTreeFamilyType.\"demoReadView\".\"mib-2\"") == true;
      • new OID("vacmViewTreeFamilyMask.\"#x75:6e:00:65:73\".\"dod\"").equals(
           new OID("1.3.6.1.6.3.16.1.5.2.1.3.5.117.110.0.101.115.3.1.3.6")) == true;
      •    OID vacmAccessContextMatch = new OID("1.3.6.1.6.3.16.1.4.1.4.7.118.51.103.114.111.117.112.0.3.1");
           assertEquals("vacmAccessContextMatch.\"v3group\".\"\".3.'noAuthNoPriv(1)'", vacmAccessContextMatch.toString());
           assertEquals("vacmAccessContextMatch.\"v3group\".\"\".3.'noAuthNoPriv(1)'", vacmAccessContextMatch.format());
           assertEquals(vacmAccessContextMatch, new OID("vacmAccessContextMatch.\"v3group\".\"\".3.'noAuthNoPriv(1)'"));
             
      This format can also be used to parse formatted OIDs even if the corresponding MIB information is not available.
      Since:
      1.1
    • NameAndNumber

      public static final SmiManager.OIDFormat NameAndNumber
      According to ITU-T X.680 the object identifier is formatted like the number format but for each number also the corresponding object name is provided and the number is enclosed in braces. If an object name is not known, only the number is provided without braces.
           SmiManager.OIDFormat defaultForm = smiManager.getOidFormat();
           smiManager.setOidFormat(SmiManager.OIDFormat.NameAndNumber);
           OID oid = new OID("1.3.6.1.2.1.47.1.1");
           assertEquals(oid, new OID("iso(1).org(3).dod(6).internet(1).mgmt(2).mib-2(1).entityMIB(47).entityMIBObjects(1).entityPhysical(1)"));
           assertEquals(oid, new OID("iso(1).org(3).dod(6).internet(1).mgmt(2).mib2(1).entityMIB(47).entityMIBObjects(1).entityPhysical(1)"));
           assertEquals("iso(1).org(3).dod(6).internet(1).mgmt(2).mib-2(1).entityMIB(47).entityMIBObjects(1).entityPhysical(1)", oid.toString());
           smiManager.setOidFormat(defaultForm);
       
      Since:
      1.7.1
  • Method Details

    • values

      public static SmiManager.OIDFormat[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static SmiManager.OIDFormat valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null