影视仓 v5.0.24版本的 MD5 值为:620341689ccdc375a3b86527e140060e

以下内容为反编译后的 DomDriver.java 源代码,内容仅作参考


package com.thoughtworks.xstream.io.xml;

import com.androidx.fe0;
import com.thoughtworks.xstream.converters.reflection.ObjectAccessException;
import com.thoughtworks.xstream.core.JVM;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.StreamException;
import com.thoughtworks.xstream.io.naming.NameCoder;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
public class DomDriver extends AbstractXmlDriver {
    static Class class$java$lang$String;
    static Class class$javax$xml$parsers$DocumentBuilderFactory;
    private DocumentBuilderFactory documentBuilderFactory;
    private final String encoding;

    public DomDriver() {
        this(null);
    }

    public static Class class$(String str) {
        try {
            return Class.forName(str);
        } catch (ClassNotFoundException e) {
            throw fe0.OooO0Oo(e);
        }
    }

    public DocumentBuilderFactory createDocumentBuilderFactory() {
        DocumentBuilderFactory newInstance = DocumentBuilderFactory.newInstance();
        if (JVM.isVersion(5)) {
            try {
                Class cls = class$javax$xml$parsers$DocumentBuilderFactory;
                if (cls == null) {
                    cls = class$("javax.xml.parsers.DocumentBuilderFactory");
                    class$javax$xml$parsers$DocumentBuilderFactory = cls;
                }
                Class<?>[] clsArr = new Class[2];
                Class<?> cls2 = class$java$lang$String;
                if (cls2 == null) {
                    cls2 = class$("java.lang.String");
                    class$java$lang$String = cls2;
                }
                clsArr[0] = cls2;
                clsArr[1] = Boolean.TYPE;
                cls.getMethod("setFeature", clsArr).invoke(newInstance, "http://apache.org/xml/features/disallow-doctype-decl", Boolean.TRUE);
            } catch (IllegalAccessException e) {
                throw new ObjectAccessException("Cannot set feature of DocumentBuilderFactory.", e);
            } catch (NoSuchMethodException unused) {
            } catch (InvocationTargetException e2) {
                Throwable cause = e2.getCause();
                if (JVM.isVersion(6) || ((cause instanceof ParserConfigurationException) && cause.getMessage().indexOf("disallow-doctype-decl") < 0)) {
                    throw new StreamException(cause);
                }
            }
        }
        newInstance.setExpandEntityReferences(false);
        return newInstance;
    }

    @Override
    public HierarchicalStreamReader createReader(Reader reader) {
        return createReader(new InputSource(reader));
    }

    @Override
    public HierarchicalStreamWriter createWriter(Writer writer) {
        return new PrettyPrintWriter(writer, getNameCoder());
    }

    public DomDriver(String str) {
        this(str, new XmlFriendlyNameCoder());
    }

    @Override
    public HierarchicalStreamReader createReader(InputStream inputStream) {
        return createReader(new InputSource(inputStream));
    }

    @Override
    public HierarchicalStreamWriter createWriter(OutputStream outputStream) {
        try {
            return createWriter(this.encoding != null ? new OutputStreamWriter(outputStream, this.encoding) : new OutputStreamWriter(outputStream));
        } catch (UnsupportedEncodingException e) {
            throw new StreamException(e);
        }
    }

    public DomDriver(String str, NameCoder nameCoder) {
        super(nameCoder);
        this.encoding = str;
    }

    @Override
    public HierarchicalStreamReader createReader(URL url) {
        return createReader(new InputSource(url.toExternalForm()));
    }

    @Override
    public HierarchicalStreamReader createReader(File file) {
        return createReader(new InputSource(file.toURI().toASCIIString()));
    }

    public DomDriver(String str, XmlFriendlyReplacer xmlFriendlyReplacer) {
        this(str, (NameCoder) xmlFriendlyReplacer);
    }

    private HierarchicalStreamReader createReader(InputSource inputSource) {
        try {
            if (this.documentBuilderFactory == null) {
                synchronized (this) {
                    if (this.documentBuilderFactory == null) {
                        this.documentBuilderFactory = createDocumentBuilderFactory();
                    }
                }
            }
            DocumentBuilder newDocumentBuilder = this.documentBuilderFactory.newDocumentBuilder();
            String str = this.encoding;
            if (str != null) {
                inputSource.setEncoding(str);
            }
            return new DomReader(newDocumentBuilder.parse(inputSource), getNameCoder());
        } catch (IOException e) {
            throw new StreamException(e);
        } catch (FactoryConfigurationError e2) {
            throw new StreamException(e2);
        } catch (ParserConfigurationException e3) {
            throw new StreamException(e3);
        } catch (SAXException e4) {
            throw new StreamException(e4);
        }
    }
}