1 52 53 package com.go.trove.classfile; 54 55 import java.io.*; 56 57 66 class SourceFileAttr extends Attribute { 67 private String mFileName; 68 69 private ConstantUTFInfo mSourcefile; 70 71 public SourceFileAttr(ConstantPool cp, String fileName) { 72 super(cp, SOURCE_FILE); 73 74 mFileName = fileName; 75 mSourcefile = ConstantUTFInfo.make(cp, fileName); 76 } 77 78 81 public String getFileName() { 82 return mFileName; 83 } 84 85 88 public ConstantUTFInfo getFileNameConstant() { 89 return mSourcefile; 90 } 91 92 95 public int getLength() { 96 return 2; 97 } 98 99 public void writeDataTo(DataOutput dout) throws IOException { 100 dout.writeShort(mSourcefile.getIndex()); 101 } 102 103 static Attribute define(ConstantPool cp, 104 String name, 105 int length, 106 DataInput din) throws IOException { 107 108 int index = din.readUnsignedShort(); 109 if ((length -= 2) > 0) { 110 din.skipBytes(length); 111 } 112 113 String filename = ((ConstantUTFInfo)cp.getConstant(index)).getValue(); 114 115 return new SourceFileAttr(cp, filename); 116 } 117 } 118 | Popular Tags |