|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.bcel.generic.ConstantPoolGen
public class 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 FormField 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(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(String class_name,
String field_name,
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(String class_name,
String method_name,
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(String class_name,
String method_name,
String signature)
Add a new Methodref constant to the ConstantPool, if it is not already in there. |
int |
addNameAndType(String name,
String signature)
Add a new NameAndType constant to the ConstantPool if it is not already in there. |
int |
addString(String str)
Add a new String constant to the ConstantPool, if it is not already in there. |
int |
addUtf8(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(String str)
Look for ConstantClass in ConstantPool named `str'. |
int |
lookupDouble(double n)
Look for ConstantDouble in ConstantPool. |
int |
lookupFieldref(String class_name,
String field_name,
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(String class_name,
String method_name,
String signature)
Look for ConstantInterfaceMethodref in ConstantPool. |
int |
lookupLong(long n)
Look for ConstantLong in ConstantPool. |
int |
lookupMethodref(MethodGen method)
|
int |
lookupMethodref(String class_name,
String method_name,
String signature)
Look for ConstantMethodref in ConstantPool. |
int |
lookupNameAndType(String name,
String signature)
Look for ConstantNameAndType in ConstantPool. |
int |
lookupString(String str)
Look for ConstantString in ConstantPool containing String `str'. |
int |
lookupUtf8(String n)
Look for ConstantUtf8 in ConstantPool. |
void |
setConstant(int i,
Constant c)
Use with care! |
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)
cs
- array of given constants, new ones will be appendedpublic ConstantPoolGen(ConstantPool cp)
public ConstantPoolGen()
Method Detail |
---|
protected void adjustSize()
public int lookupString(String str)
str
- String to search for
public int addString(String str)
str
- String to add
public int lookupClass(String str)
str
- String to search for
public int addClass(String str)
str
- Class to add
public int addClass(ObjectType type)
type
- Class to add
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(String n)
n
- Utf8 string to look for
public int addUtf8(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(String name, String signature)
name
- of variable/methodsignature
- of variable/method
public int addNameAndType(String name, String signature)
name
- Name string to addsignature
- signature string to add
public int lookupMethodref(String class_name, String method_name, String signature)
class_name
- Where to find methodmethod_name
- Guess whatsignature
- return and argument types
public int lookupMethodref(MethodGen method)
public int addMethodref(String class_name, String method_name, String signature)
class_name
- class name string to addmethod_name
- method name string to addsignature
- method signature string to add
public int addMethodref(MethodGen method)
public int lookupInterfaceMethodref(String class_name, String method_name, String signature)
class_name
- Where to find methodmethod_name
- Guess whatsignature
- return and argument types
public int lookupInterfaceMethodref(MethodGen method)
public int addInterfaceMethodref(String class_name, String method_name, String signature)
class_name
- class name string to addmethod_name
- method name string to addsignature
- signature string to add
public int addInterfaceMethodref(MethodGen method)
public int lookupFieldref(String class_name, String field_name, String signature)
class_name
- Where to find methodfield_name
- Guess whatsignature
- return and argument types
public int addFieldref(String class_name, String field_name, String signature)
class_name
- class name string to addfield_name
- field name string to addsignature
- signature string to add
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 String toString()
toString
in class Object
public int addConstant(Constant c, ConstantPoolGen cp)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |