KickJava   Java API By Example, From Geeks To Geeks.

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


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: ObjectTypeFilter.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 /*---------------match name--------------------*/
29   class ObjectTypeFilter extends ObjectFilter
30   {
31
32 final static int SUBCLASS_INHERITANCE = 1;
33 final static int SUPERCLASS_INHERITANCE = 2;
34 final static int NO_INHERITANCE = 3;
35     private Class JavaDoc superClass;
36     private int inheritanceType;
37
38     ObjectTypeFilter(int extractionMode,Class JavaDoc superCls,int inhType)
39       {
40         super(extractionMode);
41         this.superClass = superCls;
42         this.inheritanceType = inhType;
43       }
44
45     protected boolean doIsSpecialObject(Object JavaDoc target)
46       {
47         if (target == null)
48         return false;
49         switch(inheritanceType)
50         {
51             case SUBCLASS_INHERITANCE:
52             return superClass.isAssignableFrom(target.getClass());
53             case SUPERCLASS_INHERITANCE:
54             return target.getClass().isAssignableFrom(superClass);
55             case NO_INHERITANCE:
56             return superClass.equals(target);
57             default:
58             throw new Error JavaDoc("Illegal state: inheritanceType");
59         }
60       }
61   }
62
63
64 //====================================================================
65
//
66
//$Log: ObjectTypeFilter.java,v $
67
//Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
68
//Imported from ETH Zurich
69
//
70
//Revision 1.2 2003/05/06 15:51:43 popovici
71
//Mozilla-ification
72
//
73
//Revision 1.1 2003/05/05 13:57:57 popovici
74
//renaming from runes to prose
75
//
76
//Revision 1.1 2003/04/27 13:08:52 popovici
77
//Specializers renamed to PointCutter
78
//
79
//Revision 1.6 2003/04/26 14:33:49 popovici
80
//subtypeOf, supertypeOf specializers addde to this and target
81
//
82
//Revision 1.5 2003/04/17 12:49:34 popovici
83
//Refactoring of the crosscut package
84
// ExceptionCut renamed to ThrowCut
85
// McutSignature is now SignaturePattern
86
//
87
//Revision 1.4 2003/04/17 08:47:53 popovici
88
//Important functionality additions
89
// - Cflow specializers
90
// - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
91
// - Transactional capabilities
92
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
93
// between static and dynamic specializers.
94
// - Functionality pulled up in abstract classes
95
// - Uniformization of advice methods patterns and names
96
//
97
//Revision 1.3 2003/03/05 10:48:47 popovici
98
//Adapted tot the IKS template form
99
//
100
//
101
Popular Tags