Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.bcel.generic
Class FieldGen  view FieldGen download FieldGen.java

java.lang.Object
  extended byorg.apache.bcel.classfile.AccessFlags
      extended byorg.apache.bcel.generic.FieldGenOrMethodGen
          extended byorg.apache.bcel.generic.FieldGen
All Implemented Interfaces:
java.lang.Cloneable, NamedAndTyped, java.io.Serializable

public class FieldGen
extends FieldGenOrMethodGen

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).

Version:
$Id: FieldGen.java 386056 2006-03-15 11:31:56Z tcurdt $

Field Summary
private static org.apache.bcel.util.BCELComparator _cmp
           
private  java.util.List observers
           
private  java.lang.Object value
           
 
Fields inherited from class org.apache.bcel.generic.FieldGenOrMethodGen
cp, name, type
 
Fields inherited from class org.apache.bcel.classfile.AccessFlags
access_flags
 
Constructor Summary
FieldGen(org.apache.bcel.classfile.Field field, ConstantPoolGen cp)
          Instantiate from existing field.
FieldGen(int access_flags, Type type, java.lang.String name, ConstantPoolGen cp)
          Declare a field.
 
Method Summary
private  int addConstant()
           
 void addObserver(FieldObserver o)
          Add observer for this object.
 void cancelInitValue()
          Remove any initial value.
private  void checkType(Type atype)
           
 FieldGen copy(ConstantPoolGen cp)
           
 boolean equals(java.lang.Object obj)
          Return value as defined by given BCELComparator strategy.
static org.apache.bcel.util.BCELComparator getComparator()
           
 org.apache.bcel.classfile.Field getField()
          Get field object after having set up all necessary values.
 java.lang.String getInitValue()
           
 java.lang.String getSignature()
           
 int hashCode()
          Return value as defined by given BCELComparator strategy.
 void removeObserver(FieldObserver o)
          Remove observer for this object.
static void setComparator(org.apache.bcel.util.BCELComparator comparator)
           
 void setInitValue(boolean b)
           
 void setInitValue(byte b)
           
 void setInitValue(char c)
           
 void setInitValue(double d)
           
 void setInitValue(float f)
           
 void setInitValue(int i)
           
 void setInitValue(long l)
           
 void setInitValue(short s)
           
 void setInitValue(java.lang.String str)
          Set (optional) initial value of field, otherwise it will be set to null/0/false by the JVM automatically.
private  void setValue(int index)
           
 java.lang.String toString()
          Return string representation close to declaration format, `public static final short MAX = 100', e.g..
 void update()
          Call notify() method on all observers.
 
Methods inherited from class org.apache.bcel.generic.FieldGenOrMethodGen
addAttribute, clone, getAttributes, getConstantPool, getName, getType, removeAttribute, removeAttributes, setConstantPool, setName, setType
 
Methods inherited from class org.apache.bcel.classfile.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, isVolatile, isVolatile, setAccessFlags, setModifiers
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

value

private java.lang.Object value

_cmp

private static org.apache.bcel.util.BCELComparator _cmp

observers

private java.util.List observers
Constructor Detail

FieldGen

public FieldGen(int access_flags,
                Type type,
                java.lang.String name,
                ConstantPoolGen cp)
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().


FieldGen

public FieldGen(org.apache.bcel.classfile.Field field,
                ConstantPoolGen cp)
Instantiate from existing field.

Method Detail

setValue

private void setValue(int index)

setInitValue

public void setInitValue(java.lang.String str)
Set (optional) initial value of field, otherwise it will be set to null/0/false by the JVM automatically.


setInitValue

public void setInitValue(long l)

setInitValue

public void setInitValue(int i)

setInitValue

public void setInitValue(short s)

setInitValue

public void setInitValue(char c)

setInitValue

public void setInitValue(byte b)

setInitValue

public void setInitValue(boolean b)

setInitValue

public void setInitValue(float f)

setInitValue

public void setInitValue(double d)

cancelInitValue

public void cancelInitValue()
Remove any initial value.


checkType

private void checkType(Type atype)

getField

public org.apache.bcel.classfile.Field getField()
Get field object after having set up all necessary values.


addConstant

private int addConstant()

getSignature

public java.lang.String getSignature()
Specified by:
getSignature in class FieldGenOrMethodGen

addObserver

public void addObserver(FieldObserver o)
Add observer for this object.


removeObserver

public void removeObserver(FieldObserver o)
Remove observer for this object.


update

public void 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 he has finished editing the object.


getInitValue

public java.lang.String getInitValue()

toString

public final java.lang.String toString()
Return string representation close to declaration format, `public static final short MAX = 100', e.g..


copy

public FieldGen copy(ConstantPoolGen cp)

getComparator

public static org.apache.bcel.util.BCELComparator getComparator()

setComparator

public static void setComparator(org.apache.bcel.util.BCELComparator comparator)

equals

public boolean equals(java.lang.Object obj)
Return value as defined by given BCELComparator strategy. By default two FieldGen objects are said to be equal when their names and signatures are equal.


hashCode

public int hashCode()
Return value as defined by given BCELComparator strategy. By default return the hashcode of the field's name XOR signature.