1 2 package ch.ethz.prose.engine; 3 4 import ch.ethz.jvmai.JVMAspectInterface; 6 import ch.ethz.jvmai.JoinPointKinds; 7 8 9 20 public 21 class ExceptionCatchRequest extends JoinPointRequest implements JoinPointKinds { 22 23 private final Class exceptionClass; 24 25 32 public ExceptionCatchRequest(Class cls, JoinPointManager o) 33 throws ClassCastException 34 { 35 super(o); 36 37 try { 38 if (!(Class.forName("java.lang.Throwable").isAssignableFrom(cls))) 39 throw new ClassCastException ("ClassCastException: Class must be of subtype 'Throwable'"); 40 } 41 catch (ClassNotFoundException e) 42 { 43 System.err.println(e); 44 e.printStackTrace(); 45 } 46 47 exceptionClass = cls; 48 } 49 50 public int getMask() 51 { 52 return MASK_EXCEPTION_CATCH_ARGS_JP; 53 } 54 55 public String getKind() 56 { 57 return KIND_EXCEPTION_CATCH_ARGS_JP; 58 } 59 60 public Class getExceptionClass() 61 { 62 return exceptionClass; 63 } 64 65 protected void setWatch(Object listeners) 66 { 67 owner.getAspectInterface().setExceptionCatchWatch(exceptionClass, listeners); 68 } 69 70 protected void clearWatch() 71 { 72 owner.getAspectInterface().clearExceptionCatchWatch(exceptionClass); 73 } 74 75 public boolean equals(Object other) 76 { 77 ExceptionCatchRequest otherReq; 78 if (other instanceof ExceptionCatchRequest) 79 otherReq = (ExceptionCatchRequest)other; 80 else 81 return false; 82 return exceptionClass.equals(otherReq.getExceptionClass()); 83 } 84 85 public int hashCode() 86 { 87 return exceptionClass.hashCode(); 88 } 89 90 public String toString() 91 { 92 return "ExceptionCatchRequest on Class " + exceptionClass.getName(); 93 } 94 95 } 96 | Popular Tags |