FileDocCategorySizeDatePackage
StdAttributeList.javaAPI DocAndroid 5.1 API2673Thu Mar 12 22:18:30 GMT 2015com.android.dexgen.rop

StdAttributeList

public final class StdAttributeList extends com.android.dexgen.util.FixedSizeList implements AttributeList
Standard implementation of {@link AttributeList}, which directly stores an array of {@link Attribute} objects and can be made immutable.

Fields Summary
Constructors Summary
public StdAttributeList(int size)
Constructs an instance. All indices initially contain {@code null}.

param
size the size of the list

        super(size);
    
Methods Summary
public intbyteLength()
{@inheritDoc}

        int sz = size();
        int result = 2; // u2 attributes_count

        for (int i = 0; i < sz; i++) {
            result += get(i).byteLength();
        }

        return result;
    
public AttributefindFirst(java.lang.String name)
{@inheritDoc}

        int sz = size();

        for (int i = 0; i < sz; i++) {
            Attribute att = get(i);
            if (att.getName().equals(name)) {
                return att;
            }
        }

        return null;
    
public AttributefindNext(Attribute attrib)
{@inheritDoc}

        int sz = size();
        int at;

        outer: {
            for (at = 0; at < sz; at++) {
                Attribute att = get(at);
                if (att == attrib) {
                    break outer;
                }
            }

            return null;
        }

        String name = attrib.getName();

        for (at++; at < sz; at++) {
            Attribute att = get(at);
            if (att.getName().equals(name)) {
                return att;
            }
        }

        return null;
    
public Attributeget(int n)
{@inheritDoc}

        return (Attribute) get0(n);
    
public voidset(int n, Attribute attribute)
Sets the attribute at the given index.

param
n {@code >= 0, < size();} which attribute
param
attribute {@code null-ok;} the attribute object

        set0(n, attribute);