[jdom-interest] Inconsistancy in Namespace.hashCode().

Steven D. Keens skeens at planetfred.com
Wed Feb 28 06:49:23 PST 2001


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?



--
Steven Keens                mailto:skeens at planetfred.com
PlanetFred Inc.             http://www.planetfred.com
44 Byward Market, Suite 240, Ottawa, ON, K1N 7A2, Canada




More information about the jdom-interest mailing list