1 32 33 package com.jeantessier.classreader; 34 35 import java.io.*; 36 37 import org.apache.log4j.*; 38 39 public class SourceFile_attribute extends Attribute_info { 40 private int sourceFileIndex; 41 42 public SourceFile_attribute(Classfile classfile, Visitable owner, DataInputStream in) throws IOException { 43 super(classfile, owner); 44 45 int byteCount = in.readInt(); 46 Logger.getLogger(getClass()).debug("Attribute length: " + byteCount); 47 48 sourceFileIndex = in.readUnsignedShort(); 49 Logger.getLogger(getClass()).debug("Source file: " + sourceFileIndex + " (" + getSourceFile() + ")"); 50 } 51 52 public int getSourceFileIndex() { 53 return sourceFileIndex; 54 } 55 56 public UTF8_info getRawSourceFile() { 57 return (UTF8_info) getClassfile().getConstantPool().get(getSourceFileIndex()); 58 } 59 60 public String getSourceFile() { 61 return getRawSourceFile().toString(); 62 } 63 64 public String toString() { 65 return "Source file \"" + getSourceFile() + "\""; 66 } 67 68 public void accept(Visitor visitor) { 69 visitor.visitSourceFile_attribute(this); 70 } 71 } 72 73 | Popular Tags |