[SNMP4J] Swing Table visualisation tool

Matthias Wiesmann matthias.wiesmann at gmail.com
Tue Oct 18 04:18:24 CEST 2005


On 18/10/05, Frank Fock <fock at agentpp.com> wrote:
> Hello Matthias,
>
> I will have look at your tool the next days,

Actually, I realised I did not explain how to use the classes. :-)

Basically, you simply call the
SwingSNMPTableViewer.displayFrame(String title, MOTable table) method.

So for instance in my agent that implements the HOST-RESOURCES-MIB::hrSWRunTable

SwingSNMPTableViewer.displayFrame("Processes",agent.host_resources.process_group.table);

> but I could not
> resist to comment on your suggestion about implementing
> the Number interface. I had the same idea, but had to
> recognize then, that Number is not an interface! It's an
> abstract class. So there is no way to sub-class (implement
> it).

Hell, you are right, sorry for that, I should have checked it before
making the comment.


> I think adding a Variant class that converts from/to SMI
> values from Java native objects is the best way to go,
> what do you think?

I agree.

Actually, if you look at the classes I have sent, class SMIUtil
contains this kind of functionality: there is a toVariable method that
takes a java object and tries to build a Variable instance for a given
syntax. The reverse method toJava takes a variable and tries to
convert it into a canonical java object (Number, ip address or
String).

It would be much nicer to have this kind of functionality in the
classes themselves.

Features that would be nice:

- that all numerical Variable subtypes implement a common interface
with a toNumber() and a fromNumber(Number n) method

- a Class Variable::classForSyntax(int syntax) method ), i.e you give
it a syntax number and it gives you the class type associated. This
method would be very useful when you build other data structures using
java reflections. The functionality is already there, but not cleanly
exposed.

- a common fromString(String s) method that initialises the content of
the variable from a String. The functionality is already there for
OctetString and OID, for Numerical types, this would simply parse the
String as an integer and call fromNumber with the value.

- a common toCanonicalType method, where each Variable instance would
return the most appropriate Java type, basically calling toString for
OctetString and toNumber for Numerical types.

BTW, feel free to reuse any of my code if you feel like it.

Cheers

Matthias


> Best regards,
> Frank
>
> Matthias Wiesmann wrote:
>
> >Hello everybody,
> >
> >In order to help in the development of the agent I'm working on using
> >SNMP4J-agent, I have written some small utility classes to help
> >debugging tables.
> >
> >What this basically means is that you can have the content of an
> >agent's table displayed in a Swing table. The display updates when the
> >table is updated, and you can do simple modifications via the GUI
> >(basically changing values). The code is not very sophisticated, but I
> >hope this can be useful for other persons.
> >
> >An archive with the code can be found here:
> >
> >http://ddsg.jaist.ac.jp/~wiesmann/share/code/SNMP4JSwing.tar.gz
> >
> >Basically, it works by implementing a Swing table model that registers
> >itself with the MOTable object for notifications.
> >
> >If you have comments or questions, please contact me.
> >
> >Matthias Wiesmann
> >
> >P.S One feature I really would wish for snmp4j would be better
> >conversion methods to canonical java types. In particular it would be
> >nice if all numerical subclasses of Variable would implement the
> >Number interface..
> >_______________________________________________
> >SNMP4J mailing list
> >SNMP4J at agentpp.org
> >http://lists.agentpp.org/mailman/listinfo/snmp4j
> >
> >
> >
> >
>
>
> --
> AGENT++
> http://www.agentpp.com
> http://www.mibexplorer.com
> http://www.mibdesigner.com
>
>
>



More information about the SNMP4J mailing list