KickJava   Java API By Example, From Geeks To Geeks.

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


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: Fields.java,v 1.1.1.1 2003/07/02 15:30:52 apopovic Exp $
22
// =====================================================================
23
//
24
// (history at end)
25
//
26

27 package ch.ethz.prose.filter;
28
29 // used packages
30
import java.lang.reflect.Field JavaDoc;
31 import java.lang.reflect.Member JavaDoc;
32
33 import ch.ethz.prose.engine.JoinPointRequest;
34
35 /**
36  *
37  * Class Fields is a scope for specializers that filters read or
38  * modification accesses to fields: requests which
39  * happen on access of a field. If a request is not
40  * FieldSpecific, a <code>Fields</code> specializer will just accept
41  * them.
42  * <p>
43  * This class is implemented using the <code>MemberS</code> implementation class.
44  *
45  * @version $Revision: 1.1.1.1 $
46  * @author Gerard Roos
47  */

48 public class Fields {
49
50   /**
51    * Return a <code>Fields</code> instance which accepts and generates
52    * joinpoints for fields whose name match <code>regexp</code>.
53    *
54    * @param regexp the regexp to be matched by the field's name.
55    */

56   public static PointCutter named(String JavaDoc regexp)
57     {
58       PointCutter t = new FieldsNamedFilter(regexp);
59       t.setToString("Fields.named(" + regexp + ")");
60       return t;
61     }
62
63   public static PointCutter declaredInClass(String JavaDoc regexp)
64     {
65       PointCutter t = new FieldsInClassFilter(regexp);
66       t.setToString("Fields.declaredInClass(" + regexp + ")");
67       return t;
68     }
69
70   public static PointCutter declaredInClass(Class JavaDoc cls)
71     {
72       PointCutter t = new FieldsInTypeFilter(cls,FieldsInTypeFilter.NO_INHERITANCE);
73       t.setToString("Fields.declaredInClass(" + cls.getName() + ")");
74       return t;
75
76     }
77
78   public static PointCutter declaredInSubclass(Class JavaDoc cls)
79     {
80       PointCutter t = new FieldsInTypeFilter(cls,FieldsInTypeFilter.SUBCLASS_INHERITANCE);
81       t.setToString("Fields.declaredInSubclass(" + cls.getName() + ")");
82       return t;
83
84     }
85
86   public static PointCutter declaredInSuperclass(Class JavaDoc cls)
87     {
88
89       PointCutter t = new FieldsInTypeFilter(cls,FieldsInTypeFilter.SUPERCLASS_INHERITANCE);
90       t.setToString("Fields.declaredInSuperclass(" + cls.getName() + ")");
91       return t;
92     }
93   /**
94    * Return a <code>Fields</code> instance which accepts and generates
95    * joinpoints for fields declared using the specified modifiers.
96    * Look at <code>java.lang.reflect.Modifier</code> to see how
97    * to create a modifier flag.
98    *
99    * @param the modifier combination.
100    */

101   public static PointCutter withModifier(int modifierFlag)
102     {
103       PointCutter t = new FieldsWithModifierFilter(modifierFlag);
104       t.setToString("Fields.withModifier(" + modifierFlag + ")");
105       return t;
106
107     }
108
109
110 }
111
112
113 //======================================================================
114
//
115
// $Log: Fields.java,v $
116
// Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
117
// Imported from ETH Zurich
118
//
119
// Revision 1.2 2003/05/25 11:46:48 popovici
120
// Improved 'toString' presentation of aspects
121
//
122
// Revision 1.1 2003/05/05 13:57:53 popovici
123
// renaming from runes to prose
124
//
125
// Revision 1.2 2003/04/27 13:08:46 popovici
126
// Specializers renamed to PointCutter
127
//
128
// Revision 1.1 2003/04/25 15:15:15 popovici
129
// FieldS renamed to 'Fields'
130
//
131
// Revision 1.16 2003/04/17 14:46:02 popovici
132
// ThiS renamed to This; additional method renamings
133
//
134
// Revision 1.15 2003/04/17 13:59:36 popovici
135
// This class and methods renamed
136
//
137
// Revision 1.14 2003/04/17 13:54:27 popovici
138
// Refactorization of 'ExecutionS' into 'Within' and 'Executions'.
139
// Method names refer now to 'types'
140
//
141
// Revision 1.13 2003/04/17 12:49:34 popovici
142
// Refactoring of the crosscut package
143
// ExceptionCut renamed to ThrowCut
144
// McutSignature is now SignaturePattern
145
//
146
// Revision 1.12 2003/04/17 08:47:44 popovici
147
// Important functionality additions
148
// - Cflow specializers
149
// - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
150
// - Transactional capabilities
151
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
152
// between static and dynamic specializers.
153
// - Functionality pulled up in abstract classes
154
// - Uniformization of advice methods patterns and names
155
//
156
// Revision 1.11 2003/03/05 10:48:46 popovici
157
// Adapted tot the IKS template form
158
//
159
// Revision 1.10 2003/03/04 18:36:23 popovici
160
// Organization of imprts
161
//
162
// Revision 1.9 2003/03/04 18:24:13 popovici
163
// Refactoring of the specializer. De-obfuscation
164
// by exposing the inner classes of the factory methods
165
// The specializer implementations now end in 'filter',
166
// whereas the old factory methods 'xxxS' remain
167
// pure bootstrap objects.
168
//
169
// Revision 1.8 2002/06/07 07:47:43 popovici
170
// Feature change: MemberS.doIsSpecialRequest signature changed to include a JoinPointRequest.
171
// This fixed a bug in MethodS.BEFORE1/MethodS.after, which had no way to distinguish between entries and exits
172
//
173
// Revision 1.7 2002/05/16 09:18:28 popovici
174
// ClasseS and CFlow replaced with Target, This; the crosscut spec package is refactorized. Now all
175
// crosscuts are grouped (abstract definitions + concrete definitions). Crosscuts explicitely are dynamic and static, and
176
// or/Not/And combinations can be created.
177
//
178
// Revision 1.6 2002/05/07 10:46:57 popovici
179
// Reorganization of the Specializer package. All specializer related classes
180
// moved to ch.ethz.inf.crossucut.spec; Classes ORingPointCutter, ANDspecializer and NOTspecializer is
181
// introduced, the static analysis of filtering simplified, because now specializers
182
// contain a field 'filterType' which is propagated to the root of composite specializers. junit packages updated accordingly
183
//
184
// Revision 1.5 2002/03/28 13:48:45 popovici
185
// Mozilla-ified
186
//
187
// Revision 1.4 2002/03/28 12:48:20 popovici
188
// Jakarta regexps instead of gnu regexps
189
//
190
// Revision 1.3 2002/02/21 12:39:50 popovici
191
// Specializer inspection issues:
192
// - CompositeSpecialiers now allow specializer inspection - AbstractCrosscutSpecs are now composite
193
// - AbstractCrosscutSpecs define defaults for isSpecialEvent
194
// to allow inspection of subclasses (of those overrinding the
195
// defaults)
196
//
197
// Revision 1.2 2002/02/05 09:42:35 smarkwal
198
// JVMDI-specific code replaced by JVMAI. Prose-implementation classes and reflection package removed.
199
//
200
// Revision 1.1.1.1 2001/11/29 18:13:18 popovici
201
// Sources from runes
202
//
203
// Revision 1.1.2.2 2001/02/21 13:34:49 popovici
204
// - RE objects are now transient; a String holds the regexp; (better support
205
// for serialization)
206
// - Method 'toString' added to all helper classes.
207
//
208
// Revision 1.1.2.1 2000/11/28 16:44:31 groos
209
// Initial revision.
210
//
211

212
Popular Tags