/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  java.lang.Integer
 *  java.lang.Object
 *  java.lang.String
 *  org.xml.sax.ErrorHandler
 *  org.xml.sax.SAXParseException
 */
package org.dom4j.util;

import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.QName;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXParseException;

public class XMLErrorHandler
implements ErrorHandler {
    protected static final QName ERROR_QNAME = QName.get("error");
    protected static final QName FATALERROR_QNAME = QName.get("fatalError");
    protected static final QName WARNING_QNAME = QName.get("warning");
    private QName errorQName;
    private Element errors;
    private QName fatalErrorQName;
    private QName warningQName;

    public XMLErrorHandler() {
        this.errorQName = ERROR_QNAME;
        this.fatalErrorQName = FATALERROR_QNAME;
        this.warningQName = WARNING_QNAME;
        this.errors = DocumentHelper.createElement("errors");
    }

    public XMLErrorHandler(Element element) {
        this.errorQName = ERROR_QNAME;
        this.fatalErrorQName = FATALERROR_QNAME;
        this.warningQName = WARNING_QNAME;
        this.errors = element;
    }

    protected void addException(Element element, SAXParseException sAXParseException) {
        String string2;
        element.addAttribute("column", Integer.toString((int)sAXParseException.getColumnNumber()));
        element.addAttribute("line", Integer.toString((int)sAXParseException.getLineNumber()));
        String string3 = sAXParseException.getPublicId();
        if (string3 != null && string3.length() > 0) {
            element.addAttribute("publicID", string3);
        }
        if ((string2 = sAXParseException.getSystemId()) != null && string2.length() > 0) {
            element.addAttribute("systemID", string2);
        }
        element.addText(sAXParseException.getMessage());
    }

    public void error(SAXParseException sAXParseException) {
        this.addException(this.errors.addElement(this.errorQName), sAXParseException);
    }

    public void fatalError(SAXParseException sAXParseException) {
        this.addException(this.errors.addElement(this.fatalErrorQName), sAXParseException);
    }

    public QName getErrorQName() {
        return this.errorQName;
    }

    public Element getErrors() {
        return this.errors;
    }

    public QName getFatalErrorQName() {
        return this.fatalErrorQName;
    }

    public QName getWarningQName() {
        return this.warningQName;
    }

    public void setErrorQName(QName qName) {
        this.errorQName = qName;
    }

    public void setErrors(Element element) {
        this.errors = element;
    }

    public void setFatalErrorQName(QName qName) {
        this.fatalErrorQName = qName;
    }

    public void setWarningQName(QName qName) {
        this.warningQName = qName;
    }

    public void warning(SAXParseException sAXParseException) {
        this.addException(this.errors.addElement(this.warningQName), sAXParseException);
    }
}

