SourceFileAttributepublic class SourceFileAttribute extends Attribute Encapsulates the SourceFile attribute of a Java class file. |
Fields Summary |
---|
private int | attributeNameIndexindex into the constant pool table containing the name
of this class | private int | attributeLengthlength of this attribute in bytes | private int | sourceFileIndex | private ConstantPoolInfo[] | constantPool |
Constructors Summary |
---|
public SourceFileAttribute(DataInputStream iStream, ConstantPoolInfo[] constantPool, int attributeNameIndex, int attributeLength)Constructor. Reads the SourceFileAttribute attribute from
the class file.
this.attributeNameIndex = attributeNameIndex;
this.attributeLength = attributeLength;
this.constantPool = constantPool;
sourceFileIndex = iStream.readUnsignedShort ();
|
Methods Summary |
---|
public java.lang.String | getSourceFileName()Returns the source filename as a string.
ConstantUtf8Info utf8Info;
utf8Info = (ConstantUtf8Info) constantPool[sourceFileIndex];
return (utf8Info.toString ());
| public java.lang.String | toString(ConstantPoolInfo[] constantPool)Returns the SourceFileAttribute attribute in a nice easy to
read format as a string.
ConstantUtf8Info utf8Info;
String s = new String ("");
utf8Info = (ConstantUtf8Info) constantPool[attributeNameIndex];
s = s + utf8Info.toString () + "=\t";
utf8Info = (ConstantUtf8Info) constantPool[sourceFileIndex];
s = s + utf8Info.toString ();
return s;
|
|