public abstract class CtMember extends Object
CtMember
represents a field, a constructor,
or a method.Modifier and Type | Field and Description |
---|---|
protected CtClass |
declaringClass |
Modifier | Constructor and Description |
---|---|
protected |
CtMember(CtClass clazz) |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
extendToString(StringBuffer buffer)
Invoked by
toString() to add to the buffer and provide the
complete value. |
abstract Object |
getAnnotation(Class clz)
Returns the annotation if the class has the specified annotation class.
|
abstract Object[] |
getAnnotations()
Returns the annotations associated with this member.
|
abstract byte[] |
getAttribute(String name)
Obtains a user-defined attribute with the given name.
|
abstract Object[] |
getAvailableAnnotations()
Returns the annotations associated with this member.
|
CtClass |
getDeclaringClass()
Returns the class that declares this member.
|
abstract String |
getGenericSignature()
Returns the generic signature of the member.
|
abstract int |
getModifiers()
Obtains the modifiers of the member.
|
abstract String |
getName()
Obtains the name of the member.
|
abstract String |
getSignature()
Returns the character string representing the signature of the member.
|
abstract boolean |
hasAnnotation(Class clz)
Returns true if the class has the specified annotation class.
|
abstract void |
setAttribute(String name,
byte[] data)
Adds a user-defined attribute.
|
abstract void |
setGenericSignature(String sig)
Sets the generic signature of the member.
|
abstract void |
setModifiers(int mod)
Sets the encoded modifiers of the member.
|
String |
toString() |
boolean |
visibleFrom(CtClass clazz)
Returns true if this member is accessible from the given class.
|
protected CtClass declaringClass
protected CtMember(CtClass clazz)
protected abstract void extendToString(StringBuffer buffer)
toString()
to add to the buffer and provide the
complete value. Subclasses should invoke this method, adding a
space before each token. The modifiers for the member are
provided first; subclasses should provide additional data such
as return type, field or method name, etc.public CtClass getDeclaringClass()
public boolean visibleFrom(CtClass clazz)
public abstract int getModifiers()
javassist.Modifier
.Modifier
public abstract void setModifiers(int mod)
Modifier
public abstract boolean hasAnnotation(Class clz)
clz
- the annotation class.true
if the annotation is found, otherwise false
.public abstract Object getAnnotation(Class clz) throws 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.clz
- the annotation class.null
.ClassNotFoundException
public abstract Object[] getAnnotations() throws 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.ClassNotFoundException
CtClass.getAnnotations()
public abstract 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 String getName()
As for constructor names, see getName()
in CtConstructor
.
CtConstructor.getName()
public abstract String getSignature()
getSignature()
returns the same string.public abstract String getGenericSignature()
public abstract void setGenericSignature(String sig)
sig
- a new generic signature.SignatureAttribute.ObjectType.encode()
,
SignatureAttribute.MethodSignature.encode()
,
CtClass.setGenericSignature(String)
public abstract byte[] getAttribute(String name)
Note that an attribute is a data block specified by
the class file format.
See AttributeInfo
.
name
- attribute namepublic abstract void setAttribute(String name, byte[] data)
Note that an attribute is a data block specified by
the class file format.
See AttributeInfo
.
name
- attribute namedata
- attribute valueCopyright © 2019. All rights reserved.