javassist

Class CtMember

public abstract class CtMember extends Object

An instance of CtMember represents a field, a constructor, or a method.
Method Summary
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.
CtClassgetDeclaringClass()
Returns the class that declares this member.
abstract intgetModifiers()
Obtains the modifiers of the member.
abstract StringgetName()
Obtains the name of the member.
abstract StringgetSignature()
Returns the character string representing the signature of the member.
abstract voidsetAttribute(String name, byte[] data)
Adds a user-defined attribute.
abstract voidsetModifiers(int mod)
Sets the encoded modifiers of the member.
StringtoString()
booleanvisibleFrom(CtClass clazz)
Returns true if this member is accessible from the given class.

Method Detail

getAnnotations

public abstract Object[] getAnnotations()
Returns the annotations associated with this member. For example, if an annotation @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.

Returns: an array of annotation-type objects.

See Also: getAnnotations

getAttribute

public abstract byte[] getAttribute(String name)
Obtains a user-defined attribute with the given name. If that attribute is not found in the class file, this method returns null.

Note that an attribute is a data block specified by the class file format. See AttributeInfo.

Parameters: name attribute name

getAvailableAnnotations

public abstract Object[] getAvailableAnnotations()
Returns the annotations associated with this member. This method is equivalent to getAnnotations() except that, if any annotations are not on the classpath, they are not included in the returned array.

Returns: an array of annotation-type objects.

Since: 3.3

See Also: getAnnotations getAvailableAnnotations

getDeclaringClass

public CtClass getDeclaringClass()
Returns the class that declares this member.

getModifiers

public abstract int getModifiers()
Obtains the modifiers of the member.

Returns: modifiers encoded with javassist.Modifier.

See Also: Modifier

getName

public abstract String getName()
Obtains the name of the member.

As for constructor names, see getName() in CtConstructor.

See Also: getName

getSignature

public abstract String getSignature()
Returns the character string representing the signature of the member. If two members have the same signature (parameter types etc.), getSignature() returns the same string.

setAttribute

public abstract void setAttribute(String name, byte[] data)
Adds a user-defined attribute. The attribute is saved in the class file.

Note that an attribute is a data block specified by the class file format. See AttributeInfo.

Parameters: name attribute name data attribute value

setModifiers

public abstract void setModifiers(int mod)
Sets the encoded modifiers of the member.

See Also: Modifier

toString

public String toString()

visibleFrom

public boolean visibleFrom(CtClass clazz)
Returns true if this member is accessible from the given class.
Javassist, a Java-bytecode translator toolkit.
Copyright (C) 1999-2006 Shigeru Chiba. All Rights Reserved.