FileDocCategorySizeDatePackage
EncodedField.javaAPI DocAndroid 1.5 API4307Wed May 06 22:41:02 BST 2009com.android.dx.dex.file

EncodedField

public final class EncodedField extends EncodedMember implements Comparable
Representation of a field of a class, of any sort.

Fields Summary
private final com.android.dx.rop.cst.CstFieldRef
field
non-null; constant for the field
Constructors Summary
public EncodedField(com.android.dx.rop.cst.CstFieldRef field, int accessFlags)
Constructs an instance.

param
field non-null; constant for the field
param
accessFlags access flags

        super(accessFlags);

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

        /*
         * TODO: Maybe check accessFlags, at least for
         * easily-checked stuff?
         */

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

        FieldIdsSection fieldIds = file.getFieldIds();
        fieldIds.intern(field);
    
public intcompareTo(com.android.dx.dex.file.EncodedField other)
{@inheritDoc}

Note: This compares the method constants only, ignoring any associated code, because it should never be the case that two different items with the same method constant ever appear in the same list (or same file, even).

        return field.compareTo(other.field);
    
public voiddebugPrint(java.io.PrintWriter out, boolean verbose)
{@inheritDoc}

        // TODO: Maybe put something better here?
        out.println(toString());
    
public intencode(DexFile file, com.android.dx.util.AnnotatedOutput out, int lastIndex, int dumpSeq)
{@inheritDoc}

        int fieldIdx = file.getFieldIds().indexOf(field);
        int diff = fieldIdx - lastIndex;
        int accessFlags = getAccessFlags();

        if (out.annotates()) {
            out.annotate(0, String.format("  [%x] %s", dumpSeq,
                            field.toHuman()));
            out.annotate(Leb128Utils.unsignedLeb128Size(diff),
                    "    field_idx:    " + Hex.u4(fieldIdx));
            out.annotate(Leb128Utils.unsignedLeb128Size(accessFlags),
                    "    access_flags: " +
                    AccessFlags.fieldString(accessFlags));
        }

        out.writeUnsignedLeb128(diff);
        out.writeUnsignedLeb128(accessFlags);

        return fieldIdx;
    
public booleanequals(java.lang.Object other)
{@inheritDoc}

        if (! (other instanceof EncodedField)) {
            return false;
        }

        return compareTo((EncodedField) other) == 0;
    
public com.android.dx.rop.cst.CstUtf8getName()
{@inheritDoc}

        return field.getNat().getName();
    
public com.android.dx.rop.cst.CstFieldRefgetRef()
Gets the constant for the field.

return
non-null; the constant

        return field;
    
public inthashCode()
{@inheritDoc}

        return field.hashCode();
    
public java.lang.StringtoHuman()
{@inheritDoc}

        return field.toHuman();
    
public java.lang.StringtoString()
{@inheritDoc}

        StringBuffer sb = new StringBuffer(100);

        sb.append(getClass().getName());
        sb.append('{");
        sb.append(Hex.u2(getAccessFlags()));
        sb.append(' ");
        sb.append(field);
        sb.append('}");
        return sb.toString();