FileDocCategorySizeDatePackage
FieldIdsSection.javaAPI DocAndroid 5.1 API3740Thu Mar 12 22:18:30 GMT 2015com.android.dx.dex.file

FieldIdsSection

public final class FieldIdsSection extends MemberIdsSection
Field refs list section of a {@code .dex} file.

Fields Summary
private final TreeMap
fieldIds
{@code non-null;} map from field constants to {@link FieldIdItem} instances
Constructors Summary
public FieldIdsSection(DexFile file)
Constructs an instance. The file offset is initially unknown.

param
file {@code non-null;} file that this instance is part of

        super("field_ids", file);

        fieldIds = new TreeMap<CstFieldRef, FieldIdItem>();
    
Methods Summary
public IndexedItemget(com.android.dx.rop.cst.Constant cst)
{@inheritDoc}

        if (cst == null) {
            throw new NullPointerException("cst == null");
        }

        throwIfNotPrepared();

        IndexedItem result = fieldIds.get((CstFieldRef) cst);

        if (result == null) {
            throw new IllegalArgumentException("not found");
        }

        return result;
    
public intindexOf(com.android.dx.rop.cst.CstFieldRef ref)
Gets the index of the given reference, which must have been added to this instance.

param
ref {@code non-null;} the reference to look up
return
{@code >= 0;} the reference's index

        if (ref == null) {
            throw new NullPointerException("ref == null");
        }

        throwIfNotPrepared();

        FieldIdItem item = fieldIds.get(ref);

        if (item == null) {
            throw new IllegalArgumentException("not found");
        }

        return item.getIndex();
    
public synchronized FieldIdItemintern(com.android.dx.rop.cst.CstFieldRef field)
Interns an element into this instance.

param
field {@code non-null;} the reference to intern
return
{@code non-null;} the interned reference

        if (field == null) {
            throw new NullPointerException("field == null");
        }

        throwIfPrepared();

        FieldIdItem result = fieldIds.get(field);

        if (result == null) {
            result = new FieldIdItem(field);
            fieldIds.put(field, result);
        }

        return result;
    
public java.util.Collectionitems()
{@inheritDoc}

        return fieldIds.values();
    
public voidwriteHeaderPart(com.android.dx.util.AnnotatedOutput out)
Writes the portion of the file header that refers to this instance.

param
out {@code non-null;} where to write

        throwIfNotPrepared();

        int sz = fieldIds.size();
        int offset = (sz == 0) ? 0 : getFileOffset();

        if (out.annotates()) {
            out.annotate(4, "field_ids_size:  " + Hex.u4(sz));
            out.annotate(4, "field_ids_off:   " + Hex.u4(offset));
        }

        out.writeInt(sz);
        out.writeInt(offset);