javassist.bytecode.annotation
public class Annotation extends Object
annotation
structure.
An instance of this class is returned by
getAnnotations()
in AnnotationsAttribute
or in ParameterAnnotationsAttribute
.
See Also: getAnnotations getAnnotations MemberValue MemberValueVisitor
Constructor Summary | |
---|---|
Annotation(int type, ConstPool cp)
Constructs an annotation including no members. | |
Annotation(String typeName, ConstPool cp)
Constructs an annotation including no members. | |
Annotation(ConstPool cp, CtClass clazz)
Constructs an annotation that can be accessed through the interface
represented by clazz . |
Method Summary | |
---|---|
void | addMemberValue(int nameIndex, MemberValue value)
Adds a new member.
|
void | addMemberValue(String name, MemberValue value)
Adds a new member.
|
static MemberValue | createMemberValue(ConstPool cp, CtClass type)
Makes an instance of MemberValue .
|
boolean | equals(Object obj)
Returns true if the given object represents the same annotation
as this object. |
Set | getMemberNames()
Obtains all the member names.
|
MemberValue | getMemberValue(String name)
Obtains the member value with the given name.
|
String | getTypeName()
Obtains the name of the annotation type.
|
Object | toAnnotationType(ClassLoader cl, ClassPool cp)
Constructs an annotation-type object representing this annotation.
|
String | toString()
Returns a string representation of the annotation. |
void | write(AnnotationsWriter writer)
Writes this annotation.
|
addMemberValue()
.
Parameters: type the index into the constant pool table.
the entry at that index must be the
CONSTANT_Utf8_Info
structure
repreenting the name of the annotation interface type. cp the constant pool table.
See Also: Annotation
addMemberValue()
.
Parameters: typeName the name of the annotation interface type. cp the constant pool table.
See Also: Annotation
clazz
. The values of the members are
not specified.
Parameters: cp the constant pool table. clazz the interface.
Throws: NotFoundException when the clazz is not found
Parameters: nameIndex the index into the constant pool table.
The entry at that index must be
a CONSTANT_Utf8_info
structure.
structure representing the member name. value the member value.
Parameters: name the member name. value the member value.
MemberValue
.
Parameters: cp the constant pool table. type the type of the member.
Returns: the member value
Throws: NotFoundException when the type is not found
Returns: null if no members are defined.
If this annotation does not have a value for the
specified member,
this method returns null. It does not return a
MemberValue
with the default value.
The default value can be obtained from the annotation type.
Parameters: name the member name
Returns: null if the member cannot be found or if the value is the default value.
See Also: AnnotationDefaultAttribute
Returns: the type name
@Author
,
this method returns an Author
object.
Parameters: cl class loader for loading an annotation type. cp class pool for obtaining class files.
Returns: the annotation
Throws: ClassNotFoundException when the class cannot found
Parameters: writer the output.
Throws: IOException for an error during the write