[jdom-interest] DocType equals()-hashCode() contract violation

Elliotte Rusty Harold elharo at metalab.unc.edu
Wed Apr 17 10:30:04 PDT 2002

At 12:49 PM -0400 4/17/02, Alex Rosen wrote:
>Good point. Currently, only on DocType and Namespace does equals() do an
>actual equivalency check - everything else does an identity check (an ==
>check), as explained in the JDOM FAQ. Basically it does this because for
>Element, an equivalency check would be slow, and is not 100% well-defined.
>Your point about the internal subset indicates that it's not very
>well-defined for DocType either, which makes me think we should changes its
>equals() instead of its hashCode(). And if we did that would it imply that
>we should change Namespace too?

Namespace is trickier because it uses the flyweight design pattern. 
Unlike every other class in JDOM, there is not a 1-1 mapping between 
namespace nodes and Namespace objects.

| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
|          The XML Bible, 2nd Edition (Hungry Minds, 2001)           |
|             http://www.cafeconleche.org/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
|  Read Cafe con Leche for XML News: http://www.cafeconleche.org/    |

More information about the jdom-interest mailing list