How-to configure your own quotation for the ObjectNameAndDecodedIndex4RoundTrip OIDFormat?

Last modified by Frank Fock on 2024/05/25 21:04

The OIDFormat allows to parse and format OIDs with sub-index values as string values (instead of th well-known dotted numeric format 1.3.6) like for example vacmAccessContextMatch."v3group"."".3.'noAuthNoPriv(1)'. With that format variable length sub-index values are enclosed with double quotes and fixed length or implied length sub-index values are enclosed with single quotes.

Warning

If you use the same quotation character for fixed and variable length, you will not be able to parse OIDs properly if the MIB information for the corresponding table is not available/loaded!

Always use a consistent escape character!

The escaping charcater and the escape character used in the quote escape sequences for fixed and variable length sub-indexes must be identical! Otherwise, the format will not work.

Using Single Quotes Only

To use single quotes only, execute the following code, before using OIDs:

smiManager.setOidVariableLengthStringQuote(smiManager.getOidFixedLengthStringQuote());
smiManager.setOidVariableLengthStringQuoteEscapeSequence(smiManager.getOidFixedLengthStringQuoteEscapeSequence());

Switch Quotes

You can easily switch the quoting to single quotes for variable length and double quotes for fixed/implied length sub-index values with:

smiManager.resetOidQuoting();
char varStringQuote = smiManager.getOidVariableLengthStringQuote();
smiManager.setOidVariableLengthStringQuote(smiManager.getOidFixedLengthStringQuote());
String varStringEscape = smiManager.getOidVariableLengthStringQuoteEscapeSequence();
smiManager.setOidVariableLengthStringQuoteEscapeSequence(smiManager.getOidFixedLengthStringQuoteEscapeSequence());
smiManager.setOidFixedLengthStringQuoteEscapeSequence(varStringEscape);
smiManager.setOidFixedLengthStringQuote(varStringQuote);

Resetting Quotes to Default

Using the default quotation is highly recommended to avoid runtime trouble You can reset the quoation to the factory default with:

smiManager.resetOidQuoting();