[SNMP4J] Improved table index

Matthias Wiesmann matthias.wiesmann at gmail.com
Tue Jan 31 10:20:53 CET 2006


Hello everybody, Frank,

I have done some modifications to the MOTableIndex, basically I added
a new variant of createIndex that takes an array of variables and
creates a table index out of it.
The method is not static and uses the impliedLength parameter to build
up the index in the correct way. It also does some basic checking that
the variables match the types of the subindexes.

The goal of these changes is that if you declare the table indexes
public and static, the definition can be use both on the agent and the
client side, this way, if the table definition changes, the code does
not need to be changed. I also have changed the field declaration so
that both the array of subindexes and the impliedLength field are
final, this way, instances are invariant and can be safely shared. The
same changes were be done to the class MOTableSubIndex.

One thing that strikes me in the code of this class is that there are
a lot of switches on the syntax of variables. It might make sense to
move the index building functionality directly into the different
subclasses of Variable, maybe with methods like:

void fromIndex(OID index) ;
OID toIndex(boolean implied_length);

On a related note, could it be possible to have the table index and
OID declaration public in the snmp tables of the MIB declaration of
snmp4j-agent? This would make writing client code simpler if the
client code could reference the relevant objects instead of defining
again the same constants.

Best regards

Matthias Wiesmann


More information about the SNMP4J mailing list