A SNMP table row index is technically an OID suffix. Thus it is a sequence of numbers between 0 and 2^32-1 separated by dots.
The standard output when using indexOID.toString()
is then based on the initialisation code below:
Sample Initialisation Code
// Sample Index OID definitions public static final OID oidId = new OID(new int[] { 1,3,6,1,4,1,4976,1,1,1,4,4,2,1,1 }); public static final OID oidVersion = new OID(new int[] { 1,3,6,1,4,1,4976,1,1,1,4,4,2,1,2 }); public static final OID oidInstance = new OID(new int[] { 1,3,6,1,4,1,4976,1,1,1,4,4,2,1,3 }); DefaultMOFactory moFactory = new DefaultMOFactory(); MOTableSubIndex[] moTableSubIndices = new MOTableSubIndex[] { moFactory.createSubIndex(oidId, SMIConstants.SYNTAX_OCTET_STRING, 1, 32), moFactory.createSubIndex(oidVersion, SMIConstants.SYNTAX_OCTET_STRING, 11, 12), moFactory.createSubIndex(oidInstance, SMIConstants.SYNTAX_INTEGER, 1, 1) }; MOTableIndex moTableIndex = new MOTableIndex(moTableSubIndices, false); Variable[] testIndex = new Variable[] { new OctetString("TestSignal"), new OctetString("V01.01.01.0"), new Integer32(5) }; OID indexOID = moTableIndex.getIndexOID(testIndex);
Sample Output
System.out.println("> "+indexOID); > 10.84.101.115.116.83.105.103.110.97.108.11.86.48.49.46.48.49.46.48.49.46.48.5 System.out.println("> "+Arrays.toString(moTableIndex.getIndexValues(indexOID))); > [TestSignal, V01.01.01.0, 5]
If you use SNMP4J-SMI-PRO in your agent/application, you can even get more formatting, because then also DISPLAY-HINT information of the MIB can be used to format the index values (for SNMP4J-SMI-PRO initialisation see "How to use the extended features SNMP4J-SMI-PRO provides?"):
OID vacmViewTreeFamilyEntryOID = new OID(new int[]{1, 3, 6, 1, 6, 3, 16, 1, 5, 2, 1}); OID vacmViewTreeFamilyMaskColumnOID = new OID("3"); OID vacmViewTreeFamilyRowIndex= new OID("22.117.110.114.101.115.116.114.105.99.116.101.100.39.46.82.101.97.100.86.105.101.119.3.1.3.6"); OID vacmViewTreeFamilyMaskInstanceOID = vacmViewTreeFamilyEntryOID.append(vacmViewTreeFamilyMaskColumnOID).append(vacmViewTreeFamilyRowIndex); System.out.println("> "+vacmViewTreeFamilyMaskInstanceOID); > vacmViewTreeFamilyMask."unrestricted'.ReadView"."dod"