[jdom-interest] How about a general purpose Object reference?

Alex Chaffee guru at edamame.stinky.com
Mon Oct 9 07:42:14 PDT 2000


> Is there any compelling reasons not to do this? 

Cause it's dumb? :-)

Just kidding, it's a natural instinct, used in library APIs since the
dawn of time, but leads (as you said) to all sorts of messiness.

Since JDOM defines equals() lazily (that's not an insult, just a
description -- it uses ==) you can use a hashtable, and be assured you
won't get back the same object for different nodes that happen to have
the same contents.

  Map extra = new HashMap();
  extra.put( elementA, objectB );
  extra.put( elementC, objectD );

There's your association between JDOM nodes and arbitrary objects.

 - A

-- 
Alex Chaffee                       mailto:alex at jguru.com
jGuru - Java News and FAQs         http://www.jguru.com/alex/
Creator of Gamelan                 http://www.gamelan.com/
Founder of Purple Technology       http://www.purpletech.com/
Curator of Stinky Art Collective   http://www.stinky.com/



More information about the jdom-interest mailing list