FileDocCategorySizeDatePackage
ConstantClass.javaAPI DocJava SE 5 API5203Fri Aug 26 14:55:16 BST 2005com.sun.org.apache.bcel.internal.classfile

ConstantClass

public final class ConstantClass extends Constant implements ConstantObject
This class is derived from the abstract Constant class and represents a reference to a (external) class.
version
$Id: ConstantClass.java,v 1.1.1.1 2001/10/29 19:59:58 jvanzyl Exp $
author
M. Dahm
see
Constant

Fields Summary
private int
name_index
Constructors Summary
public ConstantClass(ConstantClass c)
Initialize from another object.

    this(c.getNameIndex());
  
ConstantClass(DataInputStream file)
Initialize instance from file data.

param
file Input stream
throw
IOException

    
    this(file.readUnsignedShort());
  
public ConstantClass(int name_index)

param
name_index Name index in constant pool

    super(Constants.CONSTANT_Class);
    this.name_index = name_index;
  
Methods Summary
public voidaccept(com.sun.org.apache.bcel.internal.classfile.Visitor v)
Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.

param
v Visitor object

    v.visitConstantClass(this);
  
public final voiddump(java.io.DataOutputStream file)
Dump constant class to file stream in binary format.

param
file Output file stream
throw
IOException

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

return
dereferenced string

    return (String)getConstantValue(cp);
  
public java.lang.ObjectgetConstantValue(com.sun.org.apache.bcel.internal.classfile.ConstantPool cp)

return
String object

    Constant c = cp.getConstant(name_index, Constants.CONSTANT_Utf8);
    return ((ConstantUtf8)c).getBytes();
  
public final intgetNameIndex()

return
Name index in constant pool of class name.

 return name_index; 
public final voidsetNameIndex(int name_index)

param
name_index.

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

return
String representation.

    return super.toString() + "(name_index = " + name_index + ")";