KickJava   Java API By Example, From Geeks To Geeks.

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


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.InvalidByteCodeException;
10
11 import java.io.DataInput JavaDoc;
12 import java.io.IOException JavaDoc;
13
14 /**
15  * Describes an <tt>LocalVariableTypeTable</tt> attribute 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 class LocalVariableTypeTableAttribute extends LocalVariableCommonAttribute {
21
22     /**
23      * Name of the attribute as in the corresponding constant pool entry.
24      */

25     public static final String JavaDoc ATTRIBUTE_NAME = "LocalVariableTypeTable";
26
27     /**
28      * Get the list of local variable associations of the parent <tt>Code</tt>
29      * structure as an array of <tt>LocalVariableTypeTableEntry</tt> structures.
30      *
31      * @return the array
32      */

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

43     public void setLocalVariableTypeTable(LocalVariableTypeTableEntry[] localVariableTypeTable) {
44         this.localVariableTable = localVariableTypeTable;
45     }
46
47     public void read(DataInput JavaDoc in)
48             throws InvalidByteCodeException, IOException JavaDoc {
49         super.read(in);
50
51         int localVariableTypeTableLength = in.readUnsignedShort();
52         localVariableTable = new LocalVariableTypeTableEntry[localVariableTypeTableLength];
53         for (int i = 0; i < localVariableTypeTableLength; i++) {
54             localVariableTable[i] = LocalVariableTypeTableEntry.create(in, classFile);
55         }
56
57         if (debug) debug("read ");
58     }
59
60     public int getAttributeLength() {
61         return INITIAL_LENGTH + getLength(localVariableTable) * LocalVariableTypeTableEntry.LENGTH;
62     }
63
64     protected void debug(String JavaDoc message) {
65         super.debug(message + "LocalVariableTypeTable attribute with " +
66                 getLength(localVariableTable) + " entries");
67     }
68 }
69
Popular Tags