org.ow2.asmdex.structureWriter
Class AnnotationSetRefList

java.lang.Object
  extended by org.ow2.asmdex.structureWriter.AnnotationSetRefList

public class AnnotationSetRefList
extends java.lang.Object

A Class representing an annotation_set_ref_list structure. It possesses the Annotation_set_item that EACH argument of a Method has. Dalvik handles them this way : If AT LEAST one argument of a Method is annotated, then all the arguments are stored here. The non-annotated arguments have an annotation_set_item that has a size of 0. Since all the arguments must be stored, the constructor requires the number of parameters of the Method this annotation_set_ref_list belongs. When all the parameters have been filled (which can be done in several passes, if several annotations), the annotation_set_ref_list HAS to be "closed" (through the close() method) so that empty parameters can be filled with empty annotation_set_items.

Author:
Julien Névo

Constructor Summary
AnnotationSetRefList(int nbParameters, Method method)
          Constructor of an annotation_set_ref_list.
 
Method Summary
 void addAnnotationItem(int parameterIndex, AnnotationItem annotationItem)
          Adds an annotation_item to the given parameter.
 void close()
          Fill the empty parameters with an empty annotation_set_item.
 boolean equals(java.lang.Object obj)
           
 AnnotationSetItem getAnnotationSetItem(int parameterIndex)
          Returns the annotation_set_item of the given parameter index.
 AnnotationSetItem[] getAnnotationSetItems()
          Returns an array containing, for each parameters, an annotation_set_item.
 Method getMethod()
          Returns the Method this structure belongs to.
 int getNbAnnotationSetItem()
          Returns the number of annotation_set_items in the structure.
 int getNbAnnotationSetItemsUsed()
          Returns the number of annotation_set_items that are not empty or null.
 int hashCode()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationSetRefList

public AnnotationSetRefList(int nbParameters,
                            Method method)
Constructor of an annotation_set_ref_list.

Parameters:
nbParameters - number of parameters of the Methods it belongs to (return type not included).
method - the Method this annotation_set_ref_list belongs to.
Method Detail

addAnnotationItem

public void addAnnotationItem(int parameterIndex,
                              AnnotationItem annotationItem)
Adds an annotation_item to the given parameter.

Parameters:
parameterIndex - the zero-based index of the parameter.
annotationItem - the annotation_item to add.

close

public void close()
Fill the empty parameters with an empty annotation_set_item. This has to be done once before encoding the Dex file.


getAnnotationSetItems

public AnnotationSetItem[] getAnnotationSetItems()
Returns an array containing, for each parameters, an annotation_set_item. All the parameters have an annotation_set_items. However, it can have an empty size of the parameter is not annotated.

Returns:
a Map containing, for each parameters, an annotation_set_item.

getAnnotationSetItem

public AnnotationSetItem getAnnotationSetItem(int parameterIndex)
Returns the annotation_set_item of the given parameter index.

Parameters:
parameterIndex - the zero-based parameter index.
Returns:
the annotation_set_item of the given parameter index.

getNbAnnotationSetItem

public int getNbAnnotationSetItem()
Returns the number of annotation_set_items in the structure. Represents ALL the arguments, even those who were not annotated.

Returns:
the number of annotation_set_items in the structure.

getNbAnnotationSetItemsUsed

public int getNbAnnotationSetItemsUsed()
Returns the number of annotation_set_items that are not empty or null.

Returns:
the number of annotation_set_items that are not empty or null.

getMethod

public Method getMethod()
Returns the Method this structure belongs to.

Returns:
the Method this structure belongs to.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object