harpoon.IR.RawClass
Class Constant

java.lang.Object
  extended by harpoon.IR.RawClass.Constant
Direct Known Subclasses:
ConstantFieldref, ConstantInterfaceMethodref, ConstantMethodref, ConstantNameAndType, ConstantUtf8, ConstantValue

public abstract class Constant
extends Object

The Constant class represents a single item in the constant pool of a class file. It is a super-class for the various specific constant pool item types.

Drawn from The Java Virtual Machine Specification.

Version:
$Id: Constant.java,v 1.3 2003/09/05 21:45:16 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
ConstantUtf8, ConstantInteger, ConstantFloat, ConstantLong, ConstantDouble, ConstantClass, ConstantString, ConstantFieldref, ConstantMethodref, ConstantInterfaceMethodref, ConstantNameAndType

Field Summary
protected  ClassFile parent
          ClassFile in which this Constant is found.
 
Constructor Summary
protected Constant(ClassFile parent)
           
 
Method Summary
 int entrySize()
           
 void print(PrintWriter pw, int indent)
          Pretty-print this constant.
static Constant read(ClassFile p, ClassDataInputStream in)
          Read a single Constant item from an input class bytecode file, and return an object instance corresponding to it.
 String toString()
          Create a human-readable representation for the Constant.
abstract  void write(ClassDataOutputStream out)
          Write a single constant pool item to a class bytecode file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected ClassFile parent
ClassFile in which this Constant is found.

Constructor Detail

Constant

protected Constant(ClassFile parent)
Method Detail

entrySize

public int entrySize()

read

public static Constant read(ClassFile p,
                            ClassDataInputStream in)
                     throws IOException
Read a single Constant item from an input class bytecode file, and return an object instance corresponding to it.

Throws:
IOException - on error reading from input stream.

write

public abstract void write(ClassDataOutputStream out)
                    throws IOException
Write a single constant pool item to a class bytecode file.

Throws:
IOException - on error writing to output stream.

toString

public String toString()
Create a human-readable representation for the Constant.

Overrides:
toString in class Object

print

public void print(PrintWriter pw,
                  int indent)
Pretty-print this constant.