1 7 34 35 package com.sun.tools.example.debug.tty; 36 37 import com.sun.jdi.ReferenceType; 38 import com.sun.jdi.request.*; 39 40 import java.util.ArrayList ; 41 import java.util.List ; 42 import java.util.Iterator ; 43 44 class ExceptionSpec extends EventRequestSpec { 45 private boolean notifyCaught; 46 private boolean notifyUncaught; 47 48 private ExceptionSpec(ReferenceTypeSpec refSpec) { 49 this(refSpec, true, true); 50 } 51 52 ExceptionSpec(ReferenceTypeSpec refSpec, 53 boolean notifyCaught, 54 boolean notifyUncaught) { 55 super(refSpec); 56 this.notifyCaught = notifyCaught; 57 this.notifyUncaught = notifyUncaught; 58 } 59 60 63 EventRequest resolveEventRequest(ReferenceType refType) { 64 EventRequestManager em = refType.virtualMachine().eventRequestManager(); 65 ExceptionRequest excReq = em.createExceptionRequest(refType, 66 notifyCaught, 67 notifyUncaught); 68 excReq.enable(); 69 return excReq; 70 } 71 72 public boolean notifyCaught() { 73 return notifyCaught; 74 } 75 76 public boolean notifyUncaught() { 77 return notifyUncaught; 78 } 79 80 public int hashCode() { 81 int result = 17; 83 result = (37 * result) + (notifyCaught() ? 0: 1); 84 result = (37 * result) + (notifyUncaught() ? 0: 1); 85 result = (37 * result) + refSpec.hashCode(); 86 return result; 87 } 88 89 public boolean equals(Object obj) { 90 if (obj instanceof ExceptionSpec) { 91 ExceptionSpec es = (ExceptionSpec)obj; 92 93 if (refSpec.equals(es.refSpec) && 94 (this.notifyCaught() == es.notifyCaught()) && 95 (this.notifyUncaught() == es.notifyUncaught())) { 96 return true; 97 } 98 } 99 return false; 100 } 101 102 public String toString() { 103 String s; 104 if (notifyCaught && !notifyUncaught) { 105 s = MessageOutput.format("exceptionSpec caught", 106 refSpec.toString()); 107 } else if (notifyUncaught && !notifyCaught) { 108 s = MessageOutput.format("exceptionSpec uncaught", 109 refSpec.toString()); 110 } else { 111 s = MessageOutput.format("exceptionSpec all", 112 refSpec.toString()); 113 } 114 return s; 115 } 116 } 117 | Popular Tags |