KickJava   Java API By Example, From Geeks To Geeks.

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


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: ANDingPointCutter.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.CodeJoinPoint;
34 import ch.ethz.jvmai.JoinPoint;
35 import ch.ethz.prose.engine.JoinPointRequest;
36
37
38 /**
39  * Class ANDPointCutter is a <code>PointCutter</code>. It
40  * modells the 'AND' combination of two other PointCutters.
41  *
42  * @version $Revision: 1.2 $
43  * @author Andrei Popovici
44  */

45 public
46 class ANDingPointCutter extends PointCutter implements ch.ethz.jvmai.JoinPointKinds {
47
48   PointCutter spec1;
49   PointCutter spec2;
50     public ANDingPointCutter(PointCutter spec1, PointCutter spec2)
51     {
52       if (spec1 == null || spec2 == null)
53         throw new IllegalArgumentException JavaDoc("Null Pointer argument in ANDPointCutter.<init>");
54       this.spec1=spec1;
55       this.spec2=spec2;
56       acceptMask = spec1.acceptMask & spec2.acceptMask;
57       mayFilterStaticallyMask = spec1.mayFilterStaticallyMask | spec2.mayFilterStaticallyMask;
58       canFilterStaticallyMask = spec1.canFilterStaticallyMask & spec2.canFilterStaticallyMask;
59     }
60
61   /** Return the two members of this AND PointCutter */
62       public List JavaDoc memberPointFilters()
63       {
64       Vector JavaDoc result = new Vector JavaDoc();
65       result.add(spec1);
66       result.add(spec2);
67       return result;
68       }
69
70    /** Return true if all specializers that do static filtering
71      * (see <code>filterType</code>)) and both consider that the
72      * request is special.
73      *
74      */

75     protected boolean doIsSpecialRequest(JoinPointRequest r1)
76     {
77       // return true as default. However, this result
78
// means 'undefined'. A correct implementation
79
// of composite specialzers will NOT evaluate this
80
// result.
81
// we get here IF AND ONLY IF (spec1.mayFilter | spec2.mayFilter) is fits the r1.mask
82
// in case it 0, then the abstract crosscut specializer has already
83
// said 'yes'.
84
// the following conditions reads as follows:
85
// (if spec1 may filter r1 AND it actually filters it) OR (spec3 may filter ..)
86
return
87           (spec1.isSpecialRequest(r1)) && (spec2.isSpecialRequest(r1));
88
89     }
90
91
92     /** Return true if all PointCutters that do dynamic
93      * filtering (see <code>filterType</code>)
94      * consider <code>e1</code> as special.
95      *
96      * @return true if all dynamic sub-PointCutters agree that e1 is a
97      * special event.
98      */

99     protected boolean doIsSpecialEvent(CodeJoinPoint e1)
100     {
101
102       return
103         (spec1.isSpecialEvent(e1))
104         &&
105         (spec2.isSpecialEvent(e1));
106
107     }
108
109   public String JavaDoc toString()
110     {
111       return "(" + spec1.toString() + ") AND (" + spec2.toString() + ")";
112     }
113 }
114
115
116
117
118
119 //======================================================================
120
//
121
// $Log: ANDingPointCutter.java,v $
122
// Revision 1.2 2003/07/17 13:11:08 apopovic
123
// refactorization: from PointFilter.memberSpecializers to PointFilter.memberPointFilters;
124
// improved documentation (removed references to specializers)
125
//
126
// Revision 1.1.1.1 2003/07/02 15:30:51 apopovic
127
// Imported from ETH Zurich
128
//
129
// Revision 1.2 2003/05/06 15:51:34 popovici
130
// Mozilla-ification
131
//
132
// Revision 1.1 2003/05/05 13:57:59 popovici
133
// renaming from runes to prose
134
//
135
// Revision 1.1 2003/04/27 13:08:48 popovici
136
// Specializers renamed to PointCutter
137
//
138
// Revision 1.5 2003/04/17 12:49:35 popovici
139
// Refactoring of the crosscut package
140
// ExceptionCut renamed to ThrowCut
141
// McutSignature is now SignaturePattern
142
//
143
// Revision 1.4 2003/04/17 08:47:24 popovici
144
// Important functionality additions
145
// - Cflow specializers
146
// - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
147
// - Transactional capabilities
148
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
149
// between static and dynamic specializers.
150
// - Functionality pulled up in abstract classes
151
// - Uniformization of advice methods patterns and names
152
//
153
// Revision 1.3 2003/03/04 18:36:24 popovici
154
// Organization of imprts
155
//
156
// Revision 1.2 2003/03/04 11:27:20 popovici
157
// Important refactorization step (march):
158
// - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
159
// - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
160
// structures
161
//
162
// Revision 1.1 2002/05/07 10:46:55 popovici
163
// Reorganization of the Specializer package. All specializer related classes
164
// moved to ch.ethz.inf.crossucut.spec; Classes ORingPointCutter, ANDspecializer and NOTspecializer is
165
// introduced, the static analysis of filtering simplified, because now specializers
166
// contain a field 'filterType' which is propagated to the root of composite specializers. junit packages updated accordingly
167
//
168
Popular Tags