KickJava   Java API By Example, From Geeks To Geeks.

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


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: ObjectFilter.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 import ch.ethz.jvmai.JoinPoint;
29 import ch.ethz.jvmai.JoinPointKinds;
30 import ch.ethz.prose.engine.JoinPointRequest;
31 import ch.ethz.jvmai.CodeJoinPoint;
32
33 /** An abstract class that uses an "ObjectExtractor"
34  * to get an object from a join-point and filter
35  * (dynamically) the event.
36  */

37 abstract class ObjectFilter extends PointCutter implements JoinPointKinds
38     {
39
40     {
41       acceptMask = MASK_ALL_JP;
42       mayFilterStaticallyMask=0;
43       canFilterStaticallyMask=0;
44     }
45
46       public static int TARGET_ARGS_OBJECT = 0x01;
47       public static int THIS_OBJECT = 0x02;
48       protected int objectExtractionMode =0;
49
50       protected ObjectFilter(int targetType)
51     {
52       objectExtractionMode = targetType;
53     }
54
55       /** Undefined for all requests */
56       protected boolean doIsSpecialRequest(JoinPointRequest r)
57     {
58       throw new Error JavaDoc("the AbstractCrosscuSpecialier should not allow requests in ObjectFilters");
59     }
60
61       /** Extracts an object from <code>ev</code> and then filters
62        * ev according to the abstract <code>doIsSpecialEvent</code>.
63        */

64       protected boolean doIsSpecialEvent(CodeJoinPoint ev)
65     {
66       if (objectExtractionMode == ObjectFilter.TARGET_ARGS_OBJECT)
67         return doIsSpecialObject(ev.getTarget());
68
69       if (objectExtractionMode == ObjectFilter.THIS_OBJECT)
70         return doIsSpecialObject(ev.getThis());
71
72       throw new Error JavaDoc("ObjectFilter.isSpecialEvent: Object filter was initialized with illegal value"); }
73
74       protected abstract boolean doIsSpecialObject(Object JavaDoc target);
75
76     }
77
78 //====================================================================
79
//
80
//$Log: ObjectFilter.java,v $
81
//Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
82
//Imported from ETH Zurich
83
//
84
//Revision 1.2 2003/05/06 15:51:42 popovici
85
//Mozilla-ification
86
//
87
//Revision 1.1 2003/05/05 13:58:04 popovici
88
//renaming from runes to prose
89
//
90
//Revision 1.6 2003/04/27 13:08:44 popovici
91
//Specializers renamed to PointCutter
92
//
93
//Revision 1.5 2003/04/17 12:49:34 popovici
94
//Refactoring of the crosscut package
95
// ExceptionCut renamed to ThrowCut
96
// McutSignature is now SignaturePattern
97
//
98
//Revision 1.4 2003/04/17 08:47:51 popovici
99
//Important functionality additions
100
// - Cflow specializers
101
// - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
102
// - Transactional capabilities
103
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
104
// between static and dynamic specializers.
105
// - Functionality pulled up in abstract classes
106
// - Uniformization of advice methods patterns and names
107
//
108
//Revision 1.3 2003/03/05 10:48:52 popovici
109
//Adapted tot the IKS template form
110
//
111
//
112
Popular Tags