/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  java.lang.Object
 *  java.lang.String
 *  java.util.ArrayList
 *  java.util.Iterator
 *  java.util.List
 *  org.gjt.xpp.XmlPullParserException
 *  org.gjt.xpp.XmlStartTag
 */
package org.dom4j.xpp;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.dom4j.Attribute;
import org.dom4j.DocumentFactory;
import org.dom4j.Element;
import org.dom4j.QName;
import org.dom4j.tree.AbstractElement;
import org.gjt.xpp.XmlPullParserException;
import org.gjt.xpp.XmlStartTag;

public class ProxyXmlStartTag
implements XmlStartTag {
    private Element element;
    private DocumentFactory factory;

    public ProxyXmlStartTag() {
        this.factory = DocumentFactory.getInstance();
    }

    public ProxyXmlStartTag(Element element) {
        this.factory = DocumentFactory.getInstance();
        this.element = element;
    }

    public void addAttribute(String string2, String string3, String string4, String string5) throws XmlPullParserException {
        QName qName = QName.get(string4, string2);
        this.element.addAttribute(qName, string5);
    }

    public void addAttribute(String string2, String string3, String string4, String string5, boolean bl) throws XmlPullParserException {
        if (bl) {
            String string6 = "";
            int n = string4.indexOf(58);
            if (n > 0) {
                string6 = string4.substring(0, n);
            }
            this.element.addNamespace(string6, string2);
            return;
        }
        QName qName = QName.get(string4, string2);
        this.element.addAttribute(qName, string5);
    }

    public void ensureAttributesCapacity(int n) throws XmlPullParserException {
        if (this.element instanceof AbstractElement) {
            ((AbstractElement)this.element).ensureAttributesCapacity(n);
        }
    }

    public int getAttributeCount() {
        if (this.element != null) {
            return this.element.attributeCount();
        }
        return 0;
    }

    public String getAttributeLocalName(int n) {
        Attribute attribute;
        if (this.element != null && (attribute = this.element.attribute(n)) != null) {
            return attribute.getName();
        }
        return null;
    }

    public String getAttributeNamespaceUri(int n) {
        Attribute attribute;
        if (this.element != null && (attribute = this.element.attribute(n)) != null) {
            return attribute.getNamespaceURI();
        }
        return null;
    }

    public String getAttributePrefix(int n) {
        Attribute attribute;
        String string2;
        if (this.element != null && (attribute = this.element.attribute(n)) != null && (string2 = attribute.getNamespacePrefix()) != null && string2.length() > 0) {
            return string2;
        }
        return null;
    }

    public String getAttributeRawName(int n) {
        Attribute attribute;
        if (this.element != null && (attribute = this.element.attribute(n)) != null) {
            return attribute.getQualifiedName();
        }
        return null;
    }

    public String getAttributeValue(int n) {
        Attribute attribute;
        if (this.element != null && (attribute = this.element.attribute(n)) != null) {
            return attribute.getValue();
        }
        return null;
    }

    public String getAttributeValueFromName(String string2, String string3) {
        if (this.element != null) {
            Iterator iterator = this.element.attributeIterator();
            while (iterator.hasNext()) {
                Attribute attribute = (Attribute)iterator.next();
                if (!string2.equals((Object)attribute.getNamespaceURI()) || !string3.equals((Object)attribute.getName())) continue;
                return attribute.getValue();
            }
        }
        return null;
    }

    public String getAttributeValueFromRawName(String string2) {
        if (this.element != null) {
            Iterator iterator = this.element.attributeIterator();
            while (iterator.hasNext()) {
                Attribute attribute = (Attribute)iterator.next();
                if (!string2.equals((Object)attribute.getQualifiedName())) continue;
                return attribute.getValue();
            }
        }
        return null;
    }

    public DocumentFactory getDocumentFactory() {
        return this.factory;
    }

    public Element getElement() {
        return this.element;
    }

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

    public String getNamespaceUri() {
        return this.element.getNamespaceURI();
    }

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

    public String getRawName() {
        return this.element.getQualifiedName();
    }

    public boolean isAttributeNamespaceDeclaration(int n) {
        Attribute attribute;
        if (this.element != null && (attribute = this.element.attribute(n)) != null) {
            return "xmlns".equals((Object)attribute.getNamespacePrefix());
        }
        return false;
    }

    public void modifyTag(String string2, String string3, String string4) {
        this.element = this.factory.createElement(string4, string2);
    }

    public boolean removeAttributeByName(String string2, String string3) throws XmlPullParserException {
        if (this.element != null) {
            QName qName = QName.get(string3, string2);
            Attribute attribute = this.element.attribute(qName);
            return this.element.remove(attribute);
        }
        return false;
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    public boolean removeAttributeByRawName(String string2) throws XmlPullParserException {
        Attribute attribute;
        Attribute attribute2;
        if (this.element == null) return false;
        Iterator iterator = this.element.attributeIterator();
        do {
            boolean bl = iterator.hasNext();
            attribute = null;
            if (!bl) return this.element.remove(attribute);
        } while (!(attribute2 = (Attribute)iterator.next()).getQualifiedName().equals((Object)string2));
        attribute = attribute2;
        return this.element.remove(attribute);
    }

    public void removeAttributes() throws XmlPullParserException {
        if (this.element != null) {
            this.element.setAttributes((List)new ArrayList());
        }
    }

    public void removeAtttributes() throws XmlPullParserException {
        this.removeAttributes();
    }

    public void resetStartTag() {
        this.element = null;
    }

    public void resetTag() {
        this.element = null;
    }

    public void setDocumentFactory(DocumentFactory documentFactory) {
        this.factory = documentFactory;
    }
}

