/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  java.lang.Object
 *  java.lang.String
 *  java.lang.StringBuffer
 */
package org.dom4j;

import org.dom4j.Element;
import org.dom4j.Node;
import org.dom4j.Visitor;
import org.dom4j.tree.AbstractNode;
import org.dom4j.tree.DefaultNamespace;
import org.dom4j.tree.NamespaceCache;

public class Namespace
extends AbstractNode {
    protected static final NamespaceCache CACHE = new NamespaceCache();
    public static final Namespace NO_NAMESPACE;
    public static final Namespace XML_NAMESPACE;
    private int hashCode;
    private String prefix;
    private String uri;

    static {
        XML_NAMESPACE = CACHE.get("xml", "http://www.w3.org/XML/1998/namespace");
        NO_NAMESPACE = CACHE.get("", "");
    }

    /*
     * Enabled aggressive block sorting
     */
    public Namespace(String string2, String string3) {
        if (string2 == null) {
            string2 = "";
        }
        this.prefix = string2;
        if (string3 == null) {
            string3 = "";
        }
        this.uri = string3;
    }

    public static Namespace get(String string2) {
        return CACHE.get(string2);
    }

    public static Namespace get(String string2, String string3) {
        return CACHE.get(string2, string3);
    }

    @Override
    public void accept(Visitor visitor) {
        visitor.visit((Namespace)this);
    }

    /*
     * Enabled aggressive block sorting
     */
    @Override
    public String asXML() {
        StringBuffer stringBuffer = new StringBuffer(10);
        String string2 = this.getPrefix();
        if (string2 != null && string2.length() > 0) {
            stringBuffer.append("xmlns:");
            stringBuffer.append(string2);
            stringBuffer.append("=\"");
        } else {
            stringBuffer.append("xmlns=\"");
        }
        stringBuffer.append(this.getURI());
        stringBuffer.append("\"");
        return stringBuffer.toString();
    }

    protected int createHashCode() {
        int n = this.uri.hashCode() ^ this.prefix.hashCode();
        if (n == 0) {
            n = 47806;
        }
        return n;
    }

    @Override
    protected Node createXPathResult(Element element) {
        return new DefaultNamespace(element, this.getPrefix(), this.getURI());
    }

    /*
     * Enabled aggressive block sorting
     * Lifted jumps to return sites
     */
    public boolean equals(Object object) {
        if (this == object) {
            return true;
        }
        if (!(object instanceof Namespace)) return false;
        Namespace namespace = (Namespace)object;
        if (this.hashCode() != namespace.hashCode()) return false;
        if (!this.uri.equals((Object)namespace.getURI())) return false;
        if (this.prefix.equals((Object)namespace.getPrefix())) return true;
        return false;
    }

    @Override
    public short getNodeType() {
        return 13;
    }

    @Override
    public String getPath(Element element) {
        StringBuffer stringBuffer = new StringBuffer(10);
        Element element2 = this.getParent();
        if (element2 != null && element2 != element) {
            stringBuffer.append(element2.getPath(element));
            stringBuffer.append('/');
        }
        stringBuffer.append(this.getXPathNameStep());
        return stringBuffer.toString();
    }

    public String getPrefix() {
        return this.prefix;
    }

    @Override
    public String getStringValue() {
        return this.uri;
    }

    @Override
    public String getText() {
        return this.uri;
    }

    public String getURI() {
        return this.uri;
    }

    @Override
    public String getUniquePath(Element element) {
        StringBuffer stringBuffer = new StringBuffer(10);
        Element element2 = this.getParent();
        if (element2 != null && element2 != element) {
            stringBuffer.append(element2.getUniquePath(element));
            stringBuffer.append('/');
        }
        stringBuffer.append(this.getXPathNameStep());
        return stringBuffer.toString();
    }

    public String getXPathNameStep() {
        if (this.prefix != null && !"".equals((Object)this.prefix)) {
            return new StringBuffer().append("namespace::").append(this.prefix).toString();
        }
        return "namespace::*[name()='']";
    }

    public int hashCode() {
        if (this.hashCode == 0) {
            this.hashCode = this.createHashCode();
        }
        return this.hashCode;
    }

    public String toString() {
        return new StringBuffer().append(super.toString()).append(" [Namespace: prefix ").append(this.getPrefix()).append(" mapped to URI \"").append(this.getURI()).append("\"]").toString();
    }
}

