/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  java.io.IOException
 *  java.io.StringWriter
 *  java.io.Writer
 *  java.lang.Class
 *  java.lang.Integer
 *  java.lang.Object
 *  java.lang.RuntimeException
 *  java.lang.String
 *  java.lang.StringBuffer
 *  java.util.ArrayList
 *  java.util.Collections
 *  java.util.Iterator
 *  java.util.List
 *  java.util.Map
 *  org.xml.sax.Attributes
 */
package org.dom4j.tree;

import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.dom4j.Attribute;
import org.dom4j.Branch;
import org.dom4j.CDATA;
import org.dom4j.CharacterData;
import org.dom4j.Comment;
import org.dom4j.Document;
import org.dom4j.DocumentFactory;
import org.dom4j.Element;
import org.dom4j.Entity;
import org.dom4j.IllegalAddException;
import org.dom4j.Namespace;
import org.dom4j.Node;
import org.dom4j.ProcessingInstruction;
import org.dom4j.QName;
import org.dom4j.Text;
import org.dom4j.Visitor;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
import org.dom4j.tree.AbstractBranch;
import org.dom4j.tree.BackedList;
import org.dom4j.tree.ContentListFacade;
import org.dom4j.tree.NamespaceStack;
import org.dom4j.tree.SingleIterator;
import org.xml.sax.Attributes;

public abstract class AbstractElement
extends AbstractBranch
implements Element {
    private static final DocumentFactory DOCUMENT_FACTORY = DocumentFactory.getInstance();
    protected static final Iterator EMPTY_ITERATOR;
    protected static final List EMPTY_LIST;
    protected static final boolean USE_STRINGVALUE_SEPARATOR;
    protected static final boolean VERBOSE_TOSTRING;

    static {
        EMPTY_LIST = Collections.EMPTY_LIST;
        EMPTY_ITERATOR = EMPTY_LIST.iterator();
    }

    @Override
    public void accept(Visitor visitor) {
        visitor.visit((Element)this);
        int n = this.attributeCount();
        for (int i = 0; i < n; ++i) {
            visitor.visit(this.attribute(i));
        }
        int n2 = this.nodeCount();
        for (int j = 0; j < n2; ++j) {
            this.node(j).accept(visitor);
        }
    }

    @Override
    public void add(Attribute attribute) {
        if (attribute.getParent() != null) {
            throw new IllegalAddException((Element)this, (Node)attribute, new StringBuffer().append("The Attribute already has an existing parent \"").append(attribute.getParent().getQualifiedName()).append("\"").toString());
        }
        if (attribute.getValue() == null) {
            Attribute attribute2 = this.attribute(attribute.getQName());
            if (attribute2 != null) {
                this.remove(attribute2);
            }
            return;
        }
        this.attributeList().add((Object)attribute);
        this.childAdded(attribute);
    }

    @Override
    public void add(CDATA cDATA) {
        this.addNode(cDATA);
    }

    @Override
    public void add(Comment comment) {
        this.addNode(comment);
    }

    @Override
    public void add(Element element) {
        this.addNode(element);
    }

    @Override
    public void add(Entity entity) {
        this.addNode(entity);
    }

    @Override
    public void add(Namespace namespace) {
        this.addNode(namespace);
    }

    @Override
    public void add(Node node) {
        switch (node.getNodeType()) {
            default: {
                this.invalidNodeTypeAddException(node);
                return;
            }
            case 1: {
                this.add((Element)node);
                return;
            }
            case 2: {
                this.add((Attribute)node);
                return;
            }
            case 3: {
                this.add((Text)node);
                return;
            }
            case 4: {
                this.add((CDATA)node);
                return;
            }
            case 5: {
                this.add((Entity)node);
                return;
            }
            case 7: {
                this.add((ProcessingInstruction)node);
                return;
            }
            case 8: {
                this.add((Comment)node);
                return;
            }
            case 13: 
        }
        this.add((Namespace)node);
    }

    @Override
    public void add(ProcessingInstruction processingInstruction) {
        this.addNode(processingInstruction);
    }

    @Override
    public void add(Text text) {
        this.addNode(text);
    }

    /*
     * Enabled aggressive block sorting
     * Lifted jumps to return sites
     */
    @Override
    public Element addAttribute(String string2, String string3) {
        Attribute attribute = this.attribute(string2);
        if (string3 == null) {
            if (attribute == null) return this;
            this.remove(attribute);
            return this;
        }
        if (attribute == null) {
            this.add(this.getDocumentFactory().createAttribute((Element)this, string2, string3));
            return this;
        }
        if (attribute.isReadOnly()) {
            this.remove(attribute);
            this.add(this.getDocumentFactory().createAttribute((Element)this, string2, string3));
            return this;
        }
        attribute.setValue(string3);
        return this;
    }

    /*
     * Enabled aggressive block sorting
     * Lifted jumps to return sites
     */
    @Override
    public Element addAttribute(QName qName, String string2) {
        Attribute attribute = this.attribute(qName);
        if (string2 == null) {
            if (attribute == null) return this;
            this.remove(attribute);
            return this;
        }
        if (attribute == null) {
            this.add(this.getDocumentFactory().createAttribute((Element)this, qName, string2));
            return this;
        }
        if (attribute.isReadOnly()) {
            this.remove(attribute);
            this.add(this.getDocumentFactory().createAttribute((Element)this, qName, string2));
            return this;
        }
        attribute.setValue(string2);
        return this;
    }

    @Override
    public Element addCDATA(String string2) {
        this.addNewNode(this.getDocumentFactory().createCDATA(string2));
        return this;
    }

    @Override
    public Element addComment(String string2) {
        this.addNewNode(this.getDocumentFactory().createComment(string2));
        return this;
    }

    /*
     * Enabled aggressive block sorting
     */
    @Override
    public Element addElement(String string2) {
        Namespace namespace;
        DocumentFactory documentFactory = this.getDocumentFactory();
        int n = string2.indexOf(":");
        String string3 = string2;
        if (n > 0) {
            String string4 = string2.substring(0, n);
            string3 = string2.substring(n + 1);
            namespace = this.getNamespaceForPrefix(string4);
            if (namespace == null) {
                throw new IllegalAddException(new StringBuffer().append("No such namespace prefix: ").append(string4).append(" is in scope on: ").append((Object)this).append(" so cannot add element: ").append(string2).toString());
            }
        } else {
            namespace = this.getNamespaceForPrefix("");
        }
        Element element = namespace != null ? documentFactory.createElement(documentFactory.createQName(string3, namespace)) : documentFactory.createElement(string2);
        this.addNewNode(element);
        return element;
    }

    @Override
    public Element addEntity(String string2, String string3) {
        this.addNewNode(this.getDocumentFactory().createEntity(string2, string3));
        return this;
    }

    @Override
    public Element addNamespace(String string2, String string3) {
        this.addNewNode(this.getDocumentFactory().createNamespace(string2, string3));
        return this;
    }

    protected void addNewNode(int n, Node node) {
        this.contentList().add(n, (Object)node);
        this.childAdded(node);
    }

    protected void addNewNode(Node node) {
        this.contentList().add((Object)node);
        this.childAdded(node);
    }

    @Override
    protected void addNode(int n, Node node) {
        if (node.getParent() != null) {
            throw new IllegalAddException((Element)this, node, new StringBuffer().append("The Node already has an existing parent of \"").append(node.getParent().getQualifiedName()).append("\"").toString());
        }
        this.addNewNode(n, node);
    }

    @Override
    protected void addNode(Node node) {
        if (node.getParent() != null) {
            throw new IllegalAddException((Element)this, node, new StringBuffer().append("The Node already has an existing parent of \"").append(node.getParent().getQualifiedName()).append("\"").toString());
        }
        this.addNewNode(node);
    }

    @Override
    public Element addProcessingInstruction(String string2, String string3) {
        this.addNewNode(this.getDocumentFactory().createProcessingInstruction(string2, string3));
        return this;
    }

    @Override
    public Element addProcessingInstruction(String string2, Map map) {
        this.addNewNode(this.getDocumentFactory().createProcessingInstruction(string2, map));
        return this;
    }

    @Override
    public Element addText(String string2) {
        this.addNewNode(this.getDocumentFactory().createText(string2));
        return this;
    }

    @Override
    public List additionalNamespaces() {
        List list = this.contentList();
        int n = list.size();
        BackedList backedList = this.createResultList();
        for (int i = 0; i < n; ++i) {
            Namespace namespace;
            Object object = list.get(i);
            if (!(object instanceof Namespace) || (namespace = (Namespace)object).equals(this.getNamespace())) continue;
            backedList.addLocal(namespace);
        }
        return backedList;
    }

    public List additionalNamespaces(String string2) {
        List list = this.contentList();
        BackedList backedList = this.createResultList();
        int n = list.size();
        for (int i = 0; i < n; ++i) {
            Namespace namespace;
            Object object = list.get(i);
            if (!(object instanceof Namespace) || string2.equals((Object)(namespace = (Namespace)object).getURI())) continue;
            backedList.addLocal(namespace);
        }
        return backedList;
    }

    /*
     * Enabled aggressive block sorting
     */
    @Override
    public void appendAttributes(Element element) {
        int n = 0;
        int n2 = element.attributeCount();
        while (n < n2) {
            Attribute attribute = element.attribute(n);
            if (attribute.supportsParent()) {
                this.addAttribute(attribute.getQName(), attribute.getValue());
            } else {
                this.add(attribute);
            }
            ++n;
        }
        return;
    }

    @Override
    public String asXML() {
        try {
            StringWriter stringWriter = new StringWriter();
            XMLWriter xMLWriter = new XMLWriter((Writer)stringWriter, new OutputFormat());
            xMLWriter.write(this);
            xMLWriter.flush();
            String string2 = stringWriter.toString();
            return string2;
        }
        catch (IOException var3_4) {
            throw new RuntimeException(new StringBuffer().append("IOException while generating textual representation: ").append(var3_4.getMessage()).toString());
        }
    }

    @Override
    public Attribute attribute(int n) {
        return (Attribute)this.attributeList().get(n);
    }

    @Override
    public Attribute attribute(String string2) {
        List list = this.attributeList();
        int n = list.size();
        for (int i = 0; i < n; ++i) {
            Attribute attribute = (Attribute)list.get(i);
            if (!string2.equals((Object)attribute.getName())) continue;
            return attribute;
        }
        return null;
    }

    public Attribute attribute(String string2, Namespace namespace) {
        return this.attribute(this.getDocumentFactory().createQName(string2, namespace));
    }

    @Override
    public Attribute attribute(QName qName) {
        List list = this.attributeList();
        int n = list.size();
        for (int i = 0; i < n; ++i) {
            Attribute attribute = (Attribute)list.get(i);
            if (!qName.equals(attribute.getQName())) continue;
            return attribute;
        }
        return null;
    }

    @Override
    public int attributeCount() {
        return this.attributeList().size();
    }

    @Override
    public Iterator attributeIterator() {
        return this.attributeList().iterator();
    }

    protected abstract List attributeList();

    protected abstract List attributeList(int var1);

    @Override
    public String attributeValue(String string2) {
        Attribute attribute = this.attribute(string2);
        if (attribute == null) {
            return null;
        }
        return attribute.getValue();
    }

    @Override
    public String attributeValue(String string2, String string3) {
        String string4 = this.attributeValue(string2);
        if (string4 != null) {
            return string4;
        }
        return string3;
    }

    @Override
    public String attributeValue(QName qName) {
        Attribute attribute = this.attribute(qName);
        if (attribute == null) {
            return null;
        }
        return attribute.getValue();
    }

    @Override
    public String attributeValue(QName qName, String string2) {
        String string3 = this.attributeValue(qName);
        if (string3 != null) {
            return string3;
        }
        return string2;
    }

    @Override
    public List attributes() {
        return new ContentListFacade(this, this.attributeList());
    }

    @Override
    protected void childAdded(Node node) {
        if (node != null) {
            node.setParent((Element)this);
        }
    }

    @Override
    protected void childRemoved(Node node) {
        if (node != null) {
            node.setParent(null);
            node.setDocument(null);
        }
    }

    protected List createAttributeList() {
        return this.createAttributeList(5);
    }

    protected List createAttributeList(int n) {
        return new ArrayList(n);
    }

    @Override
    public Element createCopy() {
        Element element = this.createElement(this.getQName());
        element.appendAttributes(this);
        element.appendContent((Branch)this);
        return element;
    }

    @Override
    public Element createCopy(String string2) {
        Element element = this.createElement(string2);
        element.appendAttributes((Element)this);
        element.appendContent((Branch)this);
        return element;
    }

    @Override
    public Element createCopy(QName qName) {
        Element element = this.createElement(qName);
        element.appendAttributes((Element)this);
        element.appendContent((Branch)this);
        return element;
    }

    protected Element createElement(String string2) {
        return this.getDocumentFactory().createElement(string2);
    }

    protected Element createElement(QName qName) {
        return this.getDocumentFactory().createElement(qName);
    }

    protected Iterator createSingleIterator(Object object) {
        return new SingleIterator(object);
    }

    @Override
    public List declaredNamespaces() {
        BackedList backedList = this.createResultList();
        List list = this.contentList();
        int n = list.size();
        for (int i = 0; i < n; ++i) {
            Object object = list.get(i);
            if (!(object instanceof Namespace)) continue;
            backedList.addLocal(object);
        }
        return backedList;
    }

    @Override
    public Element element(String string2) {
        List list = this.contentList();
        int n = list.size();
        for (int i = 0; i < n; ++i) {
            Element element;
            Object object = list.get(i);
            if (!(object instanceof Element) || !string2.equals((Object)(element = (Element)object).getName())) continue;
            return element;
        }
        return null;
    }

    public Element element(String string2, Namespace namespace) {
        return this.element(this.getDocumentFactory().createQName(string2, namespace));
    }

    @Override
    public Element element(QName qName) {
        List list = this.contentList();
        int n = list.size();
        for (int i = 0; i < n; ++i) {
            Element element;
            Object object = list.get(i);
            if (!(object instanceof Element) || !qName.equals((element = (Element)object).getQName())) continue;
            return element;
        }
        return null;
    }

    @Override
    public Iterator elementIterator() {
        return this.elements().iterator();
    }

    @Override
    public Iterator elementIterator(String string2) {
        return this.elements(string2).iterator();
    }

    public Iterator elementIterator(String string2, Namespace namespace) {
        return this.elementIterator(this.getDocumentFactory().createQName(string2, namespace));
    }

    @Override
    public Iterator elementIterator(QName qName) {
        return this.elements(qName).iterator();
    }

    @Override
    public String elementText(String string2) {
        Element element = this.element(string2);
        if (element != null) {
            return element.getText();
        }
        return null;
    }

    @Override
    public String elementText(QName qName) {
        Element element = this.element(qName);
        if (element != null) {
            return element.getText();
        }
        return null;
    }

    @Override
    public String elementTextTrim(String string2) {
        Element element = this.element(string2);
        if (element != null) {
            return element.getTextTrim();
        }
        return null;
    }

    @Override
    public String elementTextTrim(QName qName) {
        Element element = this.element(qName);
        if (element != null) {
            return element.getTextTrim();
        }
        return null;
    }

    @Override
    public List elements() {
        List list = this.contentList();
        BackedList backedList = this.createResultList();
        int n = list.size();
        for (int i = 0; i < n; ++i) {
            Object object = list.get(i);
            if (!(object instanceof Element)) continue;
            backedList.addLocal(object);
        }
        return backedList;
    }

    @Override
    public List elements(String string2) {
        List list = this.contentList();
        BackedList backedList = this.createResultList();
        int n = list.size();
        for (int i = 0; i < n; ++i) {
            Element element;
            Object object = list.get(i);
            if (!(object instanceof Element) || !string2.equals((Object)(element = (Element)object).getName())) continue;
            backedList.addLocal(element);
        }
        return backedList;
    }

    public List elements(String string2, Namespace namespace) {
        return this.elements(this.getDocumentFactory().createQName(string2, namespace));
    }

    @Override
    public List elements(QName qName) {
        List list = this.contentList();
        BackedList backedList = this.createResultList();
        int n = list.size();
        for (int i = 0; i < n; ++i) {
            Element element;
            Object object = list.get(i);
            if (!(object instanceof Element) || !qName.equals((element = (Element)object).getQName())) continue;
            backedList.addLocal(element);
        }
        return backedList;
    }

    public void ensureAttributesCapacity(int n) {
        List list;
        if (n > 1 && (list = this.attributeList()) instanceof ArrayList) {
            ((ArrayList)list).ensureCapacity(n);
        }
    }

    @Override
    public Object getData() {
        return this.getText();
    }

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

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

    @Override
    public Namespace getNamespace() {
        return this.getQName().getNamespace();
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    @Override
    public Namespace getNamespaceForPrefix(String string2) {
        Namespace namespace;
        if (string2 == null) {
            string2 = "";
        }
        if (string2.equals((Object)this.getNamespacePrefix())) {
            return this.getNamespace();
        }
        if (string2.equals((Object)"xml")) {
            return Namespace.XML_NAMESPACE;
        }
        List list = this.contentList();
        int n = list.size();
        for (int i = 0; i < n; ++i) {
            Object object = list.get(i);
            if (!(object instanceof Namespace)) continue;
            Namespace namespace2 = (Namespace)object;
            if (string2.equals((Object)namespace2.getPrefix())) return namespace2;
        }
        Element element = this.getParent();
        if (element != null && (namespace = element.getNamespaceForPrefix(string2)) != null) {
            return namespace;
        }
        if (string2 == null) return Namespace.NO_NAMESPACE;
        if (string2.length() > 0) return null;
        return Namespace.NO_NAMESPACE;
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    @Override
    public Namespace getNamespaceForURI(String string2) {
        if (string2 == null) return Namespace.NO_NAMESPACE;
        if (string2.length() <= 0) {
            return Namespace.NO_NAMESPACE;
        }
        if (string2.equals((Object)this.getNamespaceURI())) {
            return this.getNamespace();
        }
        List list = this.contentList();
        int n = list.size();
        int n2 = 0;
        while (n2 < n) {
            Object object = list.get(n2);
            if (object instanceof Namespace) {
                Namespace namespace = (Namespace)object;
                if (string2.equals((Object)namespace.getURI())) return namespace;
            }
            ++n2;
        }
        return null;
    }

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

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

    @Override
    public List getNamespacesForURI(String string2) {
        BackedList backedList = this.createResultList();
        List list = this.contentList();
        int n = list.size();
        for (int i = 0; i < n; ++i) {
            Object object = list.get(i);
            if (!(object instanceof Namespace) || !((Namespace)object).getURI().equals((Object)string2)) continue;
            backedList.addLocal(object);
        }
        return backedList;
    }

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

    @Override
    public String getPath(Element element) {
        if (this == element) {
            return ".";
        }
        Element element2 = this.getParent();
        if (element2 == null) {
            return new StringBuffer().append("/").append(this.getXPathNameStep()).toString();
        }
        if (element2 == element) {
            return this.getXPathNameStep();
        }
        return new StringBuffer().append(element2.getPath(element)).append("/").append(this.getXPathNameStep()).toString();
    }

    @Override
    public QName getQName(String string2) {
        Namespace namespace;
        String string3 = "";
        String string4 = string2;
        int n = string2.indexOf(":");
        if (n > 0) {
            string3 = string2.substring(0, n);
            string4 = string2.substring(n + 1);
        }
        if ((namespace = this.getNamespaceForPrefix(string3)) != null) {
            return this.getDocumentFactory().createQName(string4, namespace);
        }
        return this.getDocumentFactory().createQName(string4);
    }

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

    @Override
    public String getStringValue() {
        List list = this.contentList();
        int n = list.size();
        if (n > 0) {
            if (n == 1) {
                return this.getContentAsStringValue(list.get(0));
            }
            StringBuffer stringBuffer = new StringBuffer();
            for (int i = 0; i < n; ++i) {
                String string2 = this.getContentAsStringValue(list.get(i));
                if (string2.length() <= 0) continue;
                stringBuffer.append(string2);
            }
            return stringBuffer.toString();
        }
        return "";
    }

    @Override
    public String getUniquePath(Element element) {
        int n;
        Element element2 = this.getParent();
        if (element2 == null) {
            return new StringBuffer().append("/").append(this.getXPathNameStep()).toString();
        }
        StringBuffer stringBuffer = new StringBuffer();
        if (element2 != element) {
            stringBuffer.append(element2.getUniquePath(element));
            stringBuffer.append("/");
        }
        stringBuffer.append(this.getXPathNameStep());
        List list = element2.elements(this.getQName());
        if (list.size() > 1 && (n = list.indexOf((Object)this)) >= 0) {
            stringBuffer.append("[");
            stringBuffer.append(Integer.toString((int)(n + 1)));
            stringBuffer.append("]");
        }
        return stringBuffer.toString();
    }

    public String getXPathNameStep() {
        String string2 = this.getNamespaceURI();
        if (string2 == null || string2.length() == 0) {
            return this.getName();
        }
        String string3 = this.getNamespacePrefix();
        if (string3 == null || string3.length() == 0) {
            return new StringBuffer().append("*[name()='").append(this.getName()).append("']").toString();
        }
        return this.getQualifiedName();
    }

    @Override
    public Node getXPathResult(int n) {
        Node node = this.node(n);
        if (node != null && !node.supportsParent()) {
            node = node.asXPathResult((Element)this);
        }
        return node;
    }

    /*
     * Enabled aggressive block sorting
     */
    @Override
    public boolean hasMixedContent() {
        List list = this.contentList();
        if (list != null && !list.isEmpty() && list.size() >= 2) {
            Class class_ = null;
            Iterator iterator = list.iterator();
            while (iterator.hasNext()) {
                Class class_2 = iterator.next().getClass();
                if (class_2 == class_) continue;
                if (class_ != null) {
                    return true;
                }
                class_ = class_2;
            }
        }
        return false;
    }

    @Override
    public int indexOf(Node node) {
        return this.contentList().indexOf((Object)node);
    }

    @Override
    public boolean isRootElement() {
        Document document = this.getDocument();
        if (document != null && document.getRootElement() == this) {
            return true;
        }
        return false;
    }

    /*
     * Enabled aggressive block sorting
     * Lifted jumps to return sites
     */
    @Override
    public boolean isTextOnly() {
        Object object;
        List list = this.contentList();
        if (list == null) return true;
        if (list.isEmpty()) {
            return true;
        }
        Iterator iterator = list.iterator();
        do {
            if (!iterator.hasNext()) return true;
        } while ((object = iterator.next()) instanceof CharacterData || object instanceof String);
        return false;
    }

    @Override
    public Node node(int n) {
        if (n >= 0) {
            List list = this.contentList();
            if (n >= list.size()) {
                return null;
            }
            Object object = list.get(n);
            if (object != null) {
                if (object instanceof Node) {
                    return (Node)object;
                }
                return this.getDocumentFactory().createText(object.toString());
            }
        }
        return null;
    }

    @Override
    public int nodeCount() {
        return this.contentList().size();
    }

    @Override
    public Iterator nodeIterator() {
        return this.contentList().iterator();
    }

    @Override
    public void normalize() {
        List list = this.contentList();
        Text text = null;
        int n = 0;
        while (n < list.size()) {
            Node node = (Node)list.get(n);
            if (node instanceof Text) {
                Text text2 = (Text)node;
                if (text != null) {
                    text.appendText(text2.getText());
                    this.remove(text2);
                    continue;
                }
                String string2 = text2.getText();
                if (string2 == null || string2.length() <= 0) {
                    this.remove(text2);
                    continue;
                }
                text = text2;
                ++n;
                continue;
            }
            if (node instanceof Element) {
                ((Element)node).normalize();
            }
            ++n;
            text = null;
        }
    }

    @Override
    public ProcessingInstruction processingInstruction(String string2) {
        List list = this.contentList();
        int n = list.size();
        for (int i = 0; i < n; ++i) {
            ProcessingInstruction processingInstruction;
            Object object = list.get(i);
            if (!(object instanceof ProcessingInstruction) || !string2.equals((Object)(processingInstruction = (ProcessingInstruction)object).getName())) continue;
            return processingInstruction;
        }
        return null;
    }

    @Override
    public List processingInstructions() {
        List list = this.contentList();
        BackedList backedList = this.createResultList();
        int n = list.size();
        for (int i = 0; i < n; ++i) {
            Object object = list.get(i);
            if (!(object instanceof ProcessingInstruction)) continue;
            backedList.addLocal(object);
        }
        return backedList;
    }

    @Override
    public List processingInstructions(String string2) {
        List list = this.contentList();
        BackedList backedList = this.createResultList();
        int n = list.size();
        for (int i = 0; i < n; ++i) {
            ProcessingInstruction processingInstruction;
            Object object = list.get(i);
            if (!(object instanceof ProcessingInstruction) || !string2.equals((Object)(processingInstruction = (ProcessingInstruction)object).getName())) continue;
            backedList.addLocal(processingInstruction);
        }
        return backedList;
    }

    /*
     * Enabled aggressive block sorting
     */
    @Override
    public boolean remove(Attribute attribute) {
        List list = this.attributeList();
        boolean bl = list.remove((Object)attribute);
        if (bl) {
            this.childRemoved(attribute);
            return bl;
        } else {
            Attribute attribute2 = this.attribute(attribute.getQName());
            if (attribute2 == null) return bl;
            {
                list.remove((Object)attribute2);
                return true;
            }
        }
    }

    @Override
    public boolean remove(CDATA cDATA) {
        return this.removeNode(cDATA);
    }

    @Override
    public boolean remove(Comment comment) {
        return this.removeNode(comment);
    }

    @Override
    public boolean remove(Element element) {
        return this.removeNode(element);
    }

    @Override
    public boolean remove(Entity entity) {
        return this.removeNode(entity);
    }

    @Override
    public boolean remove(Namespace namespace) {
        return this.removeNode(namespace);
    }

    @Override
    public boolean remove(Node node) {
        switch (node.getNodeType()) {
            default: {
                return false;
            }
            case 1: {
                return this.remove((Element)node);
            }
            case 2: {
                return this.remove((Attribute)node);
            }
            case 3: {
                return this.remove((Text)node);
            }
            case 4: {
                return this.remove((CDATA)node);
            }
            case 5: {
                return this.remove((Entity)node);
            }
            case 7: {
                return this.remove((ProcessingInstruction)node);
            }
            case 8: {
                return this.remove((Comment)node);
            }
            case 13: 
        }
        return this.remove((Namespace)node);
    }

    @Override
    public boolean remove(ProcessingInstruction processingInstruction) {
        return this.removeNode(processingInstruction);
    }

    @Override
    public boolean remove(Text text) {
        return this.removeNode(text);
    }

    @Override
    protected boolean removeNode(Node node) {
        boolean bl = this.contentList().remove((Object)node);
        if (bl) {
            this.childRemoved(node);
        }
        return bl;
    }

    @Override
    public boolean removeProcessingInstruction(String string2) {
        Iterator iterator = this.contentList().iterator();
        while (iterator.hasNext()) {
            Object object = iterator.next();
            if (!(object instanceof ProcessingInstruction) || !string2.equals((Object)((ProcessingInstruction)object).getName())) continue;
            iterator.remove();
            return true;
        }
        return false;
    }

    @Override
    public void setAttributeValue(String string2, String string3) {
        this.addAttribute(string2, string3);
    }

    @Override
    public void setAttributeValue(QName qName, String string2) {
        this.addAttribute(qName, string2);
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    public void setAttributes(Attributes attributes, NamespaceStack namespaceStack, boolean bl) {
        int n = attributes.getLength();
        if (n <= 0) return;
        DocumentFactory documentFactory = this.getDocumentFactory();
        if (n == 1) {
            String string2 = attributes.getQName(0);
            if (!bl && string2.startsWith("xmlns")) return;
            String string3 = attributes.getURI(0);
            String string4 = attributes.getLocalName(0);
            String string5 = attributes.getValue(0);
            this.add(documentFactory.createAttribute((Element)this, namespaceStack.getAttributeQName(string3, string4, string2), string5));
            return;
        }
        List list = this.attributeList(n);
        list.clear();
        int n2 = 0;
        while (n2 < n) {
            String string6 = attributes.getQName(n2);
            if (bl || !string6.startsWith("xmlns")) {
                String string7 = attributes.getURI(n2);
                String string8 = attributes.getLocalName(n2);
                String string9 = attributes.getValue(n2);
                Attribute attribute = documentFactory.createAttribute((Element)this, namespaceStack.getAttributeQName(string7, string8, string6), string9);
                list.add((Object)attribute);
                this.childAdded(attribute);
            }
            ++n2;
        }
    }

    @Override
    public void setData(Object object) {
    }

    @Override
    public void setName(String string2) {
        this.setQName(this.getDocumentFactory().createQName(string2));
    }

    public void setNamespace(Namespace namespace) {
        this.setQName(this.getDocumentFactory().createQName(this.getName(), namespace));
    }

    @Override
    public void setText(String string2) {
        List list = this.contentList();
        if (list != null) {
            Iterator iterator = list.iterator();
            block3 : while (iterator.hasNext()) {
                switch (((Node)iterator.next()).getNodeType()) {
                    default: {
                        continue block3;
                    }
                    case 3: 
                    case 4: 
                    case 5: 
                }
                iterator.remove();
            }
        }
        this.addText(string2);
    }

    public String toString() {
        String string2 = this.getNamespaceURI();
        if (string2 != null && string2.length() > 0) {
            return new StringBuffer().append(super.toString()).append(" [Element: <").append(this.getQualifiedName()).append(" uri: ").append(string2).append(" attributes: ").append((Object)this.attributeList()).append("/>]").toString();
        }
        return new StringBuffer().append(super.toString()).append(" [Element: <").append(this.getQualifiedName()).append(" attributes: ").append((Object)this.attributeList()).append("/>]").toString();
    }

    @Override
    public void write(Writer writer) throws IOException {
        new XMLWriter(writer, new OutputFormat()).write((Element)this);
    }
}

