1 package com.sun.org.apache.bcel.internal.classfile; 2 3 56 57 import com.sun.org.apache.bcel.internal.Constants; 58 import java.io.*; 59 60 68 public final class LocalVariable implements Constants, Cloneable , Node { 69 private int start_pc; private int length; 71 private int name_index; private int signature_index; private int index; 76 77 private ConstantPool constant_pool; 78 79 83 public LocalVariable(LocalVariable c) { 84 this(c.getStartPC(), c.getLength(), c.getNameIndex(), 85 c.getSignatureIndex(), c.getIndex(), c.getConstantPool()); 86 } 87 88 93 LocalVariable(DataInputStream file, ConstantPool constant_pool) 94 throws IOException 95 { 96 this(file.readUnsignedShort(), file.readUnsignedShort(), 97 file.readUnsignedShort(), file.readUnsignedShort(), 98 file.readUnsignedShort(), constant_pool); 99 } 100 101 109 public LocalVariable(int start_pc, int length, int name_index, 110 int signature_index, int index, 111 ConstantPool constant_pool) 112 { 113 this.start_pc = start_pc; 114 this.length = length; 115 this.name_index = name_index; 116 this.signature_index = signature_index; 117 this.index = index; 118 this.constant_pool = constant_pool; 119 } 120 121 128 public void accept(Visitor v) { 129 v.visitLocalVariable(this); 130 } 131 132 138 public final void dump(DataOutputStream file) throws IOException 139 { 140 file.writeShort(start_pc); 141 file.writeShort(length); 142 file.writeShort(name_index); 143 file.writeShort(signature_index); 144 file.writeShort(index); 145 } 146 147 150 public final ConstantPool getConstantPool() { return constant_pool; } 151 152 155 public final int getLength() { return length; } 156 157 160 public final String getName() { 161 ConstantUtf8 c; 162 163 c = (ConstantUtf8)constant_pool.getConstant(name_index, CONSTANT_Utf8); 164 return c.getBytes(); 165 } 166 167 170 public final int getNameIndex() { return name_index; } 171 172 175 public final String getSignature() { 176 ConstantUtf8 c; 177 c = (ConstantUtf8)constant_pool.getConstant(signature_index, 178 CONSTANT_Utf8); 179 return c.getBytes(); 180 } 181 182 185 public final int getSignatureIndex() { return signature_index; } 186 187 190 public final int getIndex() { return index; } 191 192 195 public final int getStartPC() { return start_pc; } 196 197 200 public final void setConstantPool(ConstantPool constant_pool) { 201 this.constant_pool = constant_pool; 202 } 203 204 207 public final void setLength(int length) { 208 this.length = length; 209 } 210 211 214 public final void setNameIndex(int name_index) { 215 this.name_index = name_index; 216 } 217 218 221 public final void setSignatureIndex(int signature_index) { 222 this.signature_index = signature_index; 223 } 224 225 228 public final void setIndex(int index) { this.index = index; } 229 230 233 public final void setStartPC(int start_pc) { 234 this.start_pc = start_pc; 235 } 236 237 240 public final String toString() { 241 String name = getName(), signature = Utility.signatureToString(getSignature()); 242 243 return "LocalVariable(start_pc = " + start_pc + ", length = " + length + 244 ", index = " + index + ":" + signature + " " + name + ")"; 245 } 246 247 250 public LocalVariable copy() { 251 try { 252 return (LocalVariable)clone(); 253 } catch(CloneNotSupportedException e) {} 254 255 return null; 256 } 257 } 258 | Popular Tags |