[snmp] Making AsnObjectId comparable
Birgit Arkesteijn
birgit at westhawk.co.uk
Wed May 7 11:39:34 BST 2008
I added Josh's implementation to AsnObjectId and checked it into cvs.
It's compiled, but not tested.
Thanks, Josh!
Cheers, Birgit
-------- Original Message --------
Subject: RE: [snmp] Making AsnObjectId comparable
Date: Fri, 2 May 2008 13:29:25 -0400
From: Josh Bers <jbers at bbn.com>
Organisation: BBN Technologies
To: 'Birgit Arkesteijn' <Birgit at westhawk.co.uk>
CC: 'Tim Panton' <thp at westhawk.co.uk>
Here is the code for compare:
Assumes that asn objects are all positive numbers, e.g.,
0-9+(\.[0-9]+)*
*public* *int* compareTo (AsnObjectId b) {
*if* (b == *null*)
*throw* *new* NullPointerException("Trying to compare
with null");
*int* aElts = getSize();
*int* bElts = b.getSize();
*if* ((aElts == 0) && (bElts > 0))
*return* -1;
*if* ((bElts == 0) && (aElts > 0))
*return* 1;
*for* (*int* i = 0; (i < aElts) && (i < bElts); i++) {
*if* (getElementAt(i) != b.getElementAt(i))
*return* (getElementAt(i) > b.getElementAt(i)) ? 1
: -1;
}
// equal to the end of one object
*if* (aElts > bElts)
*return* 1;
*else* *if* (bElts > aElts)
*return* -1;
// both objects same
*return* 0;
}
-----Original Message-----
From: snmp-bounces at snmp.westhawk.co.uk
[mailto:snmp-bounces at snmp.westhawk.co.uk] On Behalf Of Josh Bers
Sent: Thursday, May 01, 2008 2:24 PM
To: 'List for discussion of the Westhawk SNMP stack'
Subject: [snmp] Making AsnObjectId comparable
I would vote for making the AsnObjectId comparable to help in situations
where the stack is serving as an agent in order to order OID's correctly
in a MIB. facilitating insertion into standard Java ordered container
classes.
Josh
Josh Bers
Senior Engineer, Mobile Networking Systems
BBN Technologies
web: www.bbn.com ph: (617) 873-4262 fax: (617) 873-4523
_______________________________________________
snmp mailing list
snmp at snmp.westhawk.co.uk
http://snmp.westhawk.co.uk/mailman/listinfo/snmp
--
-- Birgit Arkesteijn, birgit at westhawk.co.uk,
-- Westhawk Ltd, Albion Wharf, 19 Albion Street, Manchester M1 5LN, UK
-- Company no: 1769350
-- Registered Office:
-- 15 London Road, Stockton Heath, Warrington WA4 6SJ. UK.
-- tel.: +44 (0)161 237 0660
-- <URL: http://www.westhawk.co.uk>
More information about the snmp
mailing list