/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  com.sun.msv.datatype.xsd.XSDatatype
 *  java.lang.Object
 *  java.lang.String
 *  java.util.HashMap
 *  java.util.Map
 *  java.util.Set
 */
package org.dom4j.datatype;

import com.sun.msv.datatype.xsd.XSDatatype;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.dom4j.DocumentFactory;
import org.dom4j.Element;
import org.dom4j.QName;
import org.dom4j.datatype.DatatypeElementFactory;

class NamedTypeResolver {
    protected Map complexTypeMap = new HashMap();
    protected DocumentFactory documentFactory;
    protected Map elementFactoryMap = new HashMap();
    protected Map simpleTypeMap = new HashMap();
    protected Map typedElementMap = new HashMap();

    NamedTypeResolver(DocumentFactory documentFactory) {
        this.documentFactory = documentFactory;
    }

    private QName getQName(String string2) {
        return this.documentFactory.createQName(string2);
    }

    private QName getQNameOfSchemaElement(Element element) {
        return super.getQName(element.attributeValue("name"));
    }

    void registerComplexType(QName qName, DocumentFactory documentFactory) {
        this.complexTypeMap.put((Object)qName, (Object)documentFactory);
    }

    void registerSimpleType(QName qName, XSDatatype xSDatatype) {
        this.simpleTypeMap.put((Object)qName, (Object)xSDatatype);
    }

    void registerTypedElement(Element element, QName qName, DocumentFactory documentFactory) {
        this.typedElementMap.put((Object)element, (Object)qName);
        this.elementFactoryMap.put((Object)element, (Object)documentFactory);
    }

    void resolveElementTypes() {
        for (Element element : this.typedElementMap.keySet()) {
            QName qName = this.getQNameOfSchemaElement(element);
            QName qName2 = (QName)this.typedElementMap.get((Object)element);
            if (this.complexTypeMap.containsKey((Object)qName2)) {
                qName.setDocumentFactory((DocumentFactory)this.complexTypeMap.get((Object)qName2));
                continue;
            }
            if (!this.simpleTypeMap.containsKey((Object)qName2)) continue;
            XSDatatype xSDatatype = (XSDatatype)this.simpleTypeMap.get((Object)qName2);
            DocumentFactory documentFactory = (DocumentFactory)this.elementFactoryMap.get((Object)element);
            if (!(documentFactory instanceof DatatypeElementFactory)) continue;
            ((DatatypeElementFactory)documentFactory).setChildElementXSDatatype(qName, xSDatatype);
        }
    }

    void resolveNamedTypes() {
        this.resolveElementTypes();
    }
}

