Class FieldGen
java.lang.Object
org.apache.bcel.classfile.AccessFlags
org.apache.bcel.generic.FieldGenOrMethodGen
org.apache.bcel.generic.FieldGen
- All Implemented Interfaces:
Cloneable, NamedAndTyped
Template class for building up a field. The only extraordinary thing one can do is to add a constant value attribute
to a field (which must of course be compatible with to the declared type).
- See Also:
-
Field Summary
Fields inherited from class FieldGenOrMethodGen
cp, name, typeModifier and TypeFieldDescriptionprotected ConstantPoolGenDeprecated.(since 6.0) will be made private; do not access directly, use getter/setterprotected StringDeprecated.(since 6.0) will be made private; do not access directly, use getter/setterprotected TypeDeprecated.(since 6.0) will be made private; do not access directly, use getter/setterFields inherited from class AccessFlags
access_flagsModifier and TypeFieldDescriptionprotected intDeprecated.(since 6.0) will be made private; do not access directly, use getter/setter. -
Constructor Summary
ConstructorsConstructorDescriptionFieldGen(int accessFlags, Type type, String name, ConstantPoolGen cp) Declare a field.FieldGen(Field field, ConstantPoolGen cp) Instantiate from existing field. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd observer for this object.voidRemove any initial value.copy(ConstantPoolGen cp) Creates a deep copy of this field.booleanReturn value as defined by given BCELComparator strategy.static BCELComparator<FieldGen> Gets the comparison strategy object.getField()Gets field object after having set up all necessary values.Gets the initial value.Gets the signature of method or field.inthashCode()Return value as defined by given BCELComparator strategy.voidRemove observer for this object.static voidsetComparator(BCELComparator<FieldGen> comparator) Sets the comparison strategy object.voidsetInitValue(boolean b) Sets the initial value.voidsetInitValue(byte b) Sets the initial value.voidsetInitValue(char c) Sets the initial value.voidsetInitValue(double d) Sets the initial value.voidsetInitValue(float f) Sets the initial value.voidsetInitValue(int i) Sets the initial value.voidsetInitValue(long l) Sets the initial value.voidsetInitValue(short s) Sets the initial value.voidsetInitValue(String str) Sets (optional) initial value of field, otherwise it will be set to null/0/false by the JVM automatically.final StringtoString()Return string representation close to declaration format, for example: 'public static final short MAX = 100'.voidupdate()Call notify() method on all observers.Methods inherited from class FieldGenOrMethodGen
addAll, addAnnotationEntry, addAttribute, clone, getAnnotationEntries, getAttributes, getConstantPool, getName, getType, removeAnnotationEntries, removeAnnotationEntry, removeAttribute, removeAttributes, setConstantPool, setName, setTypeModifier and TypeMethodDescriptionprotected voidAdds all attributes from an array.voidAdds an annotation entry.voidAdd an attribute to this method.clone()Gets all annotation entries.Gets all attributes of this method or field.Gets the constant pool.getName()Gets the name of the method or field.getType()Gets the type.voidRemoves all annotation entries.voidRemoves an annotation entry.voidRemoves an attribute.voidRemoves all attributes.voidSets the constant pool.voidSets the name.voidSets the type.Methods inherited from class AccessFlags
getAccessFlags, getModifiers, isAbstract, isAbstract, isAnnotation, isAnnotation, isEnum, isEnum, isFinal, isFinal, isInterface, isInterface, isNative, isNative, isPrivate, isPrivate, isProtected, isProtected, isPublic, isPublic, isStatic, isStatic, isStrictfp, isStrictfp, isSynchronized, isSynchronized, isSynthetic, isSynthetic, isTransient, isTransient, isVarArgs, isVarArgs, isVolatile, isVolatile, setAccessFlags, setModifiersModifier and TypeMethodDescriptionfinal intGets access flags.final intGets access flags.final booleanTests whether the abstract bit is on.final voidisAbstract(boolean flag) Sets the abstract bit.final booleanTests whether the annotation bit is on.final voidisAnnotation(boolean flag) Sets the annotation bit.final booleanisEnum()Tests whether the enum bit is on.final voidisEnum(boolean flag) Sets the enum bit.final booleanisFinal()Tests whether the final bit is on.final voidisFinal(boolean flag) Sets the final bit.final booleanTests whether the interface bit is on.final voidisInterface(boolean flag) Sets the interface bit.final booleanisNative()Tests whether the native bit is on.final voidisNative(boolean flag) Sets the native bit.final booleanTests whether the private bit is on.final voidisPrivate(boolean flag) Sets the private bit.final booleanTests whether the protected bit is on.final voidisProtected(boolean flag) Sets the protected bit.final booleanisPublic()Tests whether the public bit is on.final voidisPublic(boolean flag) Sets the public bit.final booleanisStatic()Tests whether the static bit is on.final voidisStatic(boolean flag) Sets the static bit.final booleanTests whether the strict bit is on.final voidisStrictfp(boolean flag) Sets the strict bit.final booleanTests whether the synchronized bit is on.final voidisSynchronized(boolean flag) Sets the synchronized bit.final booleanTests whether the synthetic bit is on.final voidisSynthetic(boolean flag) Sets the synthetic bit.final booleanTests whether the transient bit is on.final voidisTransient(boolean flag) Sets the transient bit.final booleanTests whether the varargs bit is on.final voidisVarArgs(boolean flag) Sets the varargs bit.final booleanTests whether the volatile bit is on.final voidisVolatile(boolean flag) Sets the volatile bit.final voidsetAccessFlags(int accessFlags) Sets access flags also known as modifiers.final voidsetModifiers(int accessFlags) Sets access flags aka "modifiers".
-
Constructor Details
-
FieldGen
Instantiate from existing field.- Parameters:
field- Field object.cp- constant pool (must contain the same entries as the field's constant pool).
-
FieldGen
Declare a field. If it is static (isStatic() == true) and has a basic type like int or String it may have an initial value associated with it as defined by setInitValue().- Parameters:
accessFlags- access qualifiers.type- field type.name- field name.cp- constant pool.
-
-
Method Details
-
getComparator
Gets the comparison strategy object.- Returns:
- Comparison strategy object.
-
setComparator
Sets the comparison strategy object.- Parameters:
comparator- Comparison strategy object.
-
addObserver
Add observer for this object.- Parameters:
o- The observer to add.
-
cancelInitValue
Remove any initial value. -
copy
Creates a deep copy of this field.- Parameters:
cp- The constant pool.- Returns:
- deep copy of this field.
-
equals
-
getField
-
getInitValue
-
getSignature
Description copied from class:FieldGenOrMethodGenGets the signature of method or field.- Specified by:
getSignaturein classFieldGenOrMethodGen- Returns:
- signature of method/field.
-
hashCode
-
removeObserver
Remove observer for this object.- Parameters:
o- The observer to remove.
-
setInitValue
Sets the initial value.Records an explicit constant value, including
false. UsecancelInitValue()to remove it.- Parameters:
b- The boolean value.
-
setInitValue
-
setInitValue
-
setInitValue
-
setInitValue
-
setInitValue
-
setInitValue
-
setInitValue
-
setInitValue
Sets (optional) initial value of field, otherwise it will be set to null/0/false by the JVM automatically.- Parameters:
str- The string value.
-
toString
-
update
Call notify() method on all observers. This method is not called automatically whenever the state has changed, but has to be called by the user after they have finished editing the object.
-