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

MemberIdItem

public abstract class MemberIdItem extends IdItem
Representation of a member (field or method) reference inside a Dalvik file.

Fields Summary
private final com.android.dx.rop.cst.CstMemberRef
cst
{@code non-null;} the constant for the member
Constructors Summary
public MemberIdItem(com.android.dx.rop.cst.CstMemberRef cst)
Constructs an instance.

param
cst {@code non-null;} the constant for the member

        super(cst.getDefiningClass());

        this.cst = cst;
    
Methods Summary
public voidaddContents(DexFile file)
{@inheritDoc}

        super.addContents(file);

        StringIdsSection stringIds = file.getStringIds();
        stringIds.intern(getRef().getNat().getName());
    
public final com.android.dx.rop.cst.CstMemberRefgetRef()
Gets the member constant.

return
{@code non-null;} the constant

        return cst;
    
protected abstract intgetTypoidIdx(DexFile file)
Returns the index of the type-like thing associated with this item, in order that it may be written out. Subclasses must override this to get whatever it is they need to store.

param
file {@code non-null;} the file being written
return
the index in question

protected abstract java.lang.StringgetTypoidName()
Returns the field name of the type-like thing associated with this item, for listing-generating purposes. Subclasses must override this.

return
{@code non-null;} the name in question

public intwriteSize()
{@inheritDoc}

        return SizeOf.MEMBER_ID_ITEM;
    
public final voidwriteTo(DexFile file, com.android.dx.util.AnnotatedOutput out)
{@inheritDoc}

        TypeIdsSection typeIds = file.getTypeIds();
        StringIdsSection stringIds = file.getStringIds();
        CstNat nat = cst.getNat();
        int classIdx = typeIds.indexOf(getDefiningClass());
        int nameIdx = stringIds.indexOf(nat.getName());
        int typoidIdx = getTypoidIdx(file);

        if (out.annotates()) {
            out.annotate(0, indexString() + ' " + cst.toHuman());
            out.annotate(2, "  class_idx: " + Hex.u2(classIdx));
            out.annotate(2, String.format("  %-10s %s", getTypoidName() + ':",
                            Hex.u2(typoidIdx)));
            out.annotate(4, "  name_idx:  " + Hex.u4(nameIdx));
        }

        out.writeShort(classIdx);
        out.writeShort(typoidIdx);
        out.writeInt(nameIdx);