|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavassist.CtMember
javassist.CtField
An instance of CtField represents a field.
CtClass.getDeclaredFields()| Nested Class Summary | |
static class |
CtField.Initializer
Instances of this class specify how to initialize a field. |
| Constructor Summary | |
CtField(CtClass type,
java.lang.String name,
CtClass declaring)
Creates a CtField object. |
|
CtField(CtField src,
CtClass declaring)
Creates a copy of the given field. |
|
| Method Summary | |
byte[] |
getAttribute(java.lang.String name)
Obtains an attribute with the given name. |
java.lang.Object |
getConstantValue()
Returns the value of this field if it is a constant field. |
CtClass |
getDeclaringClass()
Returns the class declaring the field. |
FieldInfo |
getFieldInfo()
Returns the FieldInfo representing the field in the class file. |
FieldInfo |
getFieldInfo2()
Undocumented method. |
int |
getModifiers()
Returns the encoded modifiers of the field. |
java.lang.String |
getName()
Returns the name of the field. |
CtClass |
getType()
Returns the type of the field. |
static CtField |
make(java.lang.String src,
CtClass declaring)
Compiles the given source code and creates a field. |
void |
setAttribute(java.lang.String name,
byte[] data)
Adds an attribute. |
void |
setModifiers(int mod)
Sets the encoded modifiers of the field. |
void |
setName(java.lang.String newName)
Changes the name of the field. |
void |
setType(CtClass clazz)
Sets the type of the field. |
java.lang.String |
toString()
Returns a String representation of the object. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public CtField(CtClass type,
java.lang.String name,
CtClass declaring)
throws CannotCompileException
CtField object.
The created field must be added to a class
with CtClass.addField().
An initial value of the field is specified
by a CtField.Initializer object.
If getter and setter methods are needed,
call CtNewMethod.getter() and
CtNewMethod.setter().
type - field typename - field namedeclaring - the class to which the field will be added.CtClass.addField(CtField),
CtNewMethod.getter(String,CtField),
CtNewMethod.setter(String,CtField),
CtField.Initializer
public CtField(CtField src,
CtClass declaring)
throws CannotCompileException
CtClass.addField().
An initial value of the field is specified
by a CtField.Initializer object.
If getter and setter methods are needed,
call CtNewMethod.getter() and
CtNewMethod.setter().
src - the original fielddeclaring - the class to which the field will be added.CtNewMethod.getter(String,CtField),
CtNewMethod.setter(String,CtField),
CtField.Initializer| Method Detail |
public java.lang.String toString()
toString in class CtMember
public static CtField make(java.lang.String src,
CtClass declaring)
throws CannotCompileException
"public String name;" "public int k = 3;"
Note that the source code ends with ';'
(semicolon).
src - the source text.declaring - the class to which the created field is added.
CannotCompileExceptionpublic FieldInfo getFieldInfo()
public FieldInfo getFieldInfo2()
public CtClass getDeclaringClass()
getDeclaringClass in class CtMemberpublic java.lang.String getName()
getName in class CtMemberCtConstructor.getName()public void setName(java.lang.String newName)
public int getModifiers()
getModifiers in class CtMemberjavassist.Modifier.Modifierpublic void setModifiers(int mod)
setModifiers in class CtMemberModifier
public CtClass getType()
throws NotFoundException
NotFoundExceptionpublic void setType(CtClass clazz)
public java.lang.Object getConstantValue()
String type. Otherwise, it returns null.
A constant field is static and final.
Integer, Long, Float,
Double, Boolean,
or String object
representing the constant value.
null if it is not a constant field
or if the field type is not a primitive type
or String.public byte[] getAttribute(java.lang.String name)
getAttribute in class CtMembername - attribute name
public void setAttribute(java.lang.String name,
byte[] data)
setAttribute in class CtMembername - attribute namedata - attribute value
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||