Package com.tonic.parser.attribute
Class SourceFileAttribute
- java.lang.Object
-
- com.tonic.parser.attribute.Attribute
-
- com.tonic.parser.attribute.SourceFileAttribute
-
public class SourceFileAttribute extends Attribute
The SourceFile attribute: the constant-pool index of the source file name Utf8.
-
-
Constructor Summary
Constructors Constructor Description SourceFileAttribute(ClassFile classFile, String name, MemberEntry parent, int nameIndex, int length)Creates the attribute shell for parsing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClassFilegetClassFile()intgetSourceFileIndex()voidread(ClassFile classFile, int length)Reads the attribute data from the class file.StringresolveSourceFileName(int sourceFileIndex)Helper method to retrieve the source file name from the constant pool.StringtoString()voidupdateLength()Recomputes the attribute length field from the current in-memory content.
-
-
-
Constructor Detail
-
SourceFileAttribute
public SourceFileAttribute(ClassFile classFile, String name, MemberEntry parent, int nameIndex, int length)
Creates the attribute shell for parsing.- Parameters:
classFile- the class the attribute belongs toname- the attribute nameparent- the member the attribute belongs to, or null for a class-level attributenameIndex- constant-pool index of the name Utf8length- the attribute length in bytes
-
-
Method Detail
-
getSourceFileIndex
public int getSourceFileIndex()
- Returns:
- the source file index
-
getClassFile
public ClassFile getClassFile()
- Returns:
- the class file
-
read
public void read(ClassFile classFile, int length)
Description copied from class:AttributeReads the attribute data from the class file.
-
updateLength
public void updateLength()
Description copied from class:AttributeRecomputes the attribute length field from the current in-memory content.- Specified by:
updateLengthin classAttribute
-
resolveSourceFileName
public String resolveSourceFileName(int sourceFileIndex)
Helper method to retrieve the source file name from the constant pool.- Parameters:
sourceFileIndex- The index of the Utf8Item in the constant pool.- Returns:
- The source file name as a String.
-
-