Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Formatting and Parsing Examples

Code Block
// The classic use case, formatting OIDs using (last) object name and numeric (index) suffix:
OID testPrivOID = new OID("1.3.6.1.4.1.4976");
assertEquals("enterprises.4976", testPrivOID.toString());

 
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());
 
// If the selected OID format supports round-trip processing like this SmiManager.OIDFormat.ObjectNameAndDecodedIndex4RoundTrip format
// OID.toString() and OID.format() will return the same value. Otherwise, OID.toString() will render the OID in the next less formatting
// OID format that supports parsing: 
assertEquals("vacmAccessContextMatch.\"v3group\".\"\".3.'noAuthNoPriv(1)'", vacmAccessContextMatch.format());
 
// Parsing of textual OIDs is supported out-of-the-box:
assertEquals(vacmAccessContextMatch, new OID("vacmAccessContextMatch.\"v3group\".\"\".3.'noAuthNoPriv(1)'"));