| 
 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.apache.bcel.generic.ConstantPoolGen
This class is used to build up a constant pool. The user adds constants via `addXXX' methods, `addString', `addClass', etc.. These methods return an index into the constant pool. Finally, `getFinalConstantPool()' returns the constant pool built up. Intermediate versions of the constant pool can be obtained with `getConstantPool()'. A constant pool has capacity for Constants.MAX_SHORT entries. Note that the first (0) is used by the JVM and that Double and Long constants need two slots.
Constant, 
Serialized Form| Field Summary | |
| protected  Constant[] | constants | 
| protected  int | index | 
| protected  int | size | 
| Constructor Summary | |
| ConstantPoolGen()Create empty constant pool. | |
| ConstantPoolGen(Constant[] cs)Initialize with given array of constants. | |
| ConstantPoolGen(ConstantPool cp)Initialize with given constant pool. | |
| Method Summary | |
|  int | addArrayClass(ArrayType type)Add a reference to an array class (e.g. | 
|  int | addClass(ObjectType type)Add a new Class reference to the ConstantPool for a given type. | 
|  int | addClass(java.lang.String str)Add a new Class reference to the ConstantPool, if it is not already in there. | 
|  int | addConstant(Constant c,
            ConstantPoolGen cp)Import constant from another ConstantPool and return new index. | 
|  int | addDouble(double n)Add a new double constant to the ConstantPool, if it is not already in there. | 
|  int | addFieldref(java.lang.String class_name,
            java.lang.String field_name,
            java.lang.String signature)Add a new Fieldref constant to the ConstantPool, if it is not already in there. | 
|  int | addFloat(float n)Add a new Float constant to the ConstantPool, if it is not already in there. | 
|  int | addInteger(int n)Add a new Integer constant to the ConstantPool, if it is not already in there. | 
|  int | addInterfaceMethodref(MethodGen method) | 
|  int | addInterfaceMethodref(java.lang.String class_name,
                      java.lang.String method_name,
                      java.lang.String signature)Add a new InterfaceMethodref constant to the ConstantPool, if it is not already in there. | 
|  int | addLong(long n)Add a new long constant to the ConstantPool, if it is not already in there. | 
|  int | addMethodref(MethodGen method) | 
|  int | addMethodref(java.lang.String class_name,
             java.lang.String method_name,
             java.lang.String signature)Add a new Methodref constant to the ConstantPool, if it is not already in there. | 
|  int | addNameAndType(java.lang.String name,
               java.lang.String signature)Add a new NameAndType constant to the ConstantPool if it is not already in there. | 
|  int | addString(java.lang.String str)Add a new String constant to the ConstantPool, if it is not already in there. | 
|  int | addUtf8(java.lang.String n)Add a new Utf8 constant to the ConstantPool, if it is not already in there. | 
| protected  void | adjustSize()Resize internal array of constants. | 
|  Constant | getConstant(int i) | 
|  ConstantPool | getConstantPool() | 
|  ConstantPool | getFinalConstantPool() | 
|  int | getSize() | 
|  int | lookupClass(java.lang.String str)Look for ConstantClass in ConstantPool named `str'. | 
|  int | lookupDouble(double n)Look for ConstantDouble in ConstantPool. | 
|  int | lookupFieldref(java.lang.String class_name,
               java.lang.String field_name,
               java.lang.String signature)Look for ConstantFieldref in ConstantPool. | 
|  int | lookupFloat(float n)Look for ConstantFloat in ConstantPool. | 
|  int | lookupInteger(int n)Look for ConstantInteger in ConstantPool. | 
|  int | lookupInterfaceMethodref(MethodGen method) | 
|  int | lookupInterfaceMethodref(java.lang.String class_name,
                         java.lang.String method_name,
                         java.lang.String signature)Look for ConstantInterfaceMethodref in ConstantPool. | 
|  int | lookupLong(long n)Look for ConstantLong in ConstantPool. | 
|  int | lookupMethodref(MethodGen method) | 
|  int | lookupMethodref(java.lang.String class_name,
                java.lang.String method_name,
                java.lang.String signature)Look for ConstantMethodref in ConstantPool. | 
|  int | lookupNameAndType(java.lang.String name,
                  java.lang.String signature)Look for ConstantNameAndType in ConstantPool. | 
|  int | lookupString(java.lang.String str)Look for ConstantString in ConstantPool containing String `str'. | 
|  int | lookupUtf8(java.lang.String n)Look for ConstantUtf8 in ConstantPool. | 
|  void | setConstant(int i,
            Constant c)Use with care! | 
|  java.lang.String | toString() | 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
protected int size
protected Constant[] constants
protected int index
| Constructor Detail | 
public ConstantPoolGen(Constant[] cs)
public ConstantPoolGen(ConstantPool cp)
public ConstantPoolGen()
| Method Detail | 
protected void adjustSize()
public int lookupString(java.lang.String str)
str - String to search for
public int addString(java.lang.String str)
str - String to add
public int lookupClass(java.lang.String str)
str - String to search for
public int addClass(java.lang.String str)
str - Class to add
public int addClass(ObjectType type)
public int addArrayClass(ArrayType type)
type - type of array class
public int lookupInteger(int n)
n - integer number to look for
public int addInteger(int n)
n - integer number to add
public int lookupFloat(float n)
n - Float number to look for
public int addFloat(float n)
n - Float number to add
public int lookupUtf8(java.lang.String n)
n - Utf8 string to look for
public int addUtf8(java.lang.String n)
n - Utf8 string to add
public int lookupLong(long n)
n - Long number to look for
public int addLong(long n)
n - Long number to add
public int lookupDouble(double n)
n - Double number to look for
public int addDouble(double n)
n - Double number to add
public int lookupNameAndType(java.lang.String name,
                             java.lang.String signature)
name - of variable/methodsignature - of variable/method
public int addNameAndType(java.lang.String name,
                          java.lang.String signature)
public int lookupMethodref(java.lang.String class_name,
                           java.lang.String method_name,
                           java.lang.String signature)
class_name - Where to find methodmethod_name - Guess whatsignature - return and argument types
public int lookupMethodref(MethodGen method)
public int addMethodref(java.lang.String class_name,
                        java.lang.String method_name,
                        java.lang.String signature)
public int addMethodref(MethodGen method)
public int lookupInterfaceMethodref(java.lang.String class_name,
                                    java.lang.String method_name,
                                    java.lang.String signature)
class_name - Where to find methodmethod_name - Guess whatsignature - return and argument types
public int lookupInterfaceMethodref(MethodGen method)
public int addInterfaceMethodref(java.lang.String class_name,
                                 java.lang.String method_name,
                                 java.lang.String signature)
public int addInterfaceMethodref(MethodGen method)
public int lookupFieldref(java.lang.String class_name,
                          java.lang.String field_name,
                          java.lang.String signature)
class_name - Where to find methodfield_name - Guess whatsignature - return and argument types
public int addFieldref(java.lang.String class_name,
                       java.lang.String field_name,
                       java.lang.String signature)
public Constant getConstant(int i)
i - index in constant pool
public void setConstant(int i,
                        Constant c)
i - index in constant poolc - new constant pool entry at index ipublic ConstantPool getConstantPool()
public int getSize()
public ConstantPool getFinalConstantPool()
public java.lang.String toString()
toString in class java.lang.Object
public int addConstant(Constant c,
                       ConstantPoolGen cp)
| 
 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||