CtBehavior
, CtField
public abstract class CtMember
extends java.lang.Object
CtMember
represents a field, a constructor,
or a method.Modifier and Type | Method | Description |
---|---|---|
abstract java.lang.Object |
getAnnotation(java.lang.Class<?> annotationType) |
Returns the annotation if the class has the specified annotation type.
|
abstract java.lang.Object[] |
getAnnotations() |
Returns the annotations associated with this member.
|
abstract byte[] |
getAttribute(java.lang.String name) |
Obtains a user-defined attribute with the given name.
|
abstract java.lang.Object[] |
getAvailableAnnotations() |
Returns the annotations associated with this member.
|
CtClass |
getDeclaringClass() |
Returns the class that declares this member.
|
abstract java.lang.String |
getGenericSignature() |
Returns the generic signature of the member.
|
abstract int |
getModifiers() |
Obtains the modifiers of the member.
|
abstract java.lang.String |
getName() |
Obtains the name of the member.
|
abstract java.lang.String |
getSignature() |
Returns the character string representing the signature of the member.
|
boolean |
hasAnnotation(java.lang.Class<?> clz) |
Returns true if the class has the specified annotation type.
|
abstract boolean |
hasAnnotation(java.lang.String annotationTypeName) |
Returns true if the class has the specified annotation type.
|
abstract void |
setAttribute(java.lang.String name,
byte[] data) |
Adds a user-defined attribute.
|
abstract void |
setGenericSignature(java.lang.String sig) |
Sets the generic signature of the member.
|
abstract void |
setModifiers(int mod) |
Sets the encoded modifiers of the member.
|
java.lang.String |
toString() |
|
boolean |
visibleFrom(CtClass clazz) |
Returns true if this member is accessible from the given class.
|
public java.lang.String toString()
toString
in class java.lang.Object
public CtClass getDeclaringClass()
public boolean visibleFrom(CtClass clazz)
public abstract int getModifiers()
javassist.Modifier
.Modifier
public abstract void setModifiers(int mod)
Modifier
public boolean hasAnnotation(java.lang.Class<?> clz)
clz
- the annotation type.true
if the annotation is found, otherwise false
.public abstract boolean hasAnnotation(java.lang.String annotationTypeName)
annotationTypeName
- the name of annotation type.true
if the annotation is found, otherwise false
.public abstract java.lang.Object getAnnotation(java.lang.Class<?> annotationType) throws java.lang.ClassNotFoundException
@Author
is associated
with this member, an Author
object is returned.
The member values can be obtained by calling methods on
the Author
object.annotationType
- the annotation type.null
.java.lang.ClassNotFoundException
public abstract java.lang.Object[] getAnnotations() throws java.lang.ClassNotFoundException
@Author
is associated
with this member, the returned array contains an Author
object. The member values can be obtained by calling methods on
the Author
object.java.lang.ClassNotFoundException
CtClass.getAnnotations()
public abstract java.lang.Object[] getAvailableAnnotations()
getAnnotations()
except that, if any annotations are not on the classpath,
they are not included in the returned array.getAnnotations()
,
CtClass.getAvailableAnnotations()
public abstract java.lang.String getName()
As for constructor names, see getName()
in CtConstructor
.
CtConstructor.getName()
public abstract java.lang.String getSignature()
getSignature()
returns the same string.public abstract java.lang.String getGenericSignature()
public abstract void setGenericSignature(java.lang.String sig)
sig
- a new generic signature.SignatureAttribute.ObjectType.encode()
,
SignatureAttribute.MethodSignature.encode()
,
CtClass.setGenericSignature(String)
public abstract byte[] getAttribute(java.lang.String name)
Note that an attribute is a data block specified by
the class file format.
See AttributeInfo
.
name
- attribute namepublic abstract void setAttribute(java.lang.String name, byte[] data)
Note that an attribute is a data block specified by
the class file format.
See AttributeInfo
.
name
- attribute namedata
- attribute valueJavassist, a Java-bytecode translator toolkit.
Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.