FileDocCategorySizeDatePackage
SourceFile.javaAPI DocJava SE 5 API5875Fri Aug 26 14:55:18 BST 2005com.sun.org.apache.bcel.internal.classfile

SourceFile

public final class SourceFile extends Attribute
This class is derived from Attribute and represents a reference to the source file of this class. It is instantiated from the Attribute.readAttribute() method.
version
$Id: SourceFile.java,v 1.1.1.1 2001/10/29 20:00:03 jvanzyl Exp $
author
M. Dahm
see
Attribute

Fields Summary
private int
sourcefile_index
Constructors Summary
public SourceFile(SourceFile c)
Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a physical copy.

    this(c.getNameIndex(), c.getLength(), c.getSourceFileIndex(),
	 c.getConstantPool());
  
SourceFile(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
Construct object from file stream.

param
name_index Index in constant pool to CONSTANT_Utf8
param
length Content length in bytes
param
file Input stream
param
constant_pool Array of constants
throw
IOException

    this(name_index, length, file.readUnsignedShort(), constant_pool);
  
public SourceFile(int name_index, int length, int sourcefile_index, ConstantPool constant_pool)

param
name_index Index in constant pool to CONSTANT_Utf8
param
length Content length in bytes
param
constant_pool Array of constants
param
sourcefile_index Index in constant pool to CONSTANT_Utf8

    super(Constants.ATTR_SOURCE_FILE, name_index, length, constant_pool);
    this.sourcefile_index = sourcefile_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.visitSourceFile(this);
  
public com.sun.org.apache.bcel.internal.classfile.Attributecopy(com.sun.org.apache.bcel.internal.classfile.ConstantPool constant_pool)

return
deep copy of this attribute

    return (SourceFile)clone();
  
public final voiddump(java.io.DataOutputStream file)
Dump source file attribute to file stream in binary format.

param
file Output file stream
throw
IOException

    super.dump(file);
    file.writeShort(sourcefile_index);
  
public final intgetSourceFileIndex()

return
Index in constant pool of source file name.

 return sourcefile_index; 
public final java.lang.StringgetSourceFileName()

return
Source file name.

    ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(sourcefile_index, 
							     Constants.CONSTANT_Utf8);
    return c.getBytes();
  
public final voidsetSourceFileIndex(int sourcefile_index)

param
sourcefile_index.

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

return
String representation

    return "SourceFile(" + getSourceFileName() + ")";