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 69 public final class CodeException implements Cloneable , Constants, Node { 70 private int start_pc; private int end_pc; private int handler_pc; 75 private int catch_type; 79 82 public CodeException(CodeException c) { 83 this(c.getStartPC(), c.getEndPC(), c.getHandlerPC(), c.getCatchType()); 84 } 85 86 91 CodeException(DataInputStream file) throws IOException 92 { 93 this(file.readUnsignedShort(), file.readUnsignedShort(), 94 file.readUnsignedShort(), file.readUnsignedShort()); 95 } 96 97 107 public CodeException(int start_pc, int end_pc, int handler_pc, 108 int catch_type) 109 { 110 this.start_pc = start_pc; 111 this.end_pc = end_pc; 112 this.handler_pc = handler_pc; 113 this.catch_type = catch_type; 114 } 115 116 123 public void accept(Visitor v) { 124 v.visitCodeException(this); 125 } 126 132 public final void dump(DataOutputStream file) throws IOException 133 { 134 file.writeShort(start_pc); 135 file.writeShort(end_pc); 136 file.writeShort(handler_pc); 137 file.writeShort(catch_type); 138 } 139 140 144 public final int getCatchType() { return catch_type; } 145 146 149 public final int getEndPC() { return end_pc; } 150 151 154 public final int getHandlerPC() { return handler_pc; } 155 156 159 public final int getStartPC() { return start_pc; } 160 161 164 public final void setCatchType(int catch_type) { 165 this.catch_type = catch_type; 166 } 167 168 171 public final void setEndPC(int end_pc) { 172 this.end_pc = end_pc; 173 } 174 175 178 public final void setHandlerPC(int handler_pc) { 179 this.handler_pc = handler_pc; 180 } 181 182 185 public final void setStartPC(int start_pc) { 186 this.start_pc = start_pc; 187 } 188 189 192 public final String toString() { 193 return "CodeException(start_pc = " + start_pc + 194 ", end_pc = " + end_pc + 195 ", handler_pc = " + handler_pc + ", catch_type = " + catch_type + ")"; 196 } 197 198 201 public final String toString(ConstantPool cp, boolean verbose) { 202 String str; 203 204 if(catch_type == 0) 205 str = "<Any exception>(0)"; 206 else 207 str = Utility.compactClassName(cp.getConstantString(catch_type, CONSTANT_Class), false) + 208 (verbose? "(" + catch_type + ")" : ""); 209 210 return start_pc + "\t" + end_pc + "\t" + handler_pc + "\t" + str; 211 } 212 213 public final String toString(ConstantPool cp) { 214 return toString(cp, true); 215 } 216 217 220 public CodeException copy() { 221 try { 222 return (CodeException)clone(); 223 } catch(CloneNotSupportedException e) {} 224 225 return null; 226 } 227 } 228 | Popular Tags |