FileDocCategorySizeDatePackage
JConstantPool.javaAPI DocphoneME MR2 API (J2ME)3573Wed May 02 18:00:40 BST 2007com.sun.satsa.jcrmic.classfile.constants

JConstantPool

public class JConstantPool extends Object
This class represents constant pool. It defines a set of get and add methods to search or add a constant.

Fields Summary
private JConstant[]
constants
Constant ppol entries.
Constructors Summary
public JConstantPool(int size)
Constructor.

param
size constant pool size.

        constants = new JConstant[size];
    
Methods Summary
public JConstantgetAt(int index)
Returns constant pool entry.

param
index entry index
return
the entry


        return constants[index];
    
public JConstantClassgetConstantClass(int index)
Returns constant.

param
index entry index
return
the entry

        JConstant constant = getAt(index);

        if (constant instanceof JConstantClass)
            return (JConstantClass) constant;
        else
            return null;
    
public JConstantNameAndTypegetConstantNameAndType(int index)
Returns constant.

param
index entry index
return
the entry

        JConstant constant = getAt(index);

        if (constant instanceof JConstantNameAndType)
            return (JConstantNameAndType) constant;
        else
            return null;
    
public JConstantUtf8getConstantUtf8(int index)
Returns constant.

param
index entry index
return
the entry

        JConstant constant = getAt(index);

        if (constant instanceof JConstantUtf8)
            return (JConstantUtf8) constant;
        else
            return null;
    
public voidparse(java.io.DataInputStream dis)
Parses the constant pool.

param
dis input stream
throws
IOException if I/O exception occurs

        // note:  constants start at index 1

        for (int i = 1; i < constants.length; i++) {
            int tag = dis.readUnsignedByte();

            constants[i] = JConstant.create(tag, this);
            constants[i].parse(dis);


            // If a Constant_Long_info or Constant_Double_info
            // structure is the item in the constant pool table
            // at index n, then the next index n+1 must be
            // considered invalid and must not be used
            if ((tag == JConstant.CONSTANT_DOUBLE) ||
                    (tag == JConstant.CONSTANT_LONG)) {
                i++;
            }
        }