Package org.apache.bcel.generic
Class AnnotationEntryGen
- java.lang.Object
-
- org.apache.bcel.generic.AnnotationEntryGen
-
public class AnnotationEntryGen extends java.lang.ObjectGenerates annotation entries.- Since:
- 6.0
-
-
Field Summary
Fields Modifier and Type Field Description private ConstantPoolGencpool(package private) static AnnotationEntryGen[]EMPTY_ARRAYprivate java.util.List<ElementValuePairGen>evsprivate booleanisRuntimeVisibleprivate inttypeIndex
-
Constructor Summary
Constructors Modifier Constructor Description AnnotationEntryGen(AnnotationEntry a, ConstantPoolGen cpool, boolean copyPoolEntries)Here we are taking a fixed annotation of type Annotation and building a modifiable AnnotationGen object.privateAnnotationEntryGen(ConstantPoolGen cpool)AnnotationEntryGen(ObjectType type, java.util.List<ElementValuePairGen> elements, boolean vis, ConstantPoolGen cpool)Constructs an AnnotationEntryGen.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddElementNameValuePair(ElementValuePairGen evp)Adds an element name value pair.private java.util.List<ElementValuePairGen>copyValues(ElementValuePair[] in, ConstantPoolGen cpool, boolean copyPoolEntries)voiddump(java.io.DataOutputStream dos)Dumps this annotation entry to a DataOutputStream.AnnotationEntrygetAnnotation()Retrieves an immutable version of this AnnotationGen.(package private) static Attribute[]getAnnotationAttributes(ConstantPoolGen cp, AnnotationEntryGen[] annotationEntryGens)Converts a list of AnnotationGen objects into a set of attributes that can be attached to the class file.(package private) static Attribute[]getParameterAnnotationAttributes(ConstantPoolGen cp, java.util.List<AnnotationEntryGen>[] vec)Annotations against a class are stored in one of four attribute kinds: - RuntimeVisibleParameterAnnotations - RuntimeInvisibleParameterAnnotationsintgetTypeIndex()Gets the type index.java.lang.StringgetTypeName()Gets the type name.java.lang.StringgetTypeSignature()Gets the type signature.java.util.List<ElementValuePairGen>getValues()Returns list of ElementNameValuePair objects.booleanisRuntimeVisible()Gets whether this annotation is runtime visible.private voidisRuntimeVisible(boolean b)static AnnotationEntryGenread(java.io.DataInput dis, ConstantPoolGen cpool, boolean b)Reads an AnnotationEntryGen from a DataInput.java.lang.StringtoShortString()Returns a short string representation of this annotation.java.lang.StringtoString()
-
-
-
Field Detail
-
EMPTY_ARRAY
static final AnnotationEntryGen[] EMPTY_ARRAY
-
typeIndex
private int typeIndex
-
evs
private java.util.List<ElementValuePairGen> evs
-
cpool
private final ConstantPoolGen cpool
-
isRuntimeVisible
private boolean isRuntimeVisible
-
-
Constructor Detail
-
AnnotationEntryGen
public AnnotationEntryGen(AnnotationEntry a, ConstantPoolGen cpool, boolean copyPoolEntries)
Here we are taking a fixed annotation of type Annotation and building a modifiable AnnotationGen object. If the pool passed in is for a different class file, then copyPoolEntries should have been passed as true as that will force us to do a deep copy of the annotation and move the cpool entries across. We need to copy the type and the element name value pairs and the visibility.- Parameters:
a- the annotation entry.cpool- the constant pool generator.copyPoolEntries- whether to copy pool entries.
-
AnnotationEntryGen
private AnnotationEntryGen(ConstantPoolGen cpool)
-
AnnotationEntryGen
public AnnotationEntryGen(ObjectType type, java.util.List<ElementValuePairGen> elements, boolean vis, ConstantPoolGen cpool)
Constructs an AnnotationEntryGen.- Parameters:
type- the object type.elements- the element value pairs.vis- whether the annotation is visible.cpool- the constant pool generator.
-
-
Method Detail
-
getAnnotationAttributes
static Attribute[] getAnnotationAttributes(ConstantPoolGen cp, AnnotationEntryGen[] annotationEntryGens)
Converts a list of AnnotationGen objects into a set of attributes that can be attached to the class file.- Parameters:
cp- The constant pool gen where we can create the necessary name refs.annotationEntryGens- An array of AnnotationGen objects.
-
getParameterAnnotationAttributes
static Attribute[] getParameterAnnotationAttributes(ConstantPoolGen cp, java.util.List<AnnotationEntryGen>[] vec)
Annotations against a class are stored in one of four attribute kinds: - RuntimeVisibleParameterAnnotations - RuntimeInvisibleParameterAnnotations
-
read
public static AnnotationEntryGen read(java.io.DataInput dis, ConstantPoolGen cpool, boolean b) throws java.io.IOException
Reads an AnnotationEntryGen from a DataInput.- Parameters:
dis- the data input stream.cpool- the constant pool generator.b- whether the annotation is runtime visible.- Returns:
- the annotation entry generator.
- Throws:
java.io.IOException- if an I/O error occurs.
-
addElementNameValuePair
public void addElementNameValuePair(ElementValuePairGen evp)
Adds an element name value pair.- Parameters:
evp- the element value pair generator.
-
copyValues
private java.util.List<ElementValuePairGen> copyValues(ElementValuePair[] in, ConstantPoolGen cpool, boolean copyPoolEntries)
-
dump
public void dump(java.io.DataOutputStream dos) throws java.io.IOExceptionDumps this annotation entry to a DataOutputStream.- Parameters:
dos- the data output stream.- Throws:
java.io.IOException- if an I/O error occurs.
-
getAnnotation
public AnnotationEntry getAnnotation()
Retrieves an immutable version of this AnnotationGen.- Returns:
- an immutable version of this AnnotationGen.
-
getTypeIndex
public int getTypeIndex()
Gets the type index.- Returns:
- the type index.
-
getTypeName
public final java.lang.String getTypeName()
Gets the type name.- Returns:
- the type name.
-
getTypeSignature
public final java.lang.String getTypeSignature()
Gets the type signature.- Returns:
- the type signature.
-
getValues
public java.util.List<ElementValuePairGen> getValues()
Returns list of ElementNameValuePair objects.- Returns:
- list of ElementNameValuePair objects.
-
isRuntimeVisible
public boolean isRuntimeVisible()
Gets whether this annotation is runtime visible.- Returns:
- true if this annotation is runtime visible.
-
isRuntimeVisible
private void isRuntimeVisible(boolean b)
-
toShortString
public java.lang.String toShortString()
Returns a short string representation of this annotation.- Returns:
- a short string representation of this annotation.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-