Overview | Package | Class | Tree | Deprecated | Index | Help
| Apache Tomcat 7.0.29
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tomcat.util.bcel.classfile
Class ConstantPool

    java.lang.Object
      org.apache.tomcat.util.bcel.classfile.ConstantPool

All Implemented Interfaces:
  Serializable, Cloneable

    public class ConstantPool

extends Object
implements Cloneable, Serializable

This class represents the constant pool, i.e., a table of constants, of a parsed classfile. It may contain null references, due to the JVM specification that skips an entry after an 8-byte constant (double, long) entry. Those interested in generating constant pools programatically should see ConstantPoolGen.

Version:
  $Id: ConstantPool.java 1181133 2011-10-10 18:49:14Z markt $
Author:
  M. Dahm
See Also:
  `Constant`, Serialized Form

Method Summary
`String` | `constantToString(Constant c)` Resolve constant to a string representation.
`String` | `constantToString(int index, byte tag)` Retrieve constant at `index' from constant pool and resolve it to a string representation.
`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.
`String` | `getConstantString(int index, byte tag)` Get string from constant pool and bypass the indirection of `ConstantClass' and `ConstantString' objects.
`int` | `getLength()`
`String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Method Detail

### constantToString

    public String constantToString(Constant c)
                            throws ClassFormatException

  Resolve constant to a string representation.

  Parameters:
    `c` - Constant to be printed
  Returns:
    String representation
  Throws:
    `ClassFormatException`

### constantToString

    public String constantToString(int index,
                                   byte tag)
                            throws ClassFormatException

  Retrieve constant at `index' from constant pool and resolve it to a string representation.

  Parameters:
    `index` - of constant in constant pool
    `tag` - expected type
  Returns:
    String representation
  Throws:
    `ClassFormatException`

### getConstant

    public Constant getConstant(int index)

  Get constant from constant pool.

  Parameters:
    `index` - Index in constant pool
  Returns:
    Constant value
  See Also:
    `Constant`

### getConstant

    public Constant getConstant(int index,
                                byte tag)
                         throws ClassFormatException

  Get constant from constant pool and check whether it has the expected type.

  Parameters:
    `index` - Index in constant pool
    `tag` - Tag of expected constant, i.e., its type
  Returns:
    Constant value
  Throws:
    `ClassFormatException`
  See Also:
    `Constant`

### getConstantString

    public String getConstantString(int index,
                                    byte tag)
                             throws ClassFormatException

  Get string from constant pool and bypass the indirection of `ConstantClass' and `ConstantString' objects. I.e. these classes have an index field that points to another entry of the constant pool of type `ConstantUtf8' which contains the real data.

  Parameters:
    `index` - Index in constant pool
    `tag` - Tag of expected constant, either ConstantClass or ConstantString
  Returns:
    Contents of string reference
  Throws:
    `ClassFormatException`
  See Also:
    `ConstantClass`, `ConstantString`

### getLength

    public int getLength()

  Returns:
    Length of constant pool.

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`
  Returns:
    String representation.

Overview | Package | Class | Tree | Deprecated | Index | Help
| Apache Tomcat 7.0.29
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.