KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > jclasslib > structures > attributes > SourceFileAttribute


1 /*
2     This library is free software; you can redistribute it and/or
3     modify it under the terms of the GNU General Public
4     License as published by the Free Software Foundation; either
5     version 2 of the license, or (at your option) any later version.
6 */

7
8 package org.gjt.jclasslib.structures.attributes;
9
10 import org.gjt.jclasslib.structures.AttributeInfo;
11 import org.gjt.jclasslib.structures.InvalidByteCodeException;
12
13 import java.io.*;
14
15 /**
16     Describes a <tt>SourceFile</tt> attribute structure.
17  
18     @author <a HREF="mailto:jclasslib@ej-technologies.com">Ingo Kegel</a>
19     @version $Revision: 1.4 $ $Date: 2003/08/18 07:52:05 $
20 */

21 public class SourceFileAttribute extends AttributeInfo {
22
23     /** Name of the attribute as in the corresponding constant pool entry. */
24     public static final String JavaDoc ATTRIBUTE_NAME = "SourceFile";
25
26     private static final int LENGTH = 2;
27     
28     private int sourcefileIndex;
29     
30     /**
31         Get the constant pool index of the name of the source file.
32         @return the index
33      */

34     public int getSourcefileIndex() {
35         return sourcefileIndex;
36     }
37
38     /**
39         Set the constant pool index of the name of the source file.
40         @param sourcefileIndex the index
41      */

42     public void setSourcefileIndex(int sourcefileIndex) {
43         this.sourcefileIndex = sourcefileIndex;
44     }
45
46     public void read(DataInput in)
47         throws InvalidByteCodeException, IOException {
48             
49         sourcefileIndex = in.readUnsignedShort();
50         if (debug) debug("read ");
51     }
52
53     public void write(DataOutput out)
54         throws InvalidByteCodeException, IOException {
55         
56         super.write(out);
57         out.writeShort(sourcefileIndex);
58         if (debug) debug("wrote ");
59     }
60
61     public int getAttributeLength() {
62         return LENGTH;
63     }
64
65     protected void debug(String JavaDoc message) {
66         super.debug(message + "SourceFile attribute with sourcefile_index " + sourcefileIndex);
67     }
68
69 }
70
Popular Tags