KickJava   Java API By Example, From Geeks To Geeks.

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


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: NegatingPointCutter.java,v 1.3 2003/07/17 13:11:08 apopovic Exp $
22
// =====================================================================
23
//
24
// (history at end)
25
//
26

27 package ch.ethz.prose.filter;
28
29 // used packages
30
import java.util.List JavaDoc;
31 import java.util.Vector JavaDoc;
32
33 import ch.ethz.jvmai.JoinPoint;
34 import ch.ethz.jvmai.CodeJoinPoint;
35 import ch.ethz.prose.engine.JoinPointRequest;
36
37 /**
38  * Class NegaintPointCuter negates a PointCutter.
39  * It returns a <code>memberPointFilters()</code>
40  * collection with only one member (the argument to the constructor) and
41  * negates only active filters. (That is, if the filter is not doing dynamic
42  * filtering, the result is undefined).
43  *
44  * @version $Revision: 1.3 $
45  * @author Andrei Popovici
46  */

47 public
48 class NegatingPointCutter extends PointCutter {
49
50   PointCutter spec1;
51
52   /** Create a PointCutter that negates the filtering behavior of
53    * s1. <code>s1</code> is the only member PointCutter.
54    */

55   public NegatingPointCutter(PointCutter s1)
56     {
57       if (s1 == null)
58     throw new IllegalArgumentException JavaDoc("NegatingPointCutter.<init>: s1 is null");
59
60       this.acceptMask = s1.acceptMask;
61       this.mayFilterStaticallyMask=s1.mayFilterStaticallyMask;
62       this.canFilterStaticallyMask=s1.canFilterStaticallyMask;
63       spec1=s1;
64     }
65
66   /** Returns the inner PointCutter, passed to the constructor. */
67   public List JavaDoc memberPointFilters()
68     {
69       Vector JavaDoc result = new Vector JavaDoc();
70       result.add(spec1);
71       return result;
72     }
73
74   /** Negates the <code>isSpecialRequest</code> of the member PointFilter
75     * <em>if the PointFilter is doing static filtering</em>.
76     *
77     * @return <code>!r1.isSpecialRequest(r1)</code>, if spec1 is
78     * doing static filtering (see <code>filterType</code>). If
79     * spec1 is not doing static filtering, the result is undefined.
80     */

81   protected boolean doIsSpecialRequest(JoinPointRequest r1)
82     {
83       // we get here if and only if we accept this request
84
// and it is clear that we MAY filter this. Well,
85
return !spec1.isSpecialRequest(r1);
86     }
87
88   /** Negates the <code>isSpecialEvent</code> of e1.
89    *
90    * @return <code>!spec1.isSpecialRequest(e1)</code>, if spec1 is
91    * doing dynamic filtering (see <code>filterType</code>). If
92    * spec1 is not doing dynamic filtering, the result is undefined.
93    *
94    */

95   protected boolean doIsSpecialEvent(CodeJoinPoint e1)
96     {
97       // we get here if we are accepting this event,
98
// AND we cannot filter statically. The olny
99
// sensible thing is to ask..
100
return !spec1.isSpecialEvent(e1);
101     }
102
103     public String JavaDoc toString()
104     {
105     return "(!" + spec1.toString() +")";
106     }
107
108 }
109
110
111 //======================================================================
112
//
113
// $Log: NegatingPointCutter.java,v $
114
// Revision 1.3 2003/07/17 13:11:08 apopovic
115
// refactorization: from PointFilter.memberSpecializers to PointFilter.memberPointFilters;
116
// improved documentation (removed references to specializers)
117
//
118
// Revision 1.2 2003/07/11 12:24:04 apopovic
119
// Added 'toString' to NegatingSpec
120
//
121
// Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
122
// Imported from ETH Zurich
123
//
124
// Revision 1.2 2003/05/06 15:51:40 popovici
125
// Mozilla-ification
126
//
127
// Revision 1.1 2003/05/05 13:57:56 popovici
128
// renaming from runes to prose
129
//
130
// Revision 1.1 2003/04/27 13:08:50 popovici
131
// Specializers renamed to PointCutter
132
//
133
// Revision 1.6 2003/04/17 12:49:35 popovici
134
// Refactoring of the crosscut package
135
// ExceptionCut renamed to ThrowCut
136
// McutSignature is now SignaturePattern
137
//
138
// Revision 1.5 2003/04/17 08:47:50 popovici
139
// Important functionality additions
140
// - Cflow specializers
141
// - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
142
// - Transactional capabilities
143
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
144
// between static and dynamic specializers.
145
// - Functionality pulled up in abstract classes
146
// - Uniformization of advice methods patterns and names
147
//
148
// Revision 1.4 2003/03/04 18:24:14 popovici
149
// Refactoring of the specializer. De-obfuscation
150
// by exposing the inner classes of the factory methods
151
// The specializer implementations now end in 'filter',
152
// whereas the old factory methods 'xxxS' remain
153
// pure bootstrap objects.
154
//
155
// Revision 1.3 2003/03/04 11:27:23 popovici
156
// Important refactorization step (march):
157
// - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
158
// - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
159
// structures
160
//
161
// Revision 1.2 2002/05/28 15:52:55 popovici
162
// Bug fix. The constructor used the uninitialized spec1 private variable
163
//
164
// Revision 1.1 2002/05/07 10:46:58 popovici
165
// Reorganization of the Specializer package. All specializer related classes
166
// moved to ch.ethz.inf.crossucut.spec; Classes ORingPointCutter, ANDspecializer and NOTspecializer is
167
// introduced, the static analysis of filtering simplified, because now specializers
168
// contain a field 'filterType' which is propagated to the root of composite specializers. junit packages updated accordingly
169
//
170
Popular Tags