Top Description Fields Constructors Methods
org.aspectj.apache.bcel.classfile

public final Class SourceFile

extends Attribute
Class Inheritance
Imports
java.io.DataInputStream, .DataOutputStream, .IOException, org.aspectj.apache.bcel.Constants

This class is derived from Attribute and represents a reference to the source file of this class. At most one SourceFile attribute should appear per classfile. The intention of this class is that it is instantiated from the Attribute.readAttribute() method.
Author
M. Dahm
Version
$Id: SourceFile.java,v 1.5 2009/09/15 19:40:12 aclement Exp $
See Also
Attribute

Field Summary

Modifier and TypeField and Description
private int
Inherited from org.aspectj.apache.bcel.classfile.Attribute:
cpoollengthnameIndexNoAttributestag

Constructor Summary

AccessConstructor and Description
public
SourceFile(SourceFile c)

Initialize from another object.

pack-priv
SourceFile(int
Index in constant pool to CONSTANT_Utf8
name_index
,
int
Content length in bytes
length
,
DataInputStream
Input stream
file
,
ConstantPool
Array of constants
constant_pool
)

Construct object from file stream.

public
SourceFile(int
Index in constant pool to CONSTANT_Utf8, which should represent the string "SourceFile".
name_index
,
int
Content length in bytes, the value should be 2.
length
,
int
Index in constant pool to CONSTANT_Utf8. This string will be interpreted as the name of the file from which this class was compiled. It will not be interpreted as indicating the name of the directory contqining the file or an absolute path; this information has to be supplied the consumer of this attribute - in many cases, the JVM.
sourcefile_index
,
ConstantPool
The constant pool that this attribute is associated with.
constant_pool
)

Method Summary

Modifier and TypeMethod and Description
public void
accept(ClassVisitor
Visitor object
v
)

Implements abstract org.aspectj.apache.bcel.classfile.Attribute.accept.

Implements org.aspectj.apache.bcel.classfile.Node.accept.

Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class.
public final void
dump(DataOutputStream
Output file stream
file
)

Overrides org.aspectj.apache.bcel.classfile.Attribute.dump.

Dump source file attribute to file stream in binary format.
public final int

Returns:

Index in constant pool of source file name.
getSourceFileIndex
()

public final String

Returns:

Source file name.
getSourceFileName
()

public final void
setSourceFileIndex(int sourcefile_index)

public final String

Returns:

String representation
toString
()

Overrides org.aspectj.apache.bcel.classfile.Attribute.toString.

Returns a string representation of the object.
Inherited from org.aspectj.apache.bcel.classfile.Attribute:
getConstantPoolgetLengthgetNamegetNameIndexgetTagreadAttribute

Field Detail

sourcefile_indexback to summary
private int sourcefile_index

Constructor Detail

SourceFileback to 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.

SourceFileback to summary
pack-priv SourceFile(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException

Construct object from file stream.

Parameters
name_index:int

Index in constant pool to CONSTANT_Utf8

length:int

Content length in bytes

file:DataInputStream

Input stream

constant_pool:ConstantPool

Array of constants

SourceFileback to summary
public SourceFile(int name_index, int length, int sourcefile_index, ConstantPool constant_pool)
Parameters
name_index:int

Index in constant pool to CONSTANT_Utf8, which should represent the string "SourceFile".

length:int

Content length in bytes, the value should be 2.

sourcefile_index:int

Index in constant pool to CONSTANT_Utf8. This string will be interpreted as the name of the file from which this class was compiled. It will not be interpreted as indicating the name of the directory contqining the file or an absolute path; this information has to be supplied the consumer of this attribute - in many cases, the JVM.

constant_pool:ConstantPool

The constant pool that this attribute is associated with.

Method Detail

acceptback to summary
public void accept(ClassVisitor v)

Implements abstract org.aspectj.apache.bcel.classfile.Attribute.accept.

Implements org.aspectj.apache.bcel.classfile.Node.accept.

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.

Parameters
v:ClassVisitor

Visitor object

Annotations
@Override
dumpback to summary
public final void dump(DataOutputStream file) throws IOException

Overrides org.aspectj.apache.bcel.classfile.Attribute.dump.

Dump source file attribute to file stream in binary format.

Parameters
file:DataOutputStream

Output file stream

Annotations
@Override
getSourceFileIndexback to summary
public final int getSourceFileIndex()
Returns:int

Index in constant pool of source file name.

getSourceFileNameback to summary
public final String getSourceFileName()
Returns:String

Source file name.

setSourceFileIndexback to summary
public final void setSourceFileIndex(int sourcefile_index)
toStringback to summary
public final String toString()

Overrides org.aspectj.apache.bcel.classfile.Attribute.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

String representation

Annotations
@Override