1 27 package ch.ethz.prose.engine; 28 29 import ch.ethz.jvmai.JVMAspectInterface; 31 import ch.ethz.jvmai.JoinPointKinds; 32 33 34 45 public 46 class ExceptionThrowRequest extends JoinPointRequest implements JoinPointKinds { 47 48 private final Class exceptionClass; 49 50 57 public ExceptionThrowRequest(Class cls, JoinPointManager o) 58 throws ClassCastException 59 { 60 super(o); 61 62 try { 63 if (!(Class.forName("java.lang.Throwable").isAssignableFrom(cls))) 64 throw new ClassCastException ("ClassCastException: Class must be of subtype 'Throwable'"); 65 } 66 catch (ClassNotFoundException e) 67 { 68 System.err.println(e); 69 e.printStackTrace(); 70 } 71 72 exceptionClass = cls; 73 } 74 75 public int getMask() 76 { 77 return MASK_EXCEPTION_THROW_ARGS_JP; 78 } 79 80 public String getKind() 81 { 82 return KIND_EXCEPTION_THROW_ARGS_JP; 83 } 84 85 86 public Class getExceptionClass() 87 { 88 return exceptionClass; 89 } 90 91 protected void setWatch(Object listeners) 92 { 93 owner.getAspectInterface().setExceptionThrowWatch(exceptionClass, listeners); 94 } 95 96 protected void clearWatch() 97 { 98 owner.getAspectInterface().clearExceptionThrowWatch(exceptionClass); 99 } 100 101 public boolean equals(Object other) 102 { 103 ExceptionThrowRequest otherReq; 104 if (other instanceof ExceptionThrowRequest) 105 otherReq = (ExceptionThrowRequest)other; 106 else 107 return false; 108 return exceptionClass.equals(otherReq.getExceptionClass()); 109 } 110 111 public int hashCode() 112 { 113 return exceptionClass.hashCode(); 114 } 115 116 public String toString() 117 { 118 return "ExceptionThrowRequest on Class " + exceptionClass.getName(); 119 } 120 121 } 122 123 124 | Popular Tags |