FileDocCategorySizeDatePackage
ConstantCP.javaAPI DocJava SE 6 API5472Tue Jun 10 00:22:16 BST 2008com.sun.org.apache.bcel.internal.classfile

ConstantCP

public abstract class ConstantCP extends Constant
Abstract super class for Fieldref and Methodref constants.
version
$Id: ConstantCP.java,v 1.1.2.1 2005/07/31 23:46:28 jeffsuttor Exp $
author
M. Dahm
see
ConstantFieldref
see
ConstantMethodref
see
ConstantInterfaceMethodref

Fields Summary
protected int
class_index
References to the constants containing the class and the field signature
protected int
name_and_type_index
Constructors Summary
public ConstantCP(ConstantCP c)
Initialize from another object.

    this(c.getTag(), c.getClassIndex(), c.getNameAndTypeIndex());
  
ConstantCP(byte tag, DataInputStream file)
Initialize instance from file data.

param
tag Constant type tag
param
file Input stream
throws
IOException

    this(tag, file.readUnsignedShort(), file.readUnsignedShort());
  
protected ConstantCP(byte tag, int class_index, int name_and_type_index)

param
class_index Reference to the class containing the field
param
name_and_type_index and the field signature

    super(tag);
    this.class_index         = class_index;
    this.name_and_type_index = name_and_type_index;
  
Methods Summary
public final voiddump(java.io.DataOutputStream file)
Dump constant field reference to file stream in binary format.

param
file Output file stream
throws
IOException

    file.writeByte(tag);
    file.writeShort(class_index);
    file.writeShort(name_and_type_index);
  
public java.lang.StringgetClass(com.sun.org.apache.bcel.internal.classfile.ConstantPool cp)

return
Class this field belongs to.

    return cp.constantToString(class_index, Constants.CONSTANT_Class);
  
public final intgetClassIndex()

return
Reference (index) to class this field or method belongs to.

 return class_index; 
public final intgetNameAndTypeIndex()

return
Reference (index) to signature of the field.

 return name_and_type_index; 
public final voidsetClassIndex(int class_index)

param
class_index points to Constant_class

    this.class_index = class_index;
  
public final voidsetNameAndTypeIndex(int name_and_type_index)

param
name_and_type_index points to Constant_NameAndType

    this.name_and_type_index = name_and_type_index;
  
public final java.lang.StringtoString()

return
String representation.

    return super.toString() + "(class_index = " + class_index +
      ", name_and_type_index = " + name_and_type_index + ")";