FileDocCategorySizeDatePackage
ConstantClass.javaAPI DocJava SE 6 API5247Tue Jun 10 00:22:16 BST 2008com.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.2.1 2005/07/31 23:46:28 jeffsuttor 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
throws
IOException

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

param
name_index Name index in constant pool. Should refer to a ConstantUtf8.

    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
throws
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 + ")";