/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  java.io.IOException
 *  java.io.Serializable
 *  java.io.Writer
 *  java.lang.CloneNotSupportedException
 *  java.lang.Cloneable
 *  java.lang.Number
 *  java.lang.Object
 *  java.lang.RuntimeException
 *  java.lang.String
 *  java.lang.StringBuffer
 *  java.lang.UnsupportedOperationException
 *  java.util.List
 */
package org.dom4j.tree;

import java.io.IOException;
import java.io.Serializable;
import java.io.Writer;
import java.util.List;
import org.dom4j.Document;
import org.dom4j.DocumentFactory;
import org.dom4j.Element;
import org.dom4j.Node;
import org.dom4j.NodeFilter;
import org.dom4j.XPath;
import org.dom4j.rule.Pattern;

public abstract class AbstractNode
implements Serializable,
Cloneable,
Node {
    private static final DocumentFactory DOCUMENT_FACTORY;
    protected static final String[] NODE_TYPE_NAMES;

    static {
        NODE_TYPE_NAMES = new String[]{"Node", "Element", "Attribute", "Text", "CDATA", "Entity", "Entity", "ProcessingInstruction", "Comment", "Document", "DocumentType", "DocumentFragment", "Notation", "Namespace", "Unknown"};
        DOCUMENT_FACTORY = DocumentFactory.getInstance();
    }

    @Override
    public Node asXPathResult(Element element) {
        if (this.supportsParent()) {
            return this;
        }
        return this.createXPathResult(element);
    }

    @Override
    public Object clone() {
        if (this.isReadOnly()) {
            return this;
        }
        try {
            Node node = (Node)super.clone();
            node.setParent(null);
            node.setDocument(null);
            return node;
        }
        catch (CloneNotSupportedException var1_2) {
            throw new RuntimeException(new StringBuffer().append("This should never happen. Caught: ").append((Object)var1_2).toString());
        }
    }

    public Pattern createPattern(String string2) {
        return this.getDocumentFactory().createPattern(string2);
    }

    @Override
    public XPath createXPath(String string2) {
        return this.getDocumentFactory().createXPath(string2);
    }

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

    protected Node createXPathResult(Element element) {
        throw new RuntimeException(new StringBuffer().append("asXPathResult() not yet implemented fully for: ").append((Object)this).toString());
    }

    /*
     * Enabled aggressive block sorting
     */
    @Override
    public Node detach() {
        Element element = this.getParent();
        if (element != null) {
            element.remove((Node)this);
        } else {
            Document document = this.getDocument();
            if (document != null) {
                document.remove((Node)this);
            }
        }
        this.setParent(null);
        this.setDocument(null);
        return this;
    }

    @Override
    public Document getDocument() {
        Element element = this.getParent();
        if (element != null) {
            return element.getDocument();
        }
        return null;
    }

    protected DocumentFactory getDocumentFactory() {
        return DOCUMENT_FACTORY;
    }

    @Override
    public String getName() {
        return null;
    }

    @Override
    public short getNodeType() {
        return 14;
    }

    @Override
    public String getNodeTypeName() {
        short s = this.getNodeType();
        if (s < 0 || s >= NODE_TYPE_NAMES.length) {
            return "Unknown";
        }
        return NODE_TYPE_NAMES[s];
    }

    @Override
    public Element getParent() {
        return null;
    }

    @Override
    public String getPath() {
        return this.getPath(null);
    }

    @Override
    public String getStringValue() {
        return this.getText();
    }

    @Override
    public String getText() {
        return null;
    }

    @Override
    public String getUniquePath() {
        return this.getUniquePath(null);
    }

    @Override
    public boolean hasContent() {
        return false;
    }

    @Override
    public boolean isReadOnly() {
        return true;
    }

    @Override
    public boolean matches(String string2) {
        return this.createXPathFilter(string2).matches((Node)this);
    }

    @Override
    public Number numberValueOf(String string2) {
        return this.createXPath(string2).numberValueOf(this);
    }

    @Override
    public List selectNodes(String string2) {
        return this.createXPath(string2).selectNodes(this);
    }

    @Override
    public List selectNodes(String string2, String string3) {
        return this.selectNodes(string2, string3, false);
    }

    @Override
    public List selectNodes(String string2, String string3, boolean bl) {
        return this.createXPath(string2).selectNodes(this, this.createXPath(string3), bl);
    }

    @Override
    public Object selectObject(String string2) {
        return this.createXPath(string2).evaluate(this);
    }

    @Override
    public Node selectSingleNode(String string2) {
        return this.createXPath(string2).selectSingleNode(this);
    }

    @Override
    public void setDocument(Document document) {
    }

    @Override
    public void setName(String string2) {
        throw new UnsupportedOperationException("This node cannot be modified");
    }

    @Override
    public void setParent(Element element) {
    }

    @Override
    public void setText(String string2) {
        throw new UnsupportedOperationException("This node cannot be modified");
    }

    @Override
    public boolean supportsParent() {
        return false;
    }

    @Override
    public String valueOf(String string2) {
        return this.createXPath(string2).valueOf(this);
    }

    @Override
    public void write(Writer writer) throws IOException {
        writer.write(this.asXML());
    }
}

