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

ProtoIdsSection

public final class ProtoIdsSection extends UniformItemSection
Proto (method prototype) identifiers list section of a {@code .dex} file.

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

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

        super("proto_ids", file, 4);

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

        throw new UnsupportedOperationException("unsupported");
    
public intindexOf(com.android.dx.rop.type.Prototype prototype)
Gets the index of the given prototype, which must have been added to this instance.

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

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

        throwIfNotPrepared();

        ProtoIdItem item = protoIds.get(prototype);

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

        return item.getIndex();
    
public ProtoIdItemintern(com.android.dx.rop.type.Prototype prototype)
Interns an element into this instance.

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

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

        throwIfPrepared();

        ProtoIdItem result = protoIds.get(prototype);

        if (result == null) {
            result = new ProtoIdItem(prototype);
            protoIds.put(prototype, result);
        }

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

        return protoIds.values();
    
protected voidorderItems()
{@inheritDoc}

        int idx = 0;

        for (Object i : items()) {
            ((ProtoIdItem) i).setIndex(idx);
            idx++;
        }
    
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 = protoIds.size();
        int offset = (sz == 0) ? 0 : getFileOffset();

        if (sz > 65536) {
            throw new UnsupportedOperationException("too many proto ids");
        }

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

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