00001 package de.fub.bytecode.classfile;
00002
00003 import de.fub.bytecode.Constants;
00004 import java.io.*;
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 public final class CodeException implements Cloneable, Constants {
00016 private int start_pc;
00017 private int end_pc;
00018 private int handler_pc;
00019
00020
00021 private int catch_type;
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 public CodeException(int start_pc, int end_pc, int handler_pc,
00036 int catch_type)
00037 {
00038 this.start_pc = start_pc;
00039 this.end_pc = end_pc;
00040 this.handler_pc = handler_pc;
00041 this.catch_type = catch_type;
00042 }
00043
00044
00045
00046 public CodeException(CodeException c) {
00047 this(c.getStartPC(), c.getEndPC(), c.getHandlerPC(), c.getCatchType());
00048 }
00049
00050
00051
00052
00053
00054 CodeException(DataInputStream file) throws IOException
00055 {
00056 this(file.readUnsignedShort(), file.readUnsignedShort(),
00057 file.readUnsignedShort(), file.readUnsignedShort());
00058 }
00059
00060
00061
00062
00063
00064
00065
00066 public void accept(Visitor v) {
00067 v.visitCodeException(this);
00068 }
00069
00070
00071
00072 public CodeException copy() {
00073 try {
00074 return (CodeException)clone();
00075 } catch(CloneNotSupportedException e) {}
00076
00077 return null;
00078 }
00079
00080
00081
00082
00083
00084
00085 public final void dump(DataOutputStream file) throws IOException
00086 {
00087 file.writeShort(start_pc);
00088 file.writeShort(end_pc);
00089 file.writeShort(handler_pc);
00090 file.writeShort(catch_type);
00091 }
00092
00093
00094
00095
00096 public final int getCatchType() { return catch_type; }
00097
00098
00099
00100 public final int getEndPC() { return end_pc; }
00101
00102
00103
00104 public final int getHandlerPC() { return handler_pc; }
00105
00106
00107
00108 public final int getStartPC() { return start_pc; }
00109
00110
00111
00112 public final void setCatchType(int catch_type) {
00113 this.catch_type = catch_type;
00114 }
00115
00116
00117
00118 public final void setEndPC(int end_pc) {
00119 this.end_pc = end_pc;
00120 }
00121
00122
00123
00124 public final void setHandlerPC(int handler_pc) {
00125 this.handler_pc = handler_pc;
00126 }
00127
00128
00129
00130 public final void setStartPC(int start_pc) {
00131 this.start_pc = start_pc;
00132 }
00133
00134
00135
00136 public final String toString() {
00137 return "CodeException(start_pc = " + start_pc +
00138 ", end_pc = " + end_pc +
00139 ", handler_pc = " + handler_pc + ", catch_type = " + catch_type + ")";
00140 }
00141 public final String toString(ConstantPool cp) {
00142 return toString(cp, true);
00143 }
00144
00145
00146
00147 public final String toString(ConstantPool cp, boolean verbose) {
00148 String str;
00149
00150 if(catch_type == 0)
00151 str = "<Any exception>(0)";
00152 else
00153 str = Utility.compactClassName(cp.getConstantString(catch_type, CONSTANT_Class)) +
00154 (verbose? "(" + catch_type + ")" : "");
00155
00156 return start_pc + "\t" + end_pc + "\t" + handler_pc + "\t" + str;
00157 }
00158 }