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

ParameterAnnotationStruct

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

Fields Summary
private final com.android.dx.rop.cst.CstMethodRef
method
non-null; the method in question
private final com.android.dx.rop.annotation.AnnotationsList
annotationsList
non-null; the associated annotations list
private final UniformListItem
annotationsItem
non-null; the associated annotations list, as an item
Constructors Summary
public ParameterAnnotationStruct(com.android.dx.rop.cst.CstMethodRef method, com.android.dx.rop.annotation.AnnotationsList annotationsList)
Constructs an instance.

param
method non-null; the method in question
param
annotationsList non-null; the associated annotations list

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

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

        this.method = method;
        this.annotationsList = annotationsList;

        /*
         * Construct an item for the annotations list. TODO: This
         * requires way too much copying; fix it.
         */

        int size = annotationsList.size();
        ArrayList<AnnotationSetRefItem> arrayList = new
            ArrayList<AnnotationSetRefItem>(size);

        for (int i = 0; i < size; i++) {
            Annotations annotations = annotationsList.get(i);
            AnnotationSetItem item = new AnnotationSetItem(annotations);
            arrayList.add(new AnnotationSetRefItem(item));
        }
                
        this.annotationsItem = new UniformListItem<AnnotationSetRefItem>(
                ItemType.TYPE_ANNOTATION_SET_REF_LIST, arrayList);
    
Methods Summary
public voidaddContents(DexFile file)
{@inheritDoc}

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

        methodIds.intern(method);
        wordData.add(annotationsItem);
    
public intcompareTo(com.android.dx.dex.file.ParameterAnnotationStruct other)
{@inheritDoc}

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

        if (! (other instanceof ParameterAnnotationStruct)) {
            return false;
        }
        
        return method.equals(((ParameterAnnotationStruct) other).method);
    
public com.android.dx.rop.annotation.AnnotationsListgetAnnotationsList()
Gets the associated annotations list.

return
non-null; the annotations list

        return annotationsList;
    
public com.android.dx.rop.cst.CstMethodRefgetMethod()
Gets the method this item is for.

return
non-null; the method

        return method;
    
public inthashCode()
{@inheritDoc}

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

        StringBuilder sb = new StringBuilder();

        sb.append(method.toHuman());
        sb.append(": ");

        boolean first = true;
        for (AnnotationSetRefItem item : annotationsItem.getItems()) {
            if (first) {
                first = false;
            } else {
                sb.append(", ");
            }
            sb.append(item.toHuman());
        }

        return sb.toString();
    
public voidwriteTo(DexFile file, com.android.dx.util.AnnotatedOutput out)
{@inheritDoc}

        int methodIdx = file.getMethodIds().indexOf(method);
        int annotationsOff = annotationsItem.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);