KickJava   Java API By Example, From Geeks To Geeks.

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


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: ExecutionsInMethodFilter.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 ch.ethz.jvmai.CodeJoinPoint;
31 import ch.ethz.jvmai.JoinPointKinds;
32 import ch.ethz.prose.engine.*;
33
34 /**
35  * Class ExecutionsInMethodFilter XXX
36  *
37  * @version $Revision: 1.2 $
38  * @author Andrei Popovici
39  */

40 public
41 class ExecutionsInMethodFilter extends PointCutter implements JoinPointKinds{
42
43   private NameExpression regexp;
44   /**
45    * @exception IllegalArgumentException (runtimeException) thrown if
46    * the regexp is not correctly formatted
47    */

48   public ExecutionsInMethodFilter(String JavaDoc regexp)
49   {
50     this.regexp = new NameExpression(regexp);
51     acceptMask = MASK_ALL_JP;
52     mayFilterStaticallyMask = MASK_METHOD_ENTRY_JP | MASK_METHOD_EXIT_JP | MASK_METHOD_REDEFINE_JP;
53     canFilterStaticallyMask = MASK_METHOD_ENTRY_JP | MASK_METHOD_EXIT_JP | MASK_METHOD_REDEFINE_JP;
54   }
55
56   protected boolean doIsSpecialRequest(JoinPointRequest jpr)
57   {
58       switch(jpr.getMask() & (MASK_METHOD_ENTRY_JP | MASK_METHOD_EXIT_JP | MASK_METHOD_REDEFINE_JP) )
59       {
60         case MASK_METHOD_ENTRY_JP:
61           return regexp.memberMatchesRegexp(((MethodEntryRequest)jpr).getMethod());
62         case MASK_METHOD_EXIT_JP:
63           return regexp.memberMatchesRegexp(((MethodExitRequest)jpr).getMethod());
64             case MASK_METHOD_REDEFINE_JP:
65               return regexp.memberMatchesRegexp(((MethodRedefineRequest)jpr).getMethod());
66         default:
67           throw new Error JavaDoc("illegal request forwarded by the PointCutter");
68       }
69   }
70
71   protected boolean doIsSpecialEvent(CodeJoinPoint jp)
72   {
73       return regexp.memberMatchesRegexp(jp.getMethod());
74   }
75 }
76
77
78 //======================================================================
79
//
80
// $Log: ExecutionsInMethodFilter.java,v $
81
// Revision 1.2 2004/05/12 09:41:55 anicoara
82
// Remove the README.RVM file
83
//
84
// Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
85
// Imported from ETH Zurich
86
//
87
// Revision 1.2 2003/05/06 15:51:37 popovici
88
// Mozilla-ification
89
//
90
// Revision 1.1 2003/05/05 13:58:02 popovici
91
// renaming from runes to prose
92
//
93
// Revision 1.3 2003/04/27 13:08:49 popovici
94
// Specializers renamed to PointCutter
95
//
96
// Revision 1.2 2003/04/17 12:49:33 popovici
97
// Refactoring of the crosscut package
98
// ExceptionCut renamed to ThrowCut
99
// McutSignature is now SignaturePattern
100
//
101
// Revision 1.1 2003/04/17 08:47:42 popovici
102
// Important functionality additions
103
// - Cflow specializers
104
// - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
105
// - Transactional capabilities
106
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
107
// between static and dynamic specializers.
108
// - Functionality pulled up in abstract classes
109
// - Uniformization of advice methods patterns and names
110
//
111
Popular Tags