FileDocCategorySizeDatePackage
ConstantCP.javaAPI DocJava SE 5 API5467Fri Aug 26 14:55:16 BST 2005com.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.1.1 2001/10/29 19:59:58 jvanzyl 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
throw
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
throw
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 + ")";