/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  java.io.Serializable
 *  java.lang.Object
 *  java.lang.String
 *  org.jaxen.NamespaceContext
 */
package org.dom4j.xpath;

import java.io.Serializable;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.Namespace;
import org.dom4j.Node;
import org.jaxen.NamespaceContext;

public class DefaultNamespaceContext
implements Serializable,
NamespaceContext {
    private final Element element;

    public DefaultNamespaceContext(Element element) {
        this.element = element;
    }

    /*
     * Enabled aggressive block sorting
     */
    public static DefaultNamespaceContext create(Object object) {
        Element element;
        if (object instanceof Element) {
            element = (Element)object;
        } else if (object instanceof Document) {
            element = ((Document)object).getRootElement();
        } else {
            boolean bl = object instanceof Node;
            element = null;
            if (!bl) return null;
            element = ((Node)object).getParent();
        }
        if (element != null) {
            return new DefaultNamespaceContext(element);
        }
        return null;
    }

    public String translateNamespacePrefixToUri(String string2) {
        Namespace namespace;
        if (string2 != null && string2.length() > 0 && (namespace = this.element.getNamespaceForPrefix(string2)) != null) {
            return namespace.getURI();
        }
        return null;
    }
}

