1 27 package ch.ethz.prose.filter; 28 29 import org.apache.regexp.RE; 31 import org.apache.regexp.RESyntaxException; 32 33 import ch.ethz.jvmai.ExceptionJoinPoint; 34 import ch.ethz.jvmai.ExceptionCatchJoinPoint; 35 import ch.ethz.jvmai.JoinPoint; 36 import ch.ethz.prose.engine.ExceptionThrowRequest; 37 import ch.ethz.prose.engine.ExceptionCatchRequest; 38 import ch.ethz.prose.engine.JoinPointRequest; 39 40 47 public 48 class Exceptions { 49 50 protected static Class throwableClass; 52 static 53 { 54 try 55 { 56 throwableClass = Class.forName("java.lang.Throwable"); 57 } 58 catch (ClassNotFoundException e) 59 { 60 System.err.println(e); 61 e.printStackTrace(); 62 } 63 } 64 65 66 67 68 69 70 76 public static PointCutter type(String regexp) 77 { 78 PointCutter t = new ExceptionsClassFilter(regexp); 79 t.setToString("Exceptions.type(" + regexp + ")"); 80 return t; 81 } 82 83 89 public static PointCutter type(Class cls) 90 { 91 PointCutter t = new ExceptionTypeFilter(cls, ExceptionTypeFilter.NO_INHERITANCE); 92 t.setToString("Exceptions.type(" + cls.getName() + ")"); 93 return t; 94 } 95 96 102 public static PointCutter subtypeOf(Class cls) 103 { 104 PointCutter t = new ExceptionTypeFilter(cls, ExceptionTypeFilter.SUBCLASS_INHERITANCE); 105 t.setToString("Exceptions.subtypeOf(" + cls.getName() + ")"); 106 return t; 107 } 108 109 public static PointCutter supertypeOf(Class cls) 110 { 111 PointCutter t = new ExceptionTypeFilter(cls, ExceptionTypeFilter.SUPERCLASS_INHERITANCE); 112 t.setToString("Exceptions.superTypeOf(" + cls.getName() + ")"); 113 return t; 114 } 115 116 public static PointCutter withMessage(String msg) 117 { 118 PointCutter t = new ExceptionMessageFilter(msg); 119 return t; 120 } 121 122 123 } 124 125 126 | Popular Tags |