[jdom-interest] Inconsistancy in Namespace.hashCode().
Brett McLaughlin
brett at newInstance.com
Sat Mar 3 09:54:24 PST 2001
I agree with Elliotte's analysis.
-Brett
> -----Original Message-----
> From: jdom-interest-admin at jdom.org
> [mailto:jdom-interest-admin at jdom.org]On Behalf Of Elliotte Rusty Harold
> Sent: Saturday, March 03, 2001 9:34 AM
> To: Jason Hunter; Steven D. Keens
> Cc: jdom-interest
> Subject: Re: [jdom-interest] Inconsistancy in Namespace.hashCode().
>
>
> At 2:45 PM -0800 2/28/01, Jason Hunter wrote:
>
> >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?
> >
>
> 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.
> --
>
> +-----------------------+------------------------+-------------------+
> | Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
> +-----------------------+------------------------+-------------------+
> | The XML Bible (IDG Books, 1999) |
> | http://metalab.unc.edu/xml/books/bible/ |
> | http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/ |
> +----------------------------------+---------------------------------+
> | Read Cafe au Lait for Java News: http://metalab.unc.edu/javafaq/ |
> | Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/ |
> +----------------------------------+---------------------------------+
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yourad
dr at yourhost.com
More information about the jdom-interest
mailing list