All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.xolite.NamespacedName Maven / Gradle / Ivy

Go to download

This project provides a lightweight framework to serialize/deserialize (or marshall/unmarshall) java objects into XML. The implementation is based on standard SAX (Simple Api for Xml) but it follows a original approach based on the strong data encapsulation paradigm of Object Oriented (OO) programming.

The newest version!
/*-------------------------------------------------------------------------
 Copyright 2006 Olivier Berlanger

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 -------------------------------------------------------------------------*/
package net.sf.xolite;


/**
 * Class holding a "local name" and a "namespace URI".
 * 
 * @author Olivier Berlanger
 */
public class NamespacedName {


    private String uri;
    private String name;


    public NamespacedName(String namespaceUri, String localName) {
        uri = (namespaceUri == null) ? "" : namespaceUri;
        name = localName;
    }


    public String getNamespaceUri() {
        return uri;
    }


    public String getLocalName() {
        return name;
    }


    public String toString() {
        return uri + ":" + name;
    }


    public boolean equals(Object obj) {
        if (obj == null) return false;
        if (getClass() != obj.getClass()) return false;
        NamespacedName qName = (NamespacedName) obj;
        if (!name.equals(qName.name)) return false;
        if (uri == null) {
            if (qName.uri != null) return false;
        } else {
            if (!uri.equals(qName.uri)) return false;
        }
        return true;
    }


    public int hashCode() {
        int uriHash = (uri == null) ? 999 : uri.hashCode();
        int nameHash = (name == null) ? 777 : name.hashCode();
        return (uriHash << 15) + nameHash;
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy