net.sf.rej.java.constantpool
Class ConstantPoolInfo

java.lang.Object
  extended by net.sf.rej.java.constantpool.ConstantPoolInfo
Direct Known Subclasses:
ClassInfo, DoubleInfo, FloatInfo, IntegerInfo, LongInfo, NameAndTypeInfo, RefInfo, StringInfo, UTF8Info

public abstract class ConstantPoolInfo
extends java.lang.Object

ConstantPoolInfo is the superclass for all constant pool items.

Author:
Sami Koivu

Field Summary
static int CLASS
           
static int DOUBLE
           
static int FIELD_REF
           
static int FLOAT
           
static int INTEGER
           
static int INTERFACE_METHOD_REF
           
static int LONG
           
static int METHOD_REF
           
static int NAME_AND_TYPE
           
static int STRING
           
static int UTF8
           
 
Method Summary
static ConstantPoolInfo getCPI(ByteParser parser, ConstantPool pool)
          Parse a constant pool info item from a byte parser.
abstract  byte[] getData()
          Return the data of this entry in the form that it can be written to a class file.
 int getType()
          Return the type of this ConstantPoolInfo instance.
abstract  java.lang.String getTypeString()
          Return a String describing the type of this instance.
 java.lang.String getValue()
          Return a String representation of the value of this constant pool entry.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS

public static final int CLASS
See Also:
Constant Field Values

FIELD_REF

public static final int FIELD_REF
See Also:
Constant Field Values

METHOD_REF

public static final int METHOD_REF
See Also:
Constant Field Values

INTERFACE_METHOD_REF

public static final int INTERFACE_METHOD_REF
See Also:
Constant Field Values

STRING

public static final int STRING
See Also:
Constant Field Values

INTEGER

public static final int INTEGER
See Also:
Constant Field Values

FLOAT

public static final int FLOAT
See Also:
Constant Field Values

LONG

public static final int LONG
See Also:
Constant Field Values

DOUBLE

public static final int DOUBLE
See Also:
Constant Field Values

NAME_AND_TYPE

public static final int NAME_AND_TYPE
See Also:
Constant Field Values

UTF8

public static final int UTF8
See Also:
Constant Field Values
Method Detail

getCPI

public static ConstantPoolInfo getCPI(ByteParser parser,
                                      ConstantPool pool)
Parse a constant pool info item from a byte parser.

Parameters:
parser - ByteParser providing the data.
pool - ConstantPool to be passed on the the ConstantPoolInfo object.
Returns:
A subclass of ConstantPoolInfo of the correct type.

getType

public int getType()
Return the type of this ConstantPoolInfo instance. The int value returned corresponds to the public constants defined in this class and also to the byte value that is written to the class file.

Returns:
int type value of this instance.

getValue

public java.lang.String getValue()
Return a String representation of the value of this constant pool entry. Each subclass overwrites this method and returns a value that makes sense for it's context.

Returns:
String value of this entry

getData

public abstract byte[] getData()
Return the data of this entry in the form that it can be written to a class file.

Returns:
byte[] array with data

getTypeString

public abstract java.lang.String getTypeString()
Return a String describing the type of this instance.

Returns:
The type of this entry as a String.