/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  java.lang.String
 *  java.lang.UnsupportedOperationException
 *  javax.xml.transform.sax.SAXSource
 *  org.xml.sax.InputSource
 *  org.xml.sax.XMLFilter
 *  org.xml.sax.XMLReader
 */
package org.dom4j.io;

import javax.xml.transform.sax.SAXSource;
import org.dom4j.Document;
import org.dom4j.Node;
import org.dom4j.io.DocumentInputSource;
import org.dom4j.io.SAXWriter;
import org.xml.sax.InputSource;
import org.xml.sax.XMLFilter;
import org.xml.sax.XMLReader;

public class DocumentSource
extends SAXSource {
    public static final String DOM4J_FEATURE = "http://org.dom4j.io.DoucmentSource/feature";
    private XMLReader xmlReader = new SAXWriter();

    public DocumentSource(Document document) {
        this.setDocument(document);
    }

    public DocumentSource(Node node) {
        this.setDocument(node.getDocument());
    }

    public Document getDocument() {
        return ((DocumentInputSource)this.getInputSource()).getDocument();
    }

    public XMLReader getXMLReader() {
        return this.xmlReader;
    }

    public void setDocument(Document document) {
        super.setInputSource((InputSource)new DocumentInputSource(document));
    }

    public void setInputSource(InputSource inputSource) throws UnsupportedOperationException {
        if (inputSource instanceof DocumentInputSource) {
            super.setInputSource((InputSource)((DocumentInputSource)inputSource));
            return;
        }
        throw new UnsupportedOperationException();
    }

    public void setXMLReader(XMLReader xMLReader) throws UnsupportedOperationException {
        if (xMLReader instanceof SAXWriter) {
            this.xmlReader = (SAXWriter)xMLReader;
            return;
        }
        if (xMLReader instanceof XMLFilter) {
            XMLReader xMLReader2;
            XMLFilter xMLFilter = (XMLFilter)xMLReader;
            while ((xMLReader2 = xMLFilter.getParent()) instanceof XMLFilter) {
                xMLFilter = (XMLFilter)xMLReader2;
            }
            xMLFilter.setParent(this.xmlReader);
            this.xmlReader = xMLFilter;
            return;
        }
        throw new UnsupportedOperationException();
    }
}

