KickJava   Java API By Example, From Geeks To Geeks.

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


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: FieldsInTypeFilter.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 FieldsInTypeFilter XXX
42  *
43  * @version $Revision: 1.1.1.1 $
44  * @author Andrei Popovici
45  */

46 public
47 class FieldsInTypeFilter extends PointCutter implements JoinPointKinds{
48
49   final public static int SUBCLASS_INHERITANCE = 1;
50   final public static int SUPERCLASS_INHERITANCE = 2;
51   final public static int NO_INHERITANCE = 3;
52
53   private int inheritanceType;
54   private Class JavaDoc subOrSuperClass;
55   /**
56    * XXX
57    * @param XXX XXX
58    */

59   public FieldsInTypeFilter(Class JavaDoc cls, int inhType)
60   {
61     this.inheritanceType = inhType;
62     this.subOrSuperClass = cls;
63     acceptMask = MASK_FIELD_ACCESS_JP | MASK_FIELD_MODIFICATION_JP | MASK_FIELD_JP;
64     mayFilterStaticallyMask = MASK_FIELD_ACCESS_JP | MASK_FIELD_MODIFICATION_JP | MASK_FIELD_JP;
65     canFilterStaticallyMask = MASK_FIELD_ACCESS_JP | MASK_FIELD_MODIFICATION_JP | MASK_FIELD_JP;
66   }
67
68
69   protected boolean doIsSpecialRequest(JoinPointRequest jpr)
70     {
71       Class JavaDoc declaringClass;
72       switch (jpr.getMask() & (MASK_FIELD_ACCESS_JP | MASK_FIELD_MODIFICATION_JP))
73     {
74       case MASK_FIELD_ACCESS_JP:
75         declaringClass = ((FieldAccessRequest)jpr).getField().getDeclaringClass();
76         break;
77       case MASK_FIELD_MODIFICATION_JP:
78         declaringClass = ((FieldModificationRequest)jpr).getField().getDeclaringClass();
79         break;
80       default:
81           throw new Error JavaDoc("FielsInTypeFilter.doIsSpecialReq:unrequested request");
82     }
83
84       switch(inheritanceType)
85     {
86       case SUBCLASS_INHERITANCE: return subOrSuperClass.isAssignableFrom(declaringClass);
87       case SUPERCLASS_INHERITANCE:return declaringClass.isAssignableFrom(subOrSuperClass);
88       case NO_INHERITANCE: return subOrSuperClass.equals(declaringClass);
89       default:
90         throw new Error JavaDoc("Illegal state Exception");
91     }
92     }
93
94   protected boolean doIsSpecialEvent(CodeJoinPoint jpr)
95     {
96       throw new Error JavaDoc("PointCutter did not fullfil its contract");
97     }
98
99
100
101
102 }
103
104
105 //======================================================================
106
//
107
// $Log: FieldsInTypeFilter.java,v $
108
// Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
109
// Imported from ETH Zurich
110
//
111
// Revision 1.2 2003/05/06 15:51:39 popovici
112
// Mozilla-ification
113
//
114
// Revision 1.1 2003/05/05 13:57:46 popovici
115
// renaming from runes to prose
116
//
117
// Revision 1.3 2003/04/27 13:08:47 popovici
118
// Specializers renamed to PointCutter
119
//
120
// Revision 1.2 2003/04/17 12:49:32 popovici
121
// Refactoring of the crosscut package
122
// ExceptionCut renamed to ThrowCut
123
// McutSignature is now SignaturePattern
124
//
125
// Revision 1.1 2003/04/17 08:47:46 popovici
126
// Important functionality additions
127
// - Cflow specializers
128
// - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
129
// - Transactional capabilities
130
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
131
// between static and dynamic specializers.
132
// - Functionality pulled up in abstract classes
133
// - Uniformization of advice methods patterns and names
134
//
135
Popular Tags