FileDocCategorySizeDatePackage
EncodedField.javaAPI DocAndroid 5.1 API4297Thu Mar 12 22:18:30 GMT 2015com.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
{@code non-null;} constant for the field
Constructors Summary
public EncodedField(com.android.dx.rop.cst.CstFieldRef field, int accessFlags)
Constructs an instance.

param
field {@code 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(Leb128.unsignedLeb128Size(diff),
                    "    field_idx:    " + Hex.u4(fieldIdx));
            out.annotate(Leb128.unsignedLeb128Size(accessFlags),
                    "    access_flags: " +
                    AccessFlags.fieldString(accessFlags));
        }

        out.writeUleb128(diff);
        out.writeUleb128(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.CstStringgetName()
{@inheritDoc}

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

return
{@code 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();