KickJava   Java API By Example, From Geeks To Geeks.

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


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: FieldsInClassFilter.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.util.*;
31 import java.io.*;
32 import ch.ethz.jvmai.JoinPointKinds;
33 import ch.ethz.jvmai.JoinPoint;
34 import ch.ethz.jvmai.CodeJoinPoint;
35 import ch.ethz.prose.engine.JoinPointRequest;
36 import ch.ethz.prose.engine.FieldAccessRequest;
37 import ch.ethz.prose.engine.FieldModificationRequest;
38
39
40 /**
41  * Class FieldsInClassFilter XXX
42  *
43  * @version $Revision: 1.1.1.1 $
44  * @author Andrei Popovici
45  */

46 public
47 class FieldsInClassFilter extends PointCutter implements JoinPointKinds {
48
49   NameExpression regexp;
50   public FieldsInClassFilter(String JavaDoc cls)
51   {
52     acceptMask = MASK_FIELD_ACCESS_JP | MASK_FIELD_MODIFICATION_JP | MASK_FIELD_JP;
53     mayFilterStaticallyMask = MASK_FIELD_ACCESS_JP | MASK_FIELD_MODIFICATION_JP | MASK_FIELD_JP;
54     canFilterStaticallyMask = MASK_FIELD_ACCESS_JP | MASK_FIELD_MODIFICATION_JP | MASK_FIELD_JP;
55     regexp = new NameExpression(cls);
56   }
57
58   protected boolean doIsSpecialRequest(JoinPointRequest jpr)
59     {
60       // only for field accesses and field modifications
61
int jprType = jpr.getMask() & ( MASK_FIELD_ACCESS_JP | MASK_FIELD_MODIFICATION_JP);
62       switch (jprType)
63     {
64       case MASK_FIELD_ACCESS_JP:
65         return regexp.classMatchesRegexp(((FieldAccessRequest)jpr).getTargetClass());
66       case MASK_FIELD_MODIFICATION_JP:
67         return regexp.classMatchesRegexp(((FieldModificationRequest)jpr).getTargetClass());
68       default: throw new Error JavaDoc("cannot get unrequested request");
69     }
70
71     }
72
73   protected boolean doIsSpecialEvent(CodeJoinPoint jp)
74     {
75       throw new Error JavaDoc("The PointCutter contract is not correct");
76     }
77
78 }
79
80
81 //======================================================================
82
//
83
// $Log: FieldsInClassFilter.java,v $
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:38 popovici
88
// Mozilla-ification
89
//
90
// Revision 1.1 2003/05/05 13:57:58 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:34 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:45 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