KickJava   Java API By Example, From Geeks To Geeks.

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


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

47 public
48 class FieldsWithModifierFilter extends PointCutter implements JoinPointKinds {
49
50   int theModifier;
51   public FieldsWithModifierFilter(int modifier)
52   {
53     acceptMask = MASK_FIELD_ACCESS_JP | MASK_FIELD_MODIFICATION_JP | MASK_FIELD_JP;
54     mayFilterStaticallyMask = MASK_FIELD_ACCESS_JP | MASK_FIELD_MODIFICATION_JP | MASK_FIELD_JP;
55     canFilterStaticallyMask = MASK_FIELD_ACCESS_JP | MASK_FIELD_MODIFICATION_JP | MASK_FIELD_JP;
56     theModifier = modifier;
57   }
58
59
60   protected boolean doIsSpecialRequest(JoinPointRequest jpr)
61     {
62       // only for field accesses and field modifications
63
int jprType = jpr.getMask() & ( MASK_FIELD_ACCESS_JP | MASK_FIELD_MODIFICATION_JP);
64       int crtModifier;
65       switch (jprType)
66     {
67       case MASK_FIELD_ACCESS_JP:
68         crtModifier = ((FieldAccessRequest)jpr).getField().getModifiers();
69         break;
70       case MASK_FIELD_MODIFICATION_JP:
71         crtModifier = ((FieldModificationRequest)jpr).getField().getModifiers();
72         break;
73       default: throw new Error JavaDoc("cannot get unrequested request");
74     }
75
76
77       return (crtModifier & theModifier) == theModifier;
78     }
79
80   protected boolean doIsSpecialEvent(CodeJoinPoint jp)
81     {
82       throw new Error JavaDoc("The PointCutter contract is not correct");
83     }
84
85 }
86
87
88 //======================================================================
89
//
90
// $Log: FieldsWithModifierFilter.java,v $
91
// Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
92
// Imported from ETH Zurich
93
//
94
// Revision 1.2 2003/05/06 15:51:39 popovici
95
// Mozilla-ification
96
//
97
// Revision 1.1 2003/05/05 13:57:54 popovici
98
// renaming from runes to prose
99
//
100
// Revision 1.3 2003/04/27 13:08:47 popovici
101
// Specializers renamed to PointCutter
102
//
103
// Revision 1.2 2003/04/17 12:49:31 popovici
104
// Refactoring of the crosscut package
105
// ExceptionCut renamed to ThrowCut
106
// McutSignature is now SignaturePattern
107
//
108
// Revision 1.1 2003/04/17 08:47:47 popovici
109
// Important functionality additions
110
// - Cflow specializers
111
// - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
112
// - Transactional capabilities
113
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
114
// between static and dynamic specializers.
115
// - Functionality pulled up in abstract classes
116
// - Uniformization of advice methods patterns and names
117
//
118
Popular Tags