FileDocCategorySizeDatePackage
MethodIdsSection.javaAPI DocAndroid 5.1 API3804Thu Mar 12 22:18:30 GMT 2015com.android.dexgen.dex.file

MethodIdsSection

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

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

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

        super("method_ids", file);

        methodIds = new TreeMap<CstBaseMethodRef, MethodIdItem>();
    
Methods Summary
public IndexedItemget(com.android.dexgen.rop.cst.Constant cst)
{@inheritDoc}

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

        throwIfNotPrepared();

        IndexedItem result = methodIds.get((CstBaseMethodRef) cst);

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

        return result;
    
public intindexOf(com.android.dexgen.rop.cst.CstBaseMethodRef 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();

        MethodIdItem item = methodIds.get(ref);

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

        return item.getIndex();
    
public MethodIdItemintern(com.android.dexgen.rop.cst.CstBaseMethodRef method)
Interns an element into this instance.

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

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

        throwIfPrepared();

        MethodIdItem result = methodIds.get(method);

        if (result == null) {
            result = new MethodIdItem(method);
            methodIds.put(method, result);
        }

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

        return methodIds.values();
    
public voidwriteHeaderPart(com.android.dexgen.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 = methodIds.size();
        int offset = (sz == 0) ? 0 : getFileOffset();

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

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