[JDEV] jabberbeans api
Mathias Waag
mathias.waag at web.de
Tue Apr 1 17:58:58 CST 2003
hi,
i am using the jabberbeans api and i am adding up to 10 Extensions into a
presence packet. i have developed the extensions the same way the
jabberbeans api does. eg. IQBrowse, IQBrowseBuilder, IQBrowseHandler.
internally jabberbeans stores these extensions in a vector. when the
subscriber receives the presence packet, he can get the extensions within an
enumeration by calling the Extension() method of the ContentPacket class.
and thats my problem. if the subscriber is only interested in one extension
(say Location) i have to do the following:
for(Enumeration enum = presence.Extensions();enum.hasMoreElements();){
Object o = enum.nextElement();
if(o instanceof Location){
...
break;
}
}
thats bad. instanceof comparison is expensive, as far as i know.
is there another way of getting a specific extension?
- change the jabber api and use a hashtable.
ContentPacket: addExtension(String name, Extension ext),
getExtension(name)...
- subclassing the ContentPacket class and use a hashtable there.
- something else
- dont worry about the instanceof
cheers
mathias
More information about the JDev
mailing list