1 27 package ch.ethz.prose.filter; 28 29 import java.util.*; 31 import java.io.*; 32 import ch.ethz.jvmai.JoinPointKinds; 33 import ch.ethz.jvmai.JoinPoint; 34 import ch.ethz.jvmai.CodeJoinPoint; 35 import ch.ethz.prose.engine.JoinPointRequest; 36 import ch.ethz.prose.engine.ExceptionThrowRequest; 37 import ch.ethz.prose.engine.ExceptionCatchRequest; 38 39 46 public 47 class ExceptionsClassFilter extends PointCutter implements JoinPointKinds { 48 49 NameExpression regexp; 50 public ExceptionsClassFilter(String cls) 51 { 52 acceptMask = MASK_EXCEPTION_THROW_ARGS_JP | MASK_EXCEPTION_CATCH_ARGS_JP; 53 mayFilterStaticallyMask = MASK_EXCEPTION_THROW_ARGS_JP | MASK_EXCEPTION_CATCH_ARGS_JP; 54 canFilterStaticallyMask = MASK_EXCEPTION_THROW_ARGS_JP | MASK_EXCEPTION_CATCH_ARGS_JP; 55 56 regexp = new NameExpression(cls); 57 } 58 59 protected boolean doIsSpecialRequest(JoinPointRequest jpr) 60 { 61 boolean result; 65 int jprType = jpr.getMask() & ( MASK_EXCEPTION_THROW_ARGS_JP | MASK_EXCEPTION_CATCH_ARGS_JP); 66 switch (jprType) 67 { 68 case MASK_EXCEPTION_THROW_ARGS_JP: 69 result = regexp.classMatchesRegexp(((ExceptionThrowRequest)jpr).getExceptionClass()); 70 break; 71 case MASK_EXCEPTION_CATCH_ARGS_JP: 72 result = regexp.classMatchesRegexp(((ExceptionCatchRequest)jpr).getExceptionClass()); 73 break; 74 default: throw new Error ("cannot get unrequested request"); 75 } 76 return result; 78 } 79 80 protected boolean doIsSpecialEvent(CodeJoinPoint jp) 81 { 82 throw new Error ("The PointCutter contract is not correct"); 83 } 84 85 } 86 87 88 | Popular Tags |