KickJava   Java API By Example, From Geeks To Geeks.

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


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: ORingPointCutter.java,v 1.2 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 ORingPointCutter composes two sub-PointCuters into a composite
39  * PointCutter using OR semantic.
40  *
41  * @version $Revision: 1.2 $
42  * @author Andrei Popovici
43  */

44
45 class ORingPointCutter extends PointCutter {
46
47   PointCutter spec1;
48   PointCutter spec2;
49
50     /** Create a composite PointCutter with <code>spec1</code> and <code>spec2</code>
51      * as members, composed using 'OR' semantics.
52      */

53     protected ORingPointCutter(PointCutter spec1, PointCutter spec2)
54     {
55       if (spec1 == null || spec2 == null)
56         throw new IllegalArgumentException JavaDoc("Null Pointer argument in ANDPointCutter.<init>");
57
58       this.acceptMask = spec1.acceptMask | spec2.acceptMask;
59       mayFilterStaticallyMask = spec1.mayFilterStaticallyMask | spec2.mayFilterStaticallyMask;
60       canFilterStaticallyMask = spec1.canFilterStaticallyMask & spec2.canFilterStaticallyMask;
61
62       this.spec1=spec1;
63       this.spec2=spec2;
64     }
65
66
67     /** Return the two members of this OR PointCutter. */
68     public List JavaDoc memberPointFilters()
69       {
70       Vector JavaDoc result = new Vector JavaDoc();
71       result.add(spec1);
72       result.add(spec2);
73       return result;
74       }
75
76     /** Retrn true if either of the specializers passed in the crosscut
77      * does static filtering and one of them consider <code>r1</code> as special.
78      *
79      * @return true if either of the sub-specializers agree that r1 is a static
80      * special request.
81      */

82     protected boolean doIsSpecialRequest(JoinPointRequest r1)
83     {
84
85       // we get here IF AND ONLY IF (spec1.mayFilter | spec2.mayFilter) is fits the r1.mask
86
// in case it 0, then the abstract crosscut specializer has already
87
// said 'yes'.
88
// the following conditions reads as follows:
89
// (if spec1 may filter r1 AND it actually filters it) OR (spec3 may filter ..)
90
return
91           (spec1.isSpecialRequest(r1))
92         ||
93           (spec2.isSpecialRequest(r1));
94     }
95
96     /** Retrn true if either of the memer PointCutters passed in the crosscut
97      * does dynamic filtering and one of them consider <code>e1</code> as special.
98      * undefined.
99      *
100      * @return true if either of the sub-specializers agree that r1 is a dynamic
101      * special event.
102      */

103     protected boolean doIsSpecialEvent(CodeJoinPoint e1)
104       {
105     // we get here IF AND ONLY IF this is an accepted event AND
106
// either of spec1, spec2 cannot filter e1 (spec1.canFilter & spec2.canFilter) & r1.mask == 0
107
// in this case, the following condition reads
108
// as follows: if spec1 can filte said 'yes'.
109
// the following conditions reads as follows:
110
// if spec1 has filtered this event filtered e1 then return true,
111
/// else filter-it with is special event else
112
// if spec2 has filtered this event statically return true else
113
// ask is special event
114
return
115         (spec1.isSpecialEvent(e1))
116         ||
117         (spec2.isSpecialEvent(e1));
118
119       }
120
121     public String JavaDoc toString()
122       {
123     return "(" + spec1.toString() + ") OR (" + spec2.toString() + ")";
124       }
125
126
127   }
128
129
130
131
132 //======================================================================
133
//
134
// $Log: ORingPointCutter.java,v $
135
// Revision 1.2 2003/07/17 13:11:08 apopovic
136
// refactorization: from PointFilter.memberSpecializers to PointFilter.memberPointFilters;
137
// improved documentation (removed references to specializers)
138
//
139
// Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
140
// Imported from ETH Zurich
141
//
142
// Revision 1.2 2003/05/06 15:51:41 popovici
143
// Mozilla-ification
144
//
145
// Revision 1.1 2003/05/05 13:57:48 popovici
146
// renaming from runes to prose
147
//
148
// Revision 1.1 2003/04/27 13:08:45 popovici
149
// Specializers renamed to PointCutter
150
//
151
// Revision 1.5 2003/04/17 12:49:35 popovici
152
// Refactoring of the crosscut package
153
// ExceptionCut renamed to ThrowCut
154
// McutSignature is now SignaturePattern
155
//
156
// Revision 1.4 2003/04/17 08:47:50 popovici
157
// Important functionality additions
158
// - Cflow specializers
159
// - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
160
// - Transactional capabilities
161
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
162
// between static and dynamic specializers.
163
// - Functionality pulled up in abstract classes
164
// - Uniformization of advice methods patterns and names
165
//
166
// Revision 1.3 2003/03/04 18:24:14 popovici
167
// Refactoring of the specializer. De-obfuscation
168
// by exposing the inner classes of the factory methods
169
// The specializer implementations now end in 'filter',
170
// whereas the old factory methods 'xxxS' remain
171
// pure bootstrap objects.
172
//
173
// Revision 1.2 2003/03/04 11:27:23 popovici
174
// Important refactorization step (march):
175
// - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
176
// - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
177
// structures
178
//
179
// Revision 1.1 2002/05/07 10:46:59 popovici
180
// Reorganization of the Specializer package. All specializer related classes
181
// moved to ch.ethz.inf.crossucut.spec; Classes ORingPointCutter, ANDspecializer and NOTspecializer is
182
// introduced, the static analysis of filtering simplified, because now specializers
183
// contain a field 'filterType' which is propagated to the root of composite specializers. junit packages updated accordingly
184
//
185
Popular Tags