/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  java.io.IOException
 *  java.io.ObjectInputStream
 *  java.io.PrintStream
 *  java.io.Serializable
 *  java.lang.Class
 *  java.lang.ClassLoader
 *  java.lang.ClassNotFoundException
 *  java.lang.Exception
 *  java.lang.IllegalArgumentException
 *  java.lang.NoClassDefFoundError
 *  java.lang.Object
 *  java.lang.String
 *  java.lang.StringBuffer
 *  java.lang.System
 *  java.lang.Throwable
 *  java.util.List
 *  java.util.Map
 *  org.jaxen.VariableContext
 */
package org.dom4j;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.PrintStream;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.dom4j.Attribute;
import org.dom4j.CDATA;
import org.dom4j.Comment;
import org.dom4j.Document;
import org.dom4j.DocumentType;
import org.dom4j.Element;
import org.dom4j.Entity;
import org.dom4j.InvalidXPathException;
import org.dom4j.Namespace;
import org.dom4j.NodeFilter;
import org.dom4j.ProcessingInstruction;
import org.dom4j.QName;
import org.dom4j.Text;
import org.dom4j.XPath;
import org.dom4j.rule.Pattern;
import org.dom4j.tree.AbstractDocument;
import org.dom4j.tree.DefaultAttribute;
import org.dom4j.tree.DefaultCDATA;
import org.dom4j.tree.DefaultComment;
import org.dom4j.tree.DefaultDocument;
import org.dom4j.tree.DefaultDocumentType;
import org.dom4j.tree.DefaultElement;
import org.dom4j.tree.DefaultEntity;
import org.dom4j.tree.DefaultProcessingInstruction;
import org.dom4j.tree.DefaultText;
import org.dom4j.tree.QNameCache;
import org.dom4j.util.SimpleSingleton;
import org.dom4j.util.SingletonStrategy;
import org.dom4j.xpath.DefaultXPath;
import org.dom4j.xpath.XPathPattern;
import org.jaxen.VariableContext;

public class DocumentFactory
implements Serializable {
    static Class class$org$dom4j$DocumentFactory;
    private static SingletonStrategy singleton;
    protected transient QNameCache cache;
    private Map xpathNamespaceURIs;

    static {
        singleton = null;
    }

    public DocumentFactory() {
        this.init();
    }

    static Class class$(String string2) {
        try {
            Class class_ = Class.forName((String)string2);
            return class_;
        }
        catch (ClassNotFoundException var1_2) {
            throw new NoClassDefFoundError(var1_2.getMessage());
        }
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    protected static DocumentFactory createSingleton(String string2) {
        try {
            Class class_;
            if (class$org$dom4j$DocumentFactory == null) {
                class$org$dom4j$DocumentFactory = class_ = DocumentFactory.class$("org.dom4j.DocumentFactory");
                do {
                    return (DocumentFactory)Class.forName((String)string2, (boolean)true, (ClassLoader)class_.getClassLoader()).newInstance();
                    break;
                } while (true);
            }
            class_ = class$org$dom4j$DocumentFactory;
            return (DocumentFactory)Class.forName((String)string2, (boolean)true, (ClassLoader)class_.getClassLoader()).newInstance();
        }
        catch (Throwable var1_2) {
            System.out.println(new StringBuffer().append("WARNING: Cannot load DocumentFactory: ").append(string2).toString());
            return new DocumentFactory();
        }
    }

    /*
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    private static SingletonStrategy createSingleton() {
        SingletonStrategy singletonStrategy;
        String string2;
        try {
            String string3;
            string2 = string3 = System.getProperty((String)"org.dom4j.factory", (String)"org.dom4j.DocumentFactory");
        }
        catch (Exception var0_3) {
            string2 = "org.dom4j.DocumentFactory";
        }
        try {
            singletonStrategy = (SingletonStrategy)Class.forName((String)System.getProperty((String)"org.dom4j.DocumentFactory.singleton.strategy", (String)"org.dom4j.util.SimpleSingleton")).newInstance();
        }
        catch (Exception var2_4) {
            singletonStrategy = new SimpleSingleton();
        }
        singletonStrategy.setSingletonClassName(string2);
        return singletonStrategy;
    }

    public static DocumentFactory getInstance() {
        reference var2 = DocumentFactory.class;
        synchronized (DocumentFactory.class) {
            if (singleton == null) {
                singleton = DocumentFactory.createSingleton();
            }
            DocumentFactory documentFactory = (DocumentFactory)singleton.instance();
            // ** MonitorExit[var2] (shouldn't be in output)
            return documentFactory;
        }
    }

    private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
        objectInputStream.defaultReadObject();
        this.init();
    }

    public Attribute createAttribute(Element element, String string2, String string3) {
        return this.createAttribute(element, this.createQName(string2), string3);
    }

    public Attribute createAttribute(Element element, QName qName, String string2) {
        return new DefaultAttribute(qName, string2);
    }

    public CDATA createCDATA(String string2) {
        return new DefaultCDATA(string2);
    }

    public Comment createComment(String string2) {
        return new DefaultComment(string2);
    }

    public DocumentType createDocType(String string2, String string3, String string4) {
        return new DefaultDocumentType(string2, string3, string4);
    }

    public Document createDocument() {
        DefaultDocument defaultDocument = new DefaultDocument();
        defaultDocument.setDocumentFactory(this);
        return defaultDocument;
    }

    public Document createDocument(String string2) {
        Document document = this.createDocument();
        if (document instanceof AbstractDocument) {
            ((AbstractDocument)document).setXMLEncoding(string2);
        }
        return document;
    }

    public Document createDocument(Element element) {
        Document document = this.createDocument();
        document.setRootElement(element);
        return document;
    }

    public Element createElement(String string2) {
        return this.createElement(this.createQName(string2));
    }

    public Element createElement(String string2, String string3) {
        return this.createElement(this.createQName(string2, string3));
    }

    public Element createElement(QName qName) {
        return new DefaultElement(qName);
    }

    public Entity createEntity(String string2, String string3) {
        return new DefaultEntity(string2, string3);
    }

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

    public Pattern createPattern(String string2) {
        return new XPathPattern(string2);
    }

    public ProcessingInstruction createProcessingInstruction(String string2, String string3) {
        return new DefaultProcessingInstruction(string2, string3);
    }

    public ProcessingInstruction createProcessingInstruction(String string2, Map map) {
        return new DefaultProcessingInstruction(string2, map);
    }

    public QName createQName(String string2) {
        return this.cache.get(string2);
    }

    public QName createQName(String string2, String string3) {
        return this.cache.get(string2, string3);
    }

    public QName createQName(String string2, String string3, String string4) {
        return this.cache.get(string2, Namespace.get(string3, string4));
    }

    public QName createQName(String string2, Namespace namespace) {
        return this.cache.get(string2, namespace);
    }

    protected QNameCache createQNameCache() {
        return new QNameCache(this);
    }

    public Text createText(String string2) {
        if (string2 == null) {
            throw new IllegalArgumentException("Adding text to an XML document must not be null");
        }
        return new DefaultText(string2);
    }

    public XPath createXPath(String string2) throws InvalidXPathException {
        DefaultXPath defaultXPath = new DefaultXPath(string2);
        if (this.xpathNamespaceURIs != null) {
            defaultXPath.setNamespaceURIs(this.xpathNamespaceURIs);
        }
        return defaultXPath;
    }

    public XPath createXPath(String string2, VariableContext variableContext) {
        XPath xPath = this.createXPath(string2);
        xPath.setVariableContext(variableContext);
        return xPath;
    }

    public NodeFilter createXPathFilter(String string2) {
        return this.createXPath(string2);
    }

    public NodeFilter createXPathFilter(String string2, VariableContext variableContext) {
        XPath xPath = this.createXPath(string2);
        xPath.setVariableContext(variableContext);
        return xPath;
    }

    public List getQNames() {
        return this.cache.getQNames();
    }

    public Map getXPathNamespaceURIs() {
        return this.xpathNamespaceURIs;
    }

    protected void init() {
        this.cache = this.createQNameCache();
    }

    protected QName intern(QName qName) {
        return this.cache.intern(qName);
    }

    public void setXPathNamespaceURIs(Map map) {
        this.xpathNamespaceURIs = map;
    }
}

