KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > prose > filter > ExceptionsClassFilter


1 //
2
// This file is part of the prose package.
3
//
4
// The contents of this file are subject to the Mozilla Public License
5
// Version 1.1 (the "License"); you may not use this file except in
6
// compliance with the License. You may obtain a copy of the License at
7
// http://www.mozilla.org/MPL/
8
//
9
// Software distributed under the License is distributed on an "AS IS" basis,
10
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
// for the specific language governing rights and limitations under the
12
// License.
13
//
14
// The Original Code is prose.
15
//
16
// The Initial Developer of the Original Code is Andrei Popovici. Portions
17
// created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
18
// All Rights Reserved.
19
//
20
// Contributor(s):
21
// $Id: ExceptionsClassFilter.java,v 1.2 2004/05/12 09:41:55 anicoara Exp $
22
// =====================================================================
23
//
24
// (history at end)
25
//
26

27 package ch.ethz.prose.filter;
28
29 // used packages
30
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 /**
40  * Class ExceptionsClassFilter XXX
41  *
42  * @version $Revision: 1.2 $
43  * @author Andrei Popovici
44  * @author Angela Nicoara
45  */

46 public
47 class ExceptionsClassFilter extends PointCutter implements JoinPointKinds {
48
49   NameExpression regexp;
50   public ExceptionsClassFilter(String JavaDoc 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     //System.err.println("ExceptionsClassFilter - doIsSpecialRequest -> checking whether " + ((ExceptionCatchRequest)jpr).getExceptionClass() + " matches " + regexp); //angy test
62
//System.err.println("ExceptionsClassFilter - doIsSpecialRequest -> checking whether " + ((ExceptionThrowRequest)jpr).getExceptionClass() + " matches " + regexp); //angy test
63
// only for exception throw and exception catch
64
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 JavaDoc("cannot get unrequested request");
75     }
76     //System.err.println("ExceptionsClassFilter - doIsSpecialRequest ->>" + result); //angy test
77
return result;
78   }
79
80   protected boolean doIsSpecialEvent(CodeJoinPoint jp)
81     {
82       throw new Error JavaDoc("The PointCutter contract is not correct");
83     }
84
85 }
86
87
88 //======================================================================
89
//
90
// $Log: ExceptionsClassFilter.java,v $
91
// Revision 1.2 2004/05/12 09:41:55 anicoara
92
// Remove the README.RVM file
93
//
94
// Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
95
// Imported from ETH Zurich
96
//
97
// Revision 1.3 2003/07/02 12:42:56 anicoara
98
// Added CatchJoinPoint Functionality (Requests, Join-Points, Filters, CatchCuts, Tests)
99
//
100
// Revision 1.2 2003/05/06 15:51:36 popovici
101
// Mozilla-ification
102
//
103
// Revision 1.1 2003/05/05 13:58:03 popovici
104
// renaming from runes to prose
105
//
106
// Revision 1.3 2003/04/27 13:08:50 popovici
107
// Specializers renamed to PointCutter
108
//
109
// Revision 1.2 2003/04/17 12:49:33 popovici
110
// Refactoring of the crosscut package
111
// ExceptionCut renamed to ThrowCut
112
// McutSignature is now SignaturePattern
113
//
114
// Revision 1.1 2003/04/17 08:47:36 popovici
115
// Important functionality additions
116
// - Cflow specializers
117
// - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
118
// - Transactional capabilities
119
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
120
// between static and dynamic specializers.
121
// - Functionality pulled up in abstract classes
122
// - Uniformization of advice methods patterns and names
123
//
124
Popular Tags