public class ConstantPool extends java.lang.Object implements java.lang.Cloneable, Node
Constant,
ConstantPoolGen| Modifier and Type | Field and Description |
|---|---|
private Constant[] |
constant_pool |
| Constructor and Description |
|---|
ConstantPool(Constant[] constant_pool) |
ConstantPool(java.io.DataInput input)
Read constants from given input stream.
|
| Modifier and Type | Method and Description |
|---|---|
void |
accept(Visitor v)
Called by objects that are traversing the nodes of the tree implicitely
defined by the contents of a Java class.
|
java.lang.String |
constantToString(Constant c)
Resolve constant to a string representation.
|
java.lang.String |
constantToString(int index,
byte tag)
Retrieve constant at `index' from constant pool and resolve it to
a string representation.
|
ConstantPool |
copy() |
void |
dump(java.io.DataOutputStream file)
Dump constant pool to file stream in binary format.
|
private static java.lang.String |
escape(java.lang.String str) |
Constant |
getConstant(int index)
Get constant from constant pool.
|
Constant |
getConstant(int index,
byte tag)
Get constant from constant pool and check whether it has the
expected type.
|
Constant[] |
getConstantPool() |
java.lang.String |
getConstantString(int index,
byte tag)
Get string from constant pool and bypass the indirection of
`ConstantClass' and `ConstantString' objects.
|
int |
getLength() |
void |
setConstant(int index,
Constant constant) |
void |
setConstantPool(Constant[] constant_pool) |
java.lang.String |
toString() |
private Constant[] constant_pool
public ConstantPool(Constant[] constant_pool)
constant_pool - Array of constantspublic ConstantPool(java.io.DataInput input)
throws java.io.IOException,
ClassFormatException
input - Input streamjava.io.IOExceptionClassFormatExceptionpublic void accept(Visitor v)
public java.lang.String constantToString(Constant c) throws ClassFormatException
c - Constant to be printedClassFormatExceptionprivate static java.lang.String escape(java.lang.String str)
public java.lang.String constantToString(int index,
byte tag)
throws ClassFormatException
index - of constant in constant pooltag - expected typeClassFormatExceptionpublic void dump(java.io.DataOutputStream file)
throws java.io.IOException
file - Output file streamjava.io.IOExceptionpublic Constant getConstant(int index)
index - Index in constant poolConstantpublic Constant getConstant(int index, byte tag) throws ClassFormatException
index - Index in constant pooltag - Tag of expected constant, i.e., its typeClassFormatExceptionConstantpublic java.lang.String getConstantString(int index,
byte tag)
throws ClassFormatException
index - Index in constant pooltag - Tag of expected constant, either ConstantClass or ConstantStringClassFormatExceptionConstantClass,
ConstantStringpublic int getLength()
public void setConstant(int index,
Constant constant)
constant - Constant to setpublic void setConstantPool(Constant[] constant_pool)
constant_pool - public java.lang.String toString()
toString in class java.lang.Objectpublic ConstantPool copy()