/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  java.io.IOException
 *  java.lang.Object
 *  java.lang.RuntimeException
 *  java.lang.String
 *  java.lang.StringBuffer
 *  org.xml.sax.ContentHandler
 *  org.xml.sax.ErrorHandler
 *  org.xml.sax.InputSource
 *  org.xml.sax.SAXException
 *  org.xml.sax.XMLReader
 *  org.xml.sax.helpers.DefaultHandler
 */
package org.dom4j.io;

import java.io.IOException;
import org.dom4j.Document;
import org.dom4j.io.DocumentInputSource;
import org.dom4j.io.SAXHelper;
import org.xml.sax.ContentHandler;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;

public class SAXValidator {
    private ErrorHandler errorHandler;
    private XMLReader xmlReader;

    public SAXValidator() {
    }

    public SAXValidator(XMLReader xMLReader) {
        this.xmlReader = xMLReader;
    }

    protected void configureReader() throws SAXException {
        if (this.xmlReader.getContentHandler() == null) {
            this.xmlReader.setContentHandler((ContentHandler)new DefaultHandler());
        }
        this.xmlReader.setFeature("http://xml.org/sax/features/validation", true);
        this.xmlReader.setFeature("http://xml.org/sax/features/namespaces", true);
        this.xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
    }

    protected XMLReader createXMLReader() throws SAXException {
        return SAXHelper.createXMLReader(true);
    }

    public ErrorHandler getErrorHandler() {
        return this.errorHandler;
    }

    public XMLReader getXMLReader() throws SAXException {
        if (this.xmlReader == null) {
            this.xmlReader = this.createXMLReader();
            this.configureReader();
        }
        return this.xmlReader;
    }

    public void setErrorHandler(ErrorHandler errorHandler) {
        this.errorHandler = errorHandler;
    }

    public void setXMLReader(XMLReader xMLReader) throws SAXException {
        this.xmlReader = xMLReader;
        this.configureReader();
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    public void validate(Document document) throws SAXException {
        if (document == null) return;
        XMLReader xMLReader = this.getXMLReader();
        if (this.errorHandler != null) {
            xMLReader.setErrorHandler(this.errorHandler);
        }
        try {
            xMLReader.parse((InputSource)new DocumentInputSource(document));
            return;
        }
        catch (IOException var3_3) {
            throw new RuntimeException(new StringBuffer().append("Caught and exception that should never happen: ").append((Object)var3_3).toString());
        }
    }
}

