[jdom-interest] Inconsistancy in Namespace.hashCode().
Jason Hunter
jhunter at collab.net
Sat Mar 3 14:42:08 PST 2001
Elliotte Rusty Harold wrote:
>
> Yes, I disagree. I'm not sure when the mistake got in, but the
> comment is correct (i.e. it describes the right behavior) and the
> current code is wrong. Two namespaces are equal if their URIs are
> equal. The prefix should not be considered when testing for equality.
>
> I suppose you can argue that two Namespace objects are not equal if
> they describe different prefixes. Maybe that makes sense, but it
> makes me deeply uncomfortable.
>
> I guess the question comes down to what the use case for comparing
> namespaces is. I would expect that the equals method would let us
> take two set elements with possibly different prefixes, possibly one
> in a default namespace, and determine whether or not they have the
> same type; e.g. are both MathML set elements or is one a MathML set
> element and one an SVG set element? This only works if we compare
> based on URI and not prefix.
Hmm... I can see both sides. The counterargument to yours is that for
all other objects in JDOM we define equals() as ==, for good reasons
that I'll vigorously defend. Thus two <foo/> elements are not equals()
unless they're the same element object instance. Same with attributes.
Why should Namespace be different?
-jh-
More information about the jdom-interest
mailing list