00001 package de.fub.bytecode.classfile;
00002
00003 import de.fub.bytecode.Constants;
00004 import java.io.*;
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 public final class SourceFile extends Attribute {
00016 private int sourcefile_index;
00017
00018
00019
00020
00021
00022
00023
00024 public SourceFile(int name_index, int length, int sourcefile_index,
00025 ConstantPool constant_pool)
00026 {
00027 super(ATTR_SOURCE_FILE, name_index, length, constant_pool);
00028 this.sourcefile_index = sourcefile_index;
00029 }
00030
00031
00032
00033
00034
00035
00036
00037
00038 SourceFile(int name_index, int length, DataInputStream file,
00039 ConstantPool constant_pool) throws IOException
00040 {
00041 this(name_index, length, file.readUnsignedShort(), constant_pool);
00042 }
00043
00044
00045
00046
00047 public SourceFile(SourceFile c) {
00048 this(c.getNameIndex(), c.getLength(), c.getSourceFileIndex(),
00049 c.getConstantPool());
00050 }
00051
00052
00053
00054
00055
00056
00057
00058 public void accept(Visitor v) {
00059 v.visitSourceFile(this);
00060 }
00061
00062
00063
00064 public Attribute copy(ConstantPool constant_pool) {
00065 return (SourceFile)clone();
00066 }
00067
00068
00069
00070
00071
00072
00073 public final void dump(DataOutputStream file) throws IOException
00074 {
00075 super.dump(file);
00076 file.writeShort(sourcefile_index);
00077 }
00078
00079
00080
00081 public final int getSourceFileIndex() { return sourcefile_index; }
00082
00083
00084
00085 public final String getSourceFileName() {
00086 ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(sourcefile_index,
00087 CONSTANT_Utf8);
00088 return c.getBytes();
00089 }
00090
00091
00092
00093 public final void setSourceFileIndex(int sourcefile_index) {
00094 this.sourcefile_index = sourcefile_index;
00095 }
00096
00097
00098
00099 public final String toString() {
00100 return "SourceFile(" + getSourceFileName() + ")";
00101 }
00102 }