Class Annotation
- java.lang.Object
-
- com.tonic.parser.attribute.annotation.Annotation
-
public class Annotation extends Object
A parsed annotation: its type descriptor index and element-value pairs.
-
-
Constructor Summary
Constructors Constructor Description Annotation(ConstPool constPool, int typeIndex, int numElementValuePairs, List<ElementValuePair> elementValuePairs)Creates an annotation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<ElementValuePair>getElementValuePairs()intgetLength()Calculates the total length of this annotation in bytes.intgetNumElementValuePairs()intgetTypeIndex()static AnnotationreadAnnotation(ClassFile classFile, ConstPool constPool)Reads an annotation structure from the class file.StringtoString()voidwrite(DataOutputStream dos)Writes this annotation to the output stream.
-
-
-
Constructor Detail
-
Annotation
public Annotation(ConstPool constPool, int typeIndex, int numElementValuePairs, List<ElementValuePair> elementValuePairs)
Creates an annotation.- Parameters:
constPool- the pool used to resolve indicestypeIndex- constant-pool index of the annotation type descriptor Utf8numElementValuePairs- the declared pair countelementValuePairs- the element-value pairs
-
-
Method Detail
-
getTypeIndex
public int getTypeIndex()
- Returns:
- the type index
-
getNumElementValuePairs
public int getNumElementValuePairs()
- Returns:
- the num element value pairs
-
getElementValuePairs
public List<ElementValuePair> getElementValuePairs()
- Returns:
- the element value pairs
-
readAnnotation
public static Annotation readAnnotation(ClassFile classFile, ConstPool constPool)
Reads an annotation structure from the class file.- Parameters:
classFile- the class file to read fromconstPool- the constant pool- Returns:
- the parsed annotation
-
write
public void write(DataOutputStream dos) throws IOException
Writes this annotation to the output stream.- Parameters:
dos- the output stream- Throws:
IOException- if an I/O error occurs
-
getLength
public int getLength()
Calculates the total length of this annotation in bytes.- Returns:
- the length in bytes
-
-