Package org.apache.bcel.classfile
Class AnnotationEntry
java.lang.Object
org.apache.bcel.classfile.AnnotationEntry
- All Implemented Interfaces:
Node
Represents one annotation in the annotation table
- Since:
- 6.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConstantPoolprivate final List<ElementValuePair>static final AnnotationEntry[]Empty array of AnnotationEntry objects.private final booleanprivate final int -
Constructor Summary
ConstructorsConstructorDescriptionAnnotationEntry(int typeIndex, ConstantPool constantPool, boolean isRuntimeVisible) Constructs an AnnotationEntry. -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.voidaddElementNameValuePair(ElementValuePair elementNameValuePair) Adds an element name value pair.static AnnotationEntry[]createAnnotationEntries(Attribute[] attributes) Creates annotation entries from attributes.voiddump(DataOutputStream dos) Dumps this annotation entry to a DataOutputStream.Gets the annotation type name.intGets the annotation type index.Gets the constant pool.Gets the element value pairs in this annotation entry.final intGets the number of element value pairs in this annotation entry.intGets the type index.booleanGets whether this annotation is runtime visible.static AnnotationEntryread(DataInput input, ConstantPool constantPool, boolean isRuntimeVisible) Factory method to create an AnnotionEntry from a DataInput.(package private) static AnnotationEntryread(DataInput input, ConstantPool constantPool, boolean isRuntimeVisible, int nesting) Factory method to create an AnnotionEntry from a DataInput, carrying the nesting depth of the enclosing element values so thatElementValue.readElementValue(DataInput, ConstantPool, boolean, int)can bound the combined annotation/array nesting depth.Gets a short string representation of this annotation.toString()
-
Field Details
-
EMPTY_ARRAY
Empty array of AnnotationEntry objects. -
typeIndex
private final int typeIndex -
constantPool
-
isRuntimeVisible
private final boolean isRuntimeVisible -
elementValuePairs
-
-
Constructor Details
-
AnnotationEntry
Constructs an AnnotationEntry.- Parameters:
typeIndex- The type index.constantPool- The constant pool.isRuntimeVisible- whether the annotation is runtime visible.
-
-
Method Details
-
createAnnotationEntries
Creates annotation entries from attributes.- Parameters:
attributes- The attributes.- Returns:
- The annotation entries.
-
read
public static AnnotationEntry read(DataInput input, ConstantPool constantPool, boolean isRuntimeVisible) throws IOException Factory method to create an AnnotionEntry from a DataInput.- Parameters:
input- The input stream.constantPool- The constant pool.isRuntimeVisible- whether the annotation is runtime visible.- Returns:
- The entry.
- Throws:
IOException- Thrown if an I/O error occurs.
-
read
static AnnotationEntry read(DataInput input, ConstantPool constantPool, boolean isRuntimeVisible, int nesting) throws IOException Factory method to create an AnnotionEntry from a DataInput, carrying the nesting depth of the enclosing element values so thatElementValue.readElementValue(DataInput, ConstantPool, boolean, int)can bound the combined annotation/array nesting depth.- Parameters:
input- The input stream.constantPool- The constant pool.isRuntimeVisible- whether the annotation is runtime visible.nesting- the current element value nesting level.- Returns:
- The entry.
- Throws:
IOException- Thrown if an I/O error occurs.
-
accept
Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. -
addElementNameValuePair
Adds an element name value pair.- Parameters:
elementNameValuePair- The element name value pair.
-
dump
Dumps this annotation entry to a DataOutputStream.- Parameters:
dos- The output stream.- Throws:
IOException- Thrown if an I/O error occurs.
-
getAnnotationType
Gets the annotation type name.- Returns:
- The annotation type name.
-
getAnnotationTypeIndex
public int getAnnotationTypeIndex()Gets the annotation type index.- Returns:
- The annotation type index.
-
getConstantPool
Gets the constant pool.- Returns:
- The constant pool.
-
getElementValuePairs
Gets the element value pairs in this annotation entry.- Returns:
- The element value pairs in this annotation entry.
-
getNumElementValuePairs
public final int getNumElementValuePairs()Gets the number of element value pairs in this annotation entry.- Returns:
- The number of element value pairs in this annotation entry.
-
getTypeIndex
public int getTypeIndex()Gets the type index.- Returns:
- The type index.
-
isRuntimeVisible
public boolean isRuntimeVisible()Gets whether this annotation is runtime visible.- Returns:
- true if this annotation is runtime visible.
-
toShortString
Gets a short string representation of this annotation.- Returns:
- A short string representation of this annotation.
-
toString
-