[jdom-interest] Inconsistancy in Namespace.hashCode().
Jason Hunter
jhunter at collab.net
Wed Feb 28 14:45:39 PST 2001
"Steven D. Keens" wrote:
>
> I have been looking at the code a little and came across
> a discrepency between the function's documentation and its
> behaviour. Here's the code:
>
> /**
> * <p>
> * This returns a probably unique hash code for the
> <code>Namespace</code>.
> * If two namespaces have the same URI, they are equal and have the
> same
> * hash code, even if they have different prefixes.
> * </p>
> *
> * @return <code>int</code> - hash code for this <code>Namespace</code>.
> */
> public int hashCode() {
> // Since neither URI nor prefix are guaranteed to be unique,
> // use the combination
> return (prefix+uri).hashCode();
> }
>
> Notice that the prefix is appended to the uri and the resulting
> string's hashCode() is returned. But the documentation seems to
> say that prefixes are ignored. This also seems to contradict the
> documentation for the getNamespace() function.
>
> Whay do you think?
Good eye. I've changed the documentation on my local copy to be:
* This returns a probably unique hash code for the
<code>Namespace</code>.
* If two namespaces have the same URI but different prefixes, they
may
* have a different hash code.
This correctly defines the behavior, and I think the existing behavior
is correct. Anyone (Elliotte esp) have concerns?
-jh-
More information about the jdom-interest
mailing list