[jdom-interest] question regarding HashMaps in Namespace class

Jerry Lawson jerry.lawson at virtualsummit.com
Thu Nov 9 12:09:42 PST 2000


The current implementation of Namespace.java uses two HashMaps:
mappings and namespaces.
The Namespace.getNamespace() method checks namespaces twice
but uses 2 different strings for the namespaces.get() method:

if (namespaces.containsKey(uri)) {
    return (Namespace)namespaces.get(uri);
}
...
if (namespaces.containsKey(uri)) {
    return (Namespace)namespaces.get(prefix + "&" + uri);
}


What is the point of this second check? It should never get there
if the uri key exists in namespaces.

Also, there doesn't seem to be any point in the mappings
HashMap.  URIs go in, but nothing comes out (kinda like a Roach Motel).

Most importantly, the string used in the namespaces.contains() call
should be 'prefix + "&" + uri', rather than simply 'uri', I think.
Adding some println, I can see that calling Namespace.getNamespace()
with the same prefix and uri always creates a new Namespace.
This seems to defeat the whole purpose of the namespaces table.

Have I discovered a bug or am I all wet ?

--
___________________________________________________
Jerry Lawson                   Virtual Summit, Inc.
Virtual Programmer   jerry.lawson at virtualsummit.com






More information about the jdom-interest mailing list