org.ow2.asmdex.structureWriter
Class AnnotationItem

java.lang.Object
  extended by org.ow2.asmdex.structureWriter.AnnotationItem
All Implemented Interfaces:
java.lang.Comparable<AnnotationItem>

public class AnnotationItem
extends java.lang.Object
implements java.lang.Comparable<AnnotationItem>

An Annotation Item (from the annotation_item structure). Consists in Encoded Values (annotation_elements actually), sorted by string_id, as well as the visibility and the Type of the Annotation. An annotation_item is used to represent the various fields of an Annotation : @MyAnnotation(a=5, b=true) myItem. Equals and HashCode are overridden so that they can be rightly stored into a HashSet. Also overrides CompareTo in order to be sorted by type_id, as requested by annotation_set_item. CompareTo uses cached lists, as the PriorityQueue doesn't guarantee a traversal order, we have to sort them and build an array, which is only build when and if necessary.

Author:
Julien Névo

Constructor Summary
AnnotationItem(boolean visible, java.lang.String annotationType)
           
AnnotationItem(int visibility, java.lang.String annotationType)
           
 
Method Summary
 void addAnnotationElement(AnnotationElement annotationElement)
          Adds an Annotation Element to the sorted list.
 int compareTo(AnnotationItem ai)
           
 boolean equals(java.lang.Object o)
           
 java.util.PriorityQueue<AnnotationElement> getAnnotationElements()
          Returns the Annotation Element, sorted by string_id.
 java.lang.String getAnnotationType()
          Returns the Annotation Type.
 int getNbAnnotationElements()
          Returns the number of Annotation elements currently hold by the Item.
 int getVisibility()
          Returns the item visibility (see Opcodes.VISIBILITY_BUILD, Opcodes.VISIBILITY_RUNTIME, Opcodes.VISIBILITY_SYSTEM).
 int hashCode()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationItem

public AnnotationItem(int visibility,
                      java.lang.String annotationType)
Parameters:
visibility - visibility of the Annotation Item (see Opcodes.VISIBILITY_BUILD, Opcodes.VISIBILITY_RUNTIME, Opcodes.VISIBILITY_SYSTEM).
annotationType - type of the Annotation.

AnnotationItem

public AnnotationItem(boolean visible,
                      java.lang.String annotationType)
Parameters:
visible - indicates whether the Annotation Item is visible at Run Time.
annotationType - type of the Annotation.
Method Detail

addAnnotationElement

public void addAnnotationElement(AnnotationElement annotationElement)
Adds an Annotation Element to the sorted list.

Parameters:
annotationElement - the Annotation Element to add.

getVisibility

public int getVisibility()
Returns the item visibility (see Opcodes.VISIBILITY_BUILD, Opcodes.VISIBILITY_RUNTIME, Opcodes.VISIBILITY_SYSTEM).

Returns:
the item visibility.

getAnnotationType

public java.lang.String getAnnotationType()
Returns the Annotation Type.

Returns:
the Annotation Type.

getAnnotationElements

public java.util.PriorityQueue<AnnotationElement> getAnnotationElements()
Returns the Annotation Element, sorted by string_id.

Returns:
the Annotation Element, sorted by string_id.

getNbAnnotationElements

public int getNbAnnotationElements()
Returns the number of Annotation elements currently hold by the Item.

Returns:
the number of Annotation elements currently hold by the Item.

equals

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

hashCode

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

compareTo

public int compareTo(AnnotationItem ai)
Specified by:
compareTo in interface java.lang.Comparable<AnnotationItem>