/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  java.lang.Object
 *  java.lang.String
 *  java.util.ArrayList
 *  java.util.List
 *  org.w3c.dom.Attr
 *  org.w3c.dom.DOMException
 *  org.w3c.dom.Document
 *  org.w3c.dom.Element
 *  org.w3c.dom.NamedNodeMap
 *  org.w3c.dom.Node
 *  org.w3c.dom.NodeList
 */
package org.dom4j.dom;

import java.util.ArrayList;
import java.util.List;
import org.dom4j.Attribute;
import org.dom4j.Branch;
import org.dom4j.DocumentFactory;
import org.dom4j.Element;
import org.dom4j.Namespace;
import org.dom4j.Node;
import org.dom4j.QName;
import org.dom4j.dom.DOMAttribute;
import org.dom4j.dom.DOMAttributeNodeMap;
import org.dom4j.dom.DOMDocumentFactory;
import org.dom4j.dom.DOMNodeHelper;
import org.dom4j.tree.DefaultElement;
import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.NodeList;

public class DOMElement
extends DefaultElement
implements org.w3c.dom.Element {
    private static final DocumentFactory DOCUMENT_FACTORY = DOMDocumentFactory.getInstance();

    public DOMElement(String string2) {
        super(string2);
    }

    public DOMElement(String string2, Namespace namespace) {
        super(string2, namespace);
    }

    public DOMElement(QName qName) {
        super(qName);
    }

    public DOMElement(QName qName, int n) {
        super(qName, n);
    }

    private void checkNewChildNode(org.w3c.dom.Node node) throws DOMException {
        short s = node.getNodeType();
        if (s != 1 && s != 3 && s != 8 && s != 7 && s != 4 && s != 5) {
            throw new DOMException(3, "Given node cannot be a child of element");
        }
    }

    public org.w3c.dom.Node appendChild(org.w3c.dom.Node node) throws DOMException {
        super.checkNewChildNode(node);
        return DOMNodeHelper.appendChild((Node)this, node);
    }

    protected Attribute attribute(String string2, String string3) {
        List list = this.attributeList();
        int n = list.size();
        for (int i = 0; i < n; ++i) {
            Attribute attribute = (Attribute)list.get(i);
            if (!string3.equals((Object)attribute.getName()) || (string2 != null && string2.length() != 0 || attribute.getNamespaceURI() != null && attribute.getNamespaceURI().length() != 0) && (string2 == null || !string2.equals((Object)attribute.getNamespaceURI()))) continue;
            return attribute;
        }
        return null;
    }

    protected Attribute attribute(Attr attr2) {
        return this.attribute(DOCUMENT_FACTORY.createQName(attr2.getLocalName(), attr2.getPrefix(), attr2.getNamespaceURI()));
    }

    public org.w3c.dom.Node cloneNode(boolean bl) {
        return DOMNodeHelper.cloneNode((Node)this, bl);
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    protected Attribute createAttribute(Attr attr2) {
        QName qName;
        String string2 = attr2.getLocalName();
        if (string2 != null) {
            String string3 = attr2.getPrefix();
            String string4 = attr2.getNamespaceURI();
            qName = this.getDocumentFactory().createQName(string2, string3, string4);
            do {
                return new DOMAttribute(qName, attr2.getValue());
                break;
            } while (true);
        }
        String string5 = attr2.getName();
        qName = this.getDocumentFactory().createQName(string5);
        return new DOMAttribute(qName, attr2.getValue());
    }

    public String getAttribute(String string2) {
        String string3 = this.attributeValue(string2);
        if (string3 != null) {
            return string3;
        }
        return "";
    }

    public String getAttributeNS(String string2, String string3) {
        String string4;
        Attribute attribute = this.attribute(string2, string3);
        if (attribute != null && (string4 = attribute.getValue()) != null) {
            return string4;
        }
        return "";
    }

    public Attr getAttributeNode(String string2) {
        return DOMNodeHelper.asDOMAttr(this.attribute(string2));
    }

    public Attr getAttributeNodeNS(String string2, String string3) {
        Attribute attribute = this.attribute(string2, string3);
        if (attribute != null) {
            DOMNodeHelper.asDOMAttr(attribute);
        }
        return null;
    }

    public NamedNodeMap getAttributes() {
        return new DOMAttributeNodeMap(this);
    }

    public NodeList getChildNodes() {
        return DOMNodeHelper.createNodeList(this.content());
    }

    @Override
    protected DocumentFactory getDocumentFactory() {
        DocumentFactory documentFactory = this.getQName().getDocumentFactory();
        if (documentFactory != null) {
            return documentFactory;
        }
        return DOCUMENT_FACTORY;
    }

    public NodeList getElementsByTagName(String string2) {
        ArrayList arrayList = new ArrayList();
        DOMNodeHelper.appendElementsByTagName((List)arrayList, (Branch)this, string2);
        return DOMNodeHelper.createNodeList((List)arrayList);
    }

    public NodeList getElementsByTagNameNS(String string2, String string3) {
        ArrayList arrayList = new ArrayList();
        DOMNodeHelper.appendElementsByTagNameNS((List)arrayList, (Branch)this, string2, string3);
        return DOMNodeHelper.createNodeList((List)arrayList);
    }

    public org.w3c.dom.Node getFirstChild() {
        return DOMNodeHelper.asDOMNode(this.node(0));
    }

    public org.w3c.dom.Node getLastChild() {
        return DOMNodeHelper.asDOMNode(this.node(-1 + this.nodeCount()));
    }

    public String getLocalName() {
        return this.getQName().getName();
    }

    @Override
    public String getNamespaceURI() {
        return this.getQName().getNamespaceURI();
    }

    public org.w3c.dom.Node getNextSibling() {
        return DOMNodeHelper.getNextSibling(this);
    }

    public String getNodeName() {
        return this.getName();
    }

    public String getNodeValue() throws DOMException {
        return null;
    }

    public Document getOwnerDocument() {
        return DOMNodeHelper.getOwnerDocument(this);
    }

    public org.w3c.dom.Node getParentNode() {
        return DOMNodeHelper.getParentNode(this);
    }

    public String getPrefix() {
        return this.getQName().getNamespacePrefix();
    }

    public org.w3c.dom.Node getPreviousSibling() {
        return DOMNodeHelper.getPreviousSibling(this);
    }

    protected QName getQName(String string2, String string3) {
        int n = string3.indexOf(58);
        String string4 = "";
        String string5 = string3;
        if (n >= 0) {
            string4 = string3.substring(0, n);
            string5 = string3.substring(n + 1);
        }
        return this.getDocumentFactory().createQName(string5, string4, string2);
    }

    public String getTagName() {
        return this.getName();
    }

    public boolean hasAttribute(String string2) {
        if (this.attribute(string2) != null) {
            return true;
        }
        return false;
    }

    public boolean hasAttributeNS(String string2, String string3) {
        if (this.attribute(string2, string3) != null) {
            return true;
        }
        return false;
    }

    public boolean hasAttributes() {
        return DOMNodeHelper.hasAttributes(this);
    }

    public boolean hasChildNodes() {
        if (this.nodeCount() > 0) {
            return true;
        }
        return false;
    }

    public org.w3c.dom.Node insertBefore(org.w3c.dom.Node node, org.w3c.dom.Node node2) throws DOMException {
        super.checkNewChildNode(node);
        return DOMNodeHelper.insertBefore((Node)this, node, node2);
    }

    public boolean isSupported(String string2, String string3) {
        return DOMNodeHelper.isSupported((Node)this, string2, string3);
    }

    public void removeAttribute(String string2) throws DOMException {
        Attribute attribute = this.attribute(string2);
        if (attribute != null) {
            this.remove(attribute);
        }
    }

    public void removeAttributeNS(String string2, String string3) throws DOMException {
        Attribute attribute = this.attribute(string2, string3);
        if (attribute != null) {
            this.remove(attribute);
        }
    }

    public Attr removeAttributeNode(Attr attr2) throws DOMException {
        Attribute attribute = this.attribute(attr2);
        if (attribute != null) {
            attribute.detach();
            return DOMNodeHelper.asDOMAttr(attribute);
        }
        throw new DOMException(8, "No such attribute");
    }

    public org.w3c.dom.Node removeChild(org.w3c.dom.Node node) throws DOMException {
        return DOMNodeHelper.removeChild((Node)this, node);
    }

    public org.w3c.dom.Node replaceChild(org.w3c.dom.Node node, org.w3c.dom.Node node2) throws DOMException {
        super.checkNewChildNode(node);
        return DOMNodeHelper.replaceChild((Node)this, node, node2);
    }

    public void setAttribute(String string2, String string3) throws DOMException {
        this.addAttribute(string2, string3);
    }

    public void setAttributeNS(String string2, String string3, String string4) throws DOMException {
        Attribute attribute = this.attribute(string2, string3);
        if (attribute != null) {
            attribute.setValue(string4);
            return;
        }
        this.addAttribute(this.getQName(string2, string3), string4);
    }

    public Attr setAttributeNode(Attr attr2) throws DOMException {
        if (this.isReadOnly()) {
            throw new DOMException(7, "No modification allowed");
        }
        Attribute attribute = this.attribute(attr2);
        if (attribute != attr2) {
            if (attr2.getOwnerElement() != null) {
                throw new DOMException(10, "Attribute is already in use");
            }
            Attribute attribute2 = this.createAttribute(attr2);
            if (attribute != null) {
                attribute.detach();
            }
            this.add(attribute2);
        }
        return DOMNodeHelper.asDOMAttr(attribute);
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    public Attr setAttributeNodeNS(Attr attr2) throws DOMException {
        Attribute attribute = this.attribute(attr2.getNamespaceURI(), attr2.getLocalName());
        if (attribute != null) {
            attribute.setValue(attr2.getValue());
            do {
                return DOMNodeHelper.asDOMAttr(attribute);
                break;
            } while (true);
        }
        attribute = this.createAttribute(attr2);
        this.add(attribute);
        return DOMNodeHelper.asDOMAttr(attribute);
    }

    public void setNodeValue(String string2) throws DOMException {
    }

    public void setPrefix(String string2) throws DOMException {
        DOMNodeHelper.setPrefix((Node)this, string2);
    }

    public boolean supports(String string2, String string3) {
        return DOMNodeHelper.supports((Node)this, string2, string3);
    }
}

