[jdom-interest] Attribute comparison

Jason Hunter jhunter at collab.net
Tue Dec 5 10:34:26 PST 2000

> You can't impose == behaviour on String objects, it means that not all
> elements
> behave the same (String doesn't), and in that case you should consider
> that other 'basic' elements should implement equals otherwise than ==.

Well, Entity is another that absolutely needs .equals() to have ==
behavior because in many ways it behaves like an Element.

I already made my point about Comment, where you need to be able to
differentiate between two different comments in a List.

Let me also say it's far faster to do == than full comparisons, which
helps speed actions like attributes.remove(attrib) or

You can always implement a comparison check manually yourself.  That
also lets us avoid the debate if attributes are unique by name/value or

> > Also == helps for types like Comment because it allow you to remove a
> > comment in a list with getMixedContent().remove(comment), and you can't
> > accidentally remove a Comment that appears earlier with the same text.
> This is one scenario. But what if you want to change all comments in English
> to comments in other language. In that usecase this feature isn't usefull.
> I'm just
> saying here that we can decide either way. I personally prefer the latter.

I don't follow you here?


More information about the jdom-interest mailing list