FileDocCategorySizeDatePackage
MemberIdItem.javaAPI DocAndroid 1.5 API3430Wed May 06 22:41:02 BST 2009com.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
public static final int
WRITE_SIZE
size of instances when written out to a file, in bytes
private final com.android.dx.rop.cst.CstMemberRef
cst
non-null; the constant for the member
Constructors Summary
public MemberIdItem(com.android.dx.rop.cst.CstMemberRef cst)
Constructs an instance.

param
cst 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
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 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
non-null; the name in question

public intwriteSize()
{@inheritDoc}

        return WRITE_SIZE;
    
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);