Alexander Veit wrote:
Christian Kloner wrote:
hi,

In OMNamespaceImpl class a commodity method named "equals(String namespaceUri)" is missing!at the moment only this one is there, but it returns false if only the prefixes are different.

    public boolean equals(String uri, String prefix) {
        return (((prefix == null) && (this.prefix == null)) ||
                ((prefix != null) && prefix.equals(this.prefix))) &&
                ((uri == null) && (this.uri == null) ||
                        (uri != null) && uri.equals(this.uri));

    }

at the moment you have to write ugly code like this to get rid of: element.getNamespace().getNamespaceURI().equals(namespaceURI)

1. it's not best practice to overload java.lang.Object#equals(Object) and
arg. my fault, didn't notice by writing this that i overloaded the default java.lang.Object#equals(Object) method. just shortened the
OMNamespace#equals(String uri, String prefix) a bit.

however, method OMNamespaceImpl#equals(Object) is not implemented. So the comparation OMNamespace#equals(OMNamespace) returns false if it is not the same reference/identity.
2. I agree with you that equality according to the XML namespace
semantics should not consider any namespace prefixes (e.g. see the javax.xml.namespace.QName implementation).

So the existing equals(String, String) method should probably be removed or renamed to avoid confusion.

An org.apache.axiom.om.OMElement#belongsToNamespace(String) method would probably suit your needs. However I'm not sure if it would be wise to introduce such methods into the API.
you are right. QName also does not provide such a method. but the thing is that i cannot even use ... if (new OMNamespaceImpl(namesapceUri, namespacePrefix).equals(omElement.getNamespace())) {...} ...

so a fix would be:
====================================
    public boolean equals(Object o) {
        return ((o != null) && (o.getClass() == OMNamespaceImpl.class))
               ? uri.equals(((OMNamespaceImpl) o).uri)
               : false;
    }
====================================



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to