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, typeFields inherited from class AccessFlags
access_flags -
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) booleanReturn value as defined by given BCELComparator strategy.static BCELComparator<FieldGen> getField()Gets field object after having set up all necessary values.inthashCode()Return value as defined by given BCELComparator strategy.voidRemove observer for this object.static voidsetComparator(BCELComparator<FieldGen> comparator) voidsetInitValue(boolean b) voidsetInitValue(byte b) voidsetInitValue(char c) voidsetInitValue(double d) voidsetInitValue(float f) voidsetInitValue(int i) voidsetInitValue(long l) voidsetInitValue(short s) 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, setTypeMethods 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, setModifiers
-
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 qualifierstype- field typename- field namecp- constant pool
-
-
Method Details
-
getComparator
- Returns:
- Comparison strategy object.
-
setComparator
- Parameters:
comparator- Comparison strategy object.
-
addObserver
Add observer for this object. -
cancelInitValue
Remove any initial value. -
copy
- Returns:
- deep copy of this field
-
equals
-
getField
-
getInitValue
-
getSignature
- Specified by:
getSignaturein classFieldGenOrMethodGen- Returns:
- signature of method/field.
-
hashCode
-
removeObserver
Remove observer for this object. -
setInitValue
-
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. -
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.
-