KickJava   Java API By Example, From Geeks To Geeks.

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


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

21 public abstract class LocalVariableCommonAttribute extends AttributeInfo {
22     protected static final int INITIAL_LENGTH = 2;
23
24     protected LocalVariableCommonEntry[] localVariableTable;
25
26     /**
27      * Get the list of local variable associations of the parent <tt>Code</tt>
28      * structure as an array of <tt>LocalVariableCommonEntry</tt> structures.
29      *
30      * @return the array
31      */

32     public LocalVariableCommonEntry[] getLocalVariableEntries() {
33         return localVariableTable;
34     }
35
36     /**
37      * Set the list of local variable associations of the parent <tt>Code</tt>
38      * structure as an array of <tt>LocalVariableCommonEntry</tt> structures.
39      *
40      * @param localVariableEntries the array
41      */

42     public void setLocalVariableEntries(LocalVariableCommonEntry[] localVariableEntries) {
43         this.localVariableTable = localVariableEntries;
44     }
45
46     public void write(DataOutput JavaDoc out)
47             throws InvalidByteCodeException, IOException JavaDoc {
48
49         super.write(out);
50
51         int localVariableTableLength = getLength(localVariableTable);
52         out.writeShort(localVariableTableLength);
53         for (int i = 0; i < localVariableTableLength; i++) {
54             localVariableTable[i].write(out);
55         }
56
57         if (debug) debug("wrote ");
58     }
59 }
60
Popular Tags