[SNMP4J] how to update MoTableModel Row (not the first and last :) HELP ME!

Frank Fock fock at agentpp.com
Wed Jan 20 00:16:53 CET 2010


So, in the first case you actually did not add a
row with index "3".
The same seems to be true for the second case.

If you want to set the third column, you need
to use column index 2 (because it is zero based
as usual in Java).


On 19.01.2010 09:53, Jean.Bauwin at sita.aero wrote:
>
> yes, i add more details :
>
> ///////////////////
>
> when i tried this :
>
>
> 566 MOMutableTableRow l_row = (MOMutableTableRow)
> ifTableEvatis.getModel().getRow(new OID("3"));
> 567 l_row.setValue(3, new Integer32(1));
>
> i have this exception :
>
> java.lang.NullPointerException at
> sita.tsupervision.alarm.snmpAgent.setEvatisIstatus(snmpAgent.java:567)
>
> When i use :
>
> MOMutableTableRow l_row = (MOMutableTableRow)
> ifTableEvatis.getModel().firstRow();
> or
> MOMutableTableRow l_row = (MOMutableTableRow)
> ifTableEvatis.getModel().lastRow();
>
> it's ok, but i want to set the value of row 3 and colum 3.
>
> ///////////////////
>
> when i tried this :
>
> Iterator<MOTableRow> it = /_ifTableModule_/_.getModel().iterator()_;
> it.next();
> it.next();
> MOMutableTableRow mot = (MOMutableTableRow) it.next();
> mot.setValue(3, *new* Integer32(1));
>
> i have this exception :
>
> java.lang.ArrayIndexOutOfBoundsException: 3
> at
> org.snmp4j.agent.mo.DefaultMOMutableRow2PC.setValue(DefaultMOMutableRow2PC.java:74)
>
> at sita.tsupervision.alarm.snmpAgent.setEvatisIstatus(snmpAgent.java:561)
>
> My table have 5 rows with 4 colums as :
>
> *private* *static* DefaultMOTable createModuleTable() {
>
> MOTableSubIndex[] subIndexes = *new* MOTableSubIndex[] { *new*
> MOTableSubIndex(
> SMIConstants./SYNTAX_INTEGER/) };
> MOTableIndex indexDef = *new* MOTableIndex(subIndexes, *false*);
> MOColumn[] columns = *new* MOColumn[3];
> *int* c = 0;
> columns[c++] = *new* MOColumn(c,
> SMIConstants./SYNTAX_INTEGER32/,MOAccessImpl./ACCESS_READ_ONLY/);//
> module number
> columns[c++] = *new* MOColumn(c,
> SMIConstants./SYNTAX_OCTET_STRING/,MOAccessImpl./ACCESS_READ_ONLY/);//
> module name
> columns[c++] = *new* MOColumn(c,
> SMIConstants./SYNTAX_INTEGER32/,MOAccessImpl./ACCESS_READ_ONLY/);//
> module status
>
> /ifTableModule/ = *new* DefaultMOTable(*new*
> OID("1.3.6.1.4.1.881.5.3.200.1.2.1"),indexDef, columns);
> /model/ = (MOMutableTableModel) /ifTableModule/.getModel();
> /rowValues2/ = *new* Variable[] { *new* Integer32(1), *new*
> OctetString("EVATIS-M"), *new* Integer32(0) };
> /rowValues3/ = *new* Variable[] { *new* Integer32(2), *new*
> OctetString("EVATIS-B"), *new* Integer32(0) };
> /rowValues4/ = *new* Variable[] { *new* Integer32(3), *new*
> OctetString("EVATIS-I"), *new* Integer32(0) };
> /rowValues5/ = *new* Variable[] { *new* Integer32(4), *new*
> OctetString("CATS-A"), *new* Integer32(0) };
> /rowValues6/ = *new* Variable[] { *new* Integer32(5), *new*
> OctetString("CATS-D"), *new* Integer32(0) };
> /model/.addRow(*new* DefaultMOMutableRow2PC(*new* OID("1"), /rowValues2/));
> /model/.addRow(*new* DefaultMOMutableRow2PC(*new* OID("2"), /rowValues3/));
> /model/.addRow(*new* DefaultMOMutableRow2PC(*new* OID("3"), /rowValues4/));
> /model/.addRow(*new* DefaultMOMutableRow2PC(*new* OID("4"), /rowValues5/));
> /model/.addRow(*new* DefaultMOMutableRow2PC(*new* OID("5"), /rowValues6/));
> /ifTableModule/.setVolatile(*true*);
> *return* /ifTableModule/;
> }
>
> I think this table is correctly implemented, beacause i can walk the
> table with the default values.
> I can set the first row and the last row.
>
> But i dont understand how to update the row 3 ...
> I prefer the first usage with getRow method beacause the iterator is not
> easy to use.
>
> Thank you for your help Franck .
>
> Jean Bauwin
> Aircom Engineer
> +33 (0)1 46 41 10 80
>
>
> *Frank Fock <fock at agentpp.com>*
> Sent by: snmp4j-bounces at agentpp.org
>
> 18/01/2010 20:09
>
> 	
> To
> 	snmp4j at agentpp.org
> cc
> 	
> Subject
> 	Re: [SNMP4J] how to update MoTableModel Row (not the first and last :)
> HELP ME!
>
>
>
>
>
> Hello Jean,
>
> Both ways should work. As you did not share
> which exceptions occur and how your rows
> have been initialized, we cannot help
> further.
>
> Regards,
> Frank
>
> On 18.01.2010 17:05, Jean.Bauwin at sita.aero wrote:
>  > Hello,
>  >
>  > I try to update my DefaultMoTable defines as :
>  >
>  > private static DefaultMOTable createModuleTable() {
>  >
>  > MOTableSubIndex[] subIndexes = new MOTableSubIndex[] { new
>  > MOTableSubIndex(
>  > SMIConstants.SYNTAX_INTEGER) };
>  > MOTableIndex indexDef = new MOTableIndex(subIndexes, false
>  > );
>  > MOColumn[] columns = new MOColumn[3];
>  > int c = 0;
>  >
>  > columns[c++] = new MOColumn(c, SMIConstants.
>  > SYNTAX_INTEGER32,MOAccessImpl.ACCESS_READ_ONLY);// module number
>  > columns[c++] = new MOColumn(c, SMIConstants.
>  > SYNTAX_OCTET_STRING,MOAccessImpl.ACCESS_READ_ONLY);// module name
>  > columns[c++] = new MOColumn(c, SMIConstants.
>  > SYNTAX_INTEGER32,MOAccessImpl.ACCESS_READ_ONLY);// module status
>  >
>  > ifTableModule = new DefaultMOTable(new OID(
>  > "1.3.6.1.4.1.881.5.3.200.1.2.1"),
>  > indexDef, columns);
>  > model = (MOMutableTableModel) ifTableModule.getModel();
>  > rowValues2 = new Variable[] { new Integer32(1), new
>  > OctetString("EVATIS-M"), new Integer32(0) };
>  > rowValues3 = new Variable[] { new Integer32(2), new
>  > OctetString("EVATIS-B"), new Integer32(0) };
>  > rowValues4 = new Variable[] { new Integer32(3), new
>  > OctetString("EVATIS-I"), new Integer32(0) };
>  > rowValues5 = new Variable[] { new Integer32(4), new
>  > OctetString("CATS-A"), new Integer32(0) };
>  > rowValues6 = new Variable[] { new Integer32(5), new
>  > OctetString("CATS-D"), new Integer32(0) };
>  > model.addRow(new DefaultMOMutableRow2PC(new OID("1"),
>  > rowValues2));
>  > model.addRow(new DefaultMOMutableRow2PC(new OID("2"),
>  > rowValues3));
>  > model.addRow(new DefaultMOMutableRow2PC(new OID("3"),
>  > rowValues4));
>  > model.addRow(new DefaultMOMutableRow2PC(new OID("4"),
>  > rowValues5));
>  > model.addRow(new DefaultMOMutableRow2PC(new OID("5"),
>  > rowValues6));
>  > ifTableModule.setVolatile(true);
>  >
>  > return ifTableModule;
>  > }
>  >
>  > It's easy to update the firstand last row ans the culums.
>  >
>  > But i dont understand how to update the row 3 colums 3 for example.
>  >
>  > I have tried this :
>  >
>  > ifTableModule.getModel().iterator().next();
>  > ifTableModule.getModel().iterator().next();
>  > MOMutableTableRow l_row = (MOMutableTableRow) ifTableModule
>  > .getModel().iterator().next();
>  > // row 3 no ?
>  > //colum 2 ??
>  > l_row.setValue(2, new Integer32(1));
>  >
>  >
>  > but i have an error during the execution...
>  >
>  > i have also tried this :
>  >
>  > MOMutableTableRow l_row = (MOMutableTableRow) ifTableEvatis
>  > .getModel().getRow(new OID("3"));
>  > l_row.setValue(3, new Integer32(1));
>  >
>  > exception ...
>  >
>  > What is the easy way to update a particuar row / colum in my
>  > DeafaultMotable(for example row 3 colum 3 of my table?)
>  >
>  > Thank you in advance for you answers !!
>  >
>  > Jean Bauwin
>  > Aircom Engineer
>  > +33 (0)1 46 41 10 80
>  >
>  > This document is strictly confidential and intended only for use by
> the addressee unless otherwise stated. If you are not the intended
> recipient, please notify the sender immediately and delete it from your
> system.
>  >
>  >
>  > _______________________________________________
>  > SNMP4J mailing list
>  > SNMP4J at agentpp.org
>  > http://lists.agentpp.org/mailman/listinfo/snmp4j
>
> --
> AGENT++
> http://www.agentpp.com
> <http://www.agentpp.com/>http://www.snmp4j.com
> <http://www.snmp4j.com/>http://www.mibexplorer.com
> <http://www.mibexplorer.com/>http://www.mibdesigner.com
>
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> <http://www.mibdesigner.com/>http://lists.agentpp.org/mailman/listinfo/snmp4j
>
>
> This document is strictly confidential and intended only for use by the
> addressee unless otherwise stated. If you are not the intended
> recipient, please notify the sender immediately and delete it from your
> system.

-- 
AGENT++
http://www.agentpp.com
http://www.snmp4j.com
http://www.mibexplorer.com
http://www.mibdesigner.com




More information about the SNMP4J mailing list