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

FieldAnnotationStruct

public final class FieldAnnotationStruct extends Object implements com.android.dx.util.ToHuman, Comparable
Association of a field and its annotations.

Fields Summary
private final com.android.dx.rop.cst.CstFieldRef
field
{@code non-null;} the field in question
private AnnotationSetItem
annotations
{@code non-null;} the associated annotations
Constructors Summary
public FieldAnnotationStruct(com.android.dx.rop.cst.CstFieldRef field, AnnotationSetItem annotations)
Constructs an instance.

param
field {@code non-null;} the field in question
param
annotations {@code non-null;} the associated annotations

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

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

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

        FieldIdsSection fieldIds = file.getFieldIds();
        MixedItemSection wordData = file.getWordData();

        fieldIds.intern(field);
        annotations = wordData.intern(annotations);
    
public intcompareTo(com.android.dx.dex.file.FieldAnnotationStruct other)
{@inheritDoc}

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

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

        return field.equals(((FieldAnnotationStruct) other).field);
    
public com.android.dx.rop.annotation.AnnotationsgetAnnotations()
Gets the associated annotations.

return
{@code non-null;} the annotations

        return annotations.getAnnotations();
    
public com.android.dx.rop.cst.CstFieldRefgetField()
Gets the field this item is for.

return
{@code non-null;} the field

        return field;
    
public inthashCode()
{@inheritDoc}

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

        return field.toHuman() + ": " + annotations;
    
public voidwriteTo(DexFile file, com.android.dx.util.AnnotatedOutput out)
{@inheritDoc}

        int fieldIdx = file.getFieldIds().indexOf(field);
        int annotationsOff = annotations.getAbsoluteOffset();

        if (out.annotates()) {
            out.annotate(0, "    " + field.toHuman());
            out.annotate(4, "      field_idx:       " + Hex.u4(fieldIdx));
            out.annotate(4, "      annotations_off: " +
                    Hex.u4(annotationsOff));
        }

        out.writeInt(fieldIdx);
        out.writeInt(annotationsOff);