KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.gjt.jclasslib.structures.attributes;
8
9 import org.gjt.jclasslib.structures.AbstractStructure;
10 import org.gjt.jclasslib.structures.InvalidByteCodeException;
11
12 import java.io.*;
13
14 /**
15  * Contains common attributes to a local variable table entry structure.
16  *
17  * @author <a HREF="mailto:vitor.carreira@gmail.com">Vitor Carreira</a>
18  * @version $Revision: 1.1 $ $Date: 2004/12/28 13:04:32 $
19  */

20 public abstract class LocalVariableCommonEntry extends AbstractStructure {
21     /**
22      * Length in bytes of a local variable association.
23      */

24     public static final int LENGTH = 10;
25
26     protected int startPc;
27     protected int length;
28     protected int nameIndex;
29     protected int descriptorOrSignatureIndex;
30     protected int index;
31
32     /**
33      * Get the <tt>start_pc</tt> of this local variable association.
34      *
35      * @return the <tt>start_pc</tt>
36      */

37     final public int getStartPc() {
38         return startPc;
39     }
40
41     /**
42      * Set the <tt>start_pc</tt> of this local variable association.
43      *
44      * @param startPc the <tt>start_pc</tt>
45      */

46     final public void setStartPc(int startPc) {
47         this.startPc = startPc;
48     }
49
50     /**
51      * Get the length in bytes of this local variable association.
52      *
53      * @return the length
54      */

55     final public int getLength() {
56         return length;
57     }
58
59     /**
60      * Set the length in bytes of this local variable association.
61      *
62      * @param length the length
63      */

64     final public void setLength(int length) {
65         this.length = length;
66     }
67
68     /**
69      * Get the index of the constant pool entry containing the name of this
70      * local variable.
71      *
72      * @return the index
73      */

74     final public int getNameIndex() {
75         return nameIndex;
76     }
77
78     /**
79      * Set the index of the constant pool entry containing the name of this
80      * local variable.
81      *
82      * @param nameIndex the index
83      */

84     final public void setNameIndex(int nameIndex) {
85         this.nameIndex = nameIndex;
86     }
87
88     /**
89      * Get the index of the constant pool entry containing the descriptor of this
90      * local variable.
91      *
92      * @return the index
93      */

94     final public int getDescriptorOrSignatureIndex() {
95         return descriptorOrSignatureIndex;
96     }
97
98     /**
99      * Get the index of the constant pool entry containing the descriptor of this
100      * local variable.
101      *
102      * @param descriptorIndex the index
103      */

104     final public void setDescriptorOrSignatureIndex(int descriptorIndex) {
105         this.descriptorOrSignatureIndex = descriptorIndex;
106     }
107
108     /**
109      * Get the index of this local variable.
110      *
111      * @return the index
112      */

113     final public int getIndex() {
114         return index;
115     }
116
117     /**
118      * Set the index of this local variable.
119      * Set the index of this local variable.
120      */

121     final public void setIndex(int index) {
122         this.index = index;
123     }
124
125     final public void read(DataInput in)
126             throws InvalidByteCodeException, IOException {
127         super.read(in);
128
129         startPc = in.readUnsignedShort();
130         length = in.readUnsignedShort();
131         nameIndex = in.readUnsignedShort();
132         descriptorOrSignatureIndex = in.readUnsignedShort();
133         index = in.readUnsignedShort();
134
135         if (debug) debug("read ");
136     }
137
138     final public void write(DataOutput out)
139             throws InvalidByteCodeException, IOException {
140         super.write(out);
141
142         out.writeShort(startPc);
143         out.writeShort(length);
144         out.writeShort(nameIndex);
145         out.writeShort(descriptorOrSignatureIndex);
146         out.writeShort(index);
147
148         if (debug) debug("wrote ");
149     }
150
151     protected String JavaDoc printAccessFlagsVerbose(int accessFlags) {
152         if (accessFlags != 0)
153             throw new RuntimeException JavaDoc("Access flags should be zero: " +
154                     Integer.toHexString(accessFlags));
155         return "";
156     }
157 }
158
Popular Tags