Top Description Inners Fields Constructors Methods
javassist

public Class CtField

extends CtMember
Class Inheritance
Known Direct Subclasses
javassist.compiler.Javac.CtFieldWithInit
Imports
java.util.List, javassist.bytecode.AccessFlag, .AnnotationsAttribute, .AttributeInfo, .Bytecode, .ClassFile, .ConstPool, .Descriptor, .FieldInfo, .SignatureAttribute, javassist.compiler.CompileError, .Javac, .SymbolTable, javassist.compiler.ast.ASTree, .DoubleConst, .IntConst, .StringL

An instance of CtField represents a field.
See Also
CtClass#getDeclaredFields()

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
pack-priv abstract static class
pack-priv static class
pack-priv static class
public abstract static class
CtField.Initializer

Instances of this class specify how to initialize a field.

pack-priv static class
pack-priv static class
pack-priv static class
CtField.MethodInitializer

A field initialized with the result of a static method call.

pack-priv static class
pack-priv static class
CtField.NewInitializer

A field initialized with an object created by the new operator.

pack-priv static class
CtField.ParamInitializer

A field initialized with a parameter passed to the constructor of the class containing that field.

pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
protected FieldInfo
pack-priv static final String
Inherited from javassist.CtMember:
declaringClassnext

Constructor Summary

AccessConstructor and Description
public
CtField(CtClass
field type
type
,
String
field name
name
,
CtClass
the class to which the field will be added.
declaring
)

Creates a CtField object.

public
CtField(CtField
the original field
src
,
CtClass
the class to which the field will be added.
declaring
)

Creates a copy of the given field.

private
CtField(String typeDesc, String name, CtClass clazz)

pack-priv

Method Summary

Modifier and TypeMethod and Description
protected void
extendToString(StringBuilder buffer)

Implements abstract javassist.CtMember.extendToString.

Invoked by toString() to add to the buffer and provide the complete value.

public Object

Returns:

the annotation if found, otherwise null.
getAnnotation
(Class<?>
the annotation class.
clz
)

Implements abstract javassist.CtMember.getAnnotation.

Returns the annotation if the class has the specified annotation class.

public Object[]

Returns:

an array of annotation-type objects.
getAnnotations
()

Implements abstract javassist.CtMember.getAnnotations.

Returns the annotations associated with this field.

private Object[]
getAnnotations(boolean ignoreNotFound)

public byte[]
getAttribute(String
attribute name
name
)

Implements abstract javassist.CtMember.getAttribute.

Obtains an attribute with the given name.

public Object[]

Returns:

an array of annotation-type objects.
getAvailableAnnotations
()

Implements abstract javassist.CtMember.getAvailableAnnotations.

Returns the annotations associated with this field.

public Object

Returns:

a 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.
getConstantValue
()

Returns the value of this field if it is a constant field.

public CtClass
getDeclaringClass()

Overrides javassist.CtMember.getDeclaringClass.

Returns the class declaring the field.

public FieldInfo
getFieldInfo()

Returns the FieldInfo representing the field in the class file.

public FieldInfo
getFieldInfo2()

Returns the FieldInfo representing the field in the class file (read only).

public String
getGenericSignature()

Implements abstract javassist.CtMember.getGenericSignature.

Returns the generic signature of the field.

pack-priv CtField.Initializer
protected ASTree
public int
getModifiers()

Implements abstract javassist.CtMember.getModifiers.

Returns the encoded modifiers of the field.

public String
getName()

Implements abstract javassist.CtMember.getName.

Returns the name of the field.

public String
getSignature()

Implements abstract javassist.CtMember.getSignature.

Returns the character string representing the type of the field.

public CtClass
getType()

Returns the type of the field.

public boolean

Returns:

true if the annotation is found, otherwise false.
hasAnnotation
(String
the name of annotation type.
typeName
)

Implements abstract javassist.CtMember.hasAnnotation.

Returns true if the class has the specified annotation type.

public static CtField
make(String
the source text.
src
,
CtClass
the class to which the created field is added.
declaring
)

Compiles the given source code and creates a field.

public void
setAttribute(String
attribute name
name
,
byte[]
attribute value
data
)

Implements abstract javassist.CtMember.setAttribute.

Adds an attribute.

public void
setGenericSignature(String
a new generic signature.
sig
)

Implements abstract javassist.CtMember.setGenericSignature.

Set the generic signature of the field.

public void
setModifiers(int mod)

Implements abstract javassist.CtMember.setModifiers.

Sets the encoded modifiers of the field.

public void
setName(String newName)

Changes the name of the field.

public void
setType(CtClass clazz)

Sets the type of the field.

public String
toString()

Overrides javassist.CtMember.toString.

Returns a String representation of the object.

Inherited from javassist.CtMember:
hasAnnotationnameReplacednextvisibleFrom