[jdom-interest] Attribute comparison

Guy Nirpaz guyn at tantian.com
Tue Dec 5 03:01:02 PST 2000


Hi,

>
> It leads then that Attribute should behave similarly to Element, and
> it'll be especially important if/when we add attribute.getParent() and
> attributes become something that can't generally be equivalent without
> being ==.
>
This analogy lacks when you have a java.lang.String that represents text.
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 ==.

> 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.

Guy




More information about the jdom-interest mailing list