Re: Equality tests on DOM nodes

On the general topic of "equality", I hope that it's clear to everyone
that there are almost innumerable definitions of the notion based on
the particular task being performed ... don't go hoping for a single
universal "always useful" definition!!!


Ray Whitmer wrote:
> 
> 	 it is not unreasonable to expect that the Java DOM binding
> might eventually specify some behavior here, which would not be the "=="
> comparison.

Though there's one thing to consider:  The behavior of Object.equals()
and Object.hashCode() is specified to make objects work as hashtable
keys in the natural manner.  For example, strings can be used as keys
since they're immutable and equals() is overridden ... were they mutable,
or did they not override equals(), that'd not be so.

If org.w3c.dom.Node.equals(Object) were defined to invoke the DOM
method equals(Node, true) then when a node was changed, it'd need
to get moved to a different location in any hashtable.

For the moment, I have a hard time seeing any better implementations
of Object.equals() and Object.hashCode() for DOM nodes than the default!

- Dave

Received on Wednesday, 16 December 1998 05:05:51 UTC