/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  java.lang.Class
 *  java.lang.Object
 *  java.lang.String
 *  java.lang.UnsupportedOperationException
 *  java.util.AbstractList
 */
package org.dom4j.bean;

import java.util.AbstractList;
import org.dom4j.Attribute;
import org.dom4j.QName;
import org.dom4j.bean.BeanAttribute;
import org.dom4j.bean.BeanElement;
import org.dom4j.bean.BeanMetaData;

public class BeanAttributeList
extends AbstractList {
    private BeanAttribute[] attributes;
    private BeanMetaData beanMetaData;
    private BeanElement parent;

    /*
     * Enabled aggressive block sorting
     */
    public BeanAttributeList(BeanElement beanElement) {
        this.parent = beanElement;
        Object object = beanElement.getData();
        Class class_ = object != null ? object.getClass() : null;
        this.beanMetaData = BeanMetaData.get(class_);
        this.attributes = new BeanAttribute[this.beanMetaData.attributeCount()];
    }

    public BeanAttributeList(BeanElement beanElement, BeanMetaData beanMetaData) {
        this.parent = beanElement;
        this.beanMetaData = beanMetaData;
        this.attributes = new BeanAttribute[beanMetaData.attributeCount()];
    }

    public void add(int n, Object object) {
        throw new UnsupportedOperationException("add(int,Object) unsupported");
    }

    public boolean add(Object object) {
        throw new UnsupportedOperationException("add(Object) unsupported");
    }

    public Attribute attribute(String string2) {
        return this.attribute(this.beanMetaData.getIndex(string2));
    }

    public Attribute attribute(QName qName) {
        return this.attribute(this.beanMetaData.getIndex(qName));
    }

    public BeanAttribute attribute(int n) {
        if (n >= 0 && n <= this.attributes.length) {
            BeanAttribute beanAttribute = this.attributes[n];
            if (beanAttribute == null) {
                this.attributes[n] = beanAttribute = this.createAttribute(this.parent, n);
            }
            return beanAttribute;
        }
        return null;
    }

    public void clear() {
        for (BeanAttribute beanAttribute : this.attributes) {
            if (beanAttribute == null) continue;
            beanAttribute.setValue(null);
        }
    }

    protected BeanAttribute createAttribute(BeanElement beanElement, int n) {
        return new BeanAttribute((BeanAttributeList)this, n);
    }

    public Object get(int n) {
        BeanAttribute beanAttribute = this.attributes[n];
        if (beanAttribute == null) {
            this.attributes[n] = beanAttribute = this.createAttribute(this.parent, n);
        }
        return beanAttribute;
    }

    public Object getData(int n) {
        return this.beanMetaData.getData(n, this.parent.getData());
    }

    public BeanElement getParent() {
        return this.parent;
    }

    public QName getQName(int n) {
        return this.beanMetaData.getQName(n);
    }

    public Object remove(int n) {
        BeanAttribute beanAttribute = (BeanAttribute)this.get(n);
        String string2 = beanAttribute.getValue();
        beanAttribute.setValue(null);
        return string2;
    }

    public boolean remove(Object object) {
        return false;
    }

    public Object set(int n, Object object) {
        throw new UnsupportedOperationException("set(int,Object) unsupported");
    }

    public void setData(int n, Object object) {
        this.beanMetaData.setData(n, this.parent.getData(), object);
    }

    public int size() {
        return this.attributes.length;
    }
}

