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

MethodAnnotationStruct

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

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

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

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

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

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

        MethodIdsSection methodIds = file.getMethodIds();
        MixedItemSection wordData = file.getWordData();

        methodIds.intern(method);
        annotations = wordData.intern(annotations);
    
public intcompareTo(com.android.dx.dex.file.MethodAnnotationStruct other)
{@inheritDoc}

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

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

        return method.equals(((MethodAnnotationStruct) other).method);
    
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.CstMethodRefgetMethod()
Gets the method this item is for.

return
{@code non-null;} the method

        return method;
    
public inthashCode()
{@inheritDoc}

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

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

        int methodIdx = file.getMethodIds().indexOf(method);
        int annotationsOff = annotations.getAbsoluteOffset();

        if (out.annotates()) {
            out.annotate(0, "    " + method.toHuman());
            out.annotate(4, "      method_idx:      " + Hex.u4(methodIdx));
            out.annotate(4, "      annotations_off: " +
                    Hex.u4(annotationsOff));
        }

        out.writeInt(methodIdx);
        out.writeInt(annotationsOff);