FileDocCategorySizeDatePackage
FieldAnnotationStruct.javaAPI DocAndroid 1.5 API3533Wed May 06 22:41:02 BST 2009com.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
non-null; the field in question
private AnnotationSetItem
annotations
non-null; the associated annotations
Constructors Summary
public FieldAnnotationStruct(com.android.dx.rop.cst.CstFieldRef field, AnnotationSetItem annotations)
Constructs an instance.

param
field non-null; the field in question
param
annotations 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
non-null; the annotations

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

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