1 26 package net.sf.javaguard.classfile; 27 28 import java.io.*; 29 30 31 36 public class LocalVariableTableAttrInfo extends AttrInfo { 37 38 private int tableLength; 39 40 private LocalVariableInfo[] variableTable; 41 42 43 44 45 50 protected LocalVariableTableAttrInfo(ClassFile cf, int attrNameIndex, int attrLength) { 51 super(cf, attrNameIndex, attrLength); 52 } 53 54 55 56 57 60 protected String getAttrName() { 61 return ATTR_LocalVariableTable; 62 } 63 64 65 66 67 71 protected void setTableLength(int len) { 72 tableLength = len; 73 } 74 75 76 80 protected int getTableLength() { 81 return tableLength; 82 } 83 84 85 86 90 protected void setLocalVariableTable(LocalVariableInfo[] table) { 91 variableTable = table; 92 } 93 94 95 99 protected LocalVariableInfo[] getLocalVariableTable() { 100 return variableTable; 101 } 102 103 104 105 106 110 protected void markUtf8RefsInInfo(ConstantPool pool) { 111 for (int i = 0; i < getTableLength(); i++) { 112 getLocalVariableTable()[i].markUtf8Refs(pool); 113 } 114 } 115 116 117 118 119 123 protected void readInfo(DataInput din) 124 throws IOException { 125 setTableLength(din.readUnsignedShort()); 126 LocalVariableInfo[] table = new LocalVariableInfo[getTableLength()]; 127 for (int i = 0; i < getTableLength(); i++) { 128 table[i] = LocalVariableInfo.create(din); 129 } 130 setLocalVariableTable(table); 131 } 132 133 134 139 public void writeInfo(DataOutput dout) 140 throws IOException { 141 dout.writeShort(getTableLength()); 142 for (int i = 0; i < getTableLength(); i++) { 143 getLocalVariableTable()[i].write(dout); 144 } 145 } 146 147 148 149 150 154 public void dump(PrintWriter pw, ClassFile cf) { 155 pw.println(getAttrName()); 156 pw.print("Number of entries: "); 157 pw.println(getTableLength()); 158 for (int i=0; i<getTableLength(); i++) { 159 getLocalVariableTable()[i].dump(pw, cf); 160 } 161 } 162 } 163 | Popular Tags |