KickJava   Java API By Example, From Geeks To Geeks.

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


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: Exceptions.java,v 1.2 2004/05/12 09:41:55 anicoara Exp $
22
// =====================================================================
23
//
24
// (history at end)
25
//
26

27 package ch.ethz.prose.filter;
28
29 // used packages
30
import org.apache.regexp.RE;
31 import org.apache.regexp.RESyntaxException;
32
33 import ch.ethz.jvmai.ExceptionJoinPoint;
34 import ch.ethz.jvmai.ExceptionCatchJoinPoint;
35 import ch.ethz.jvmai.JoinPoint;
36 import ch.ethz.prose.engine.ExceptionThrowRequest;
37 import ch.ethz.prose.engine.ExceptionCatchRequest;
38 import ch.ethz.prose.engine.JoinPointRequest;
39
40 /**
41  * Class MembersS is a container for static filters that deal
42  * with class members (methods and fields).
43  *
44  * @version $Revision: 1.2 $
45  * @author Philippe Schoch
46  */

47 public
48 class Exceptions {
49
50   // Caching variable for Class-object Throwable
51
protected static Class JavaDoc throwableClass;
52   static
53   {
54       try
55       {
56           throwableClass = Class.forName("java.lang.Throwable");
57       }
58       catch (ClassNotFoundException JavaDoc e)
59       {
60           System.err.println(e);
61       e.printStackTrace();
62       }
63   }
64
65
66   /*---------------------------------------------------------------------------*/
67   /* the factory methods */
68   /*---------------------------------------------------------------------------*/
69
70   /**
71    * Return a <code>Exceptions</code> instance which accepts and generates
72    * joinpoints of exception classes whose class name match <code>regexp</code>.
73    *
74    * @param regexp the regular expression to be matched by the exception's class name.
75    */

76   public static PointCutter type(String JavaDoc regexp)
77   {
78     PointCutter t = new ExceptionsClassFilter(regexp);
79      t.setToString("Exceptions.type(" + regexp + ")");
80      return t;
81   }
82
83   /**
84    * Return a <code>Exceptions</code> instance which accepts and generates
85    * joinpoints of exception classes whose qualified class name match <code>regexp</code>.
86    *
87    * @param regexp the regular expression to be matched by the exception's qualified class name.
88    */

89   public static PointCutter type(Class JavaDoc cls)
90   {
91     PointCutter t = new ExceptionTypeFilter(cls, ExceptionTypeFilter.NO_INHERITANCE);
92     t.setToString("Exceptions.type(" + cls.getName() + ")");
93     return t;
94   }
95
96   /**
97    * Return a <code>Exceptions</code> instance which accepts
98    * joinpoints of exceptions classes whose package name match <code>regexp</code>.
99    *
100    * @param regexp the regular expression to be matched by the exception's package name.
101    */

102   public static PointCutter subtypeOf(Class JavaDoc cls)
103   {
104     PointCutter t = new ExceptionTypeFilter(cls, ExceptionTypeFilter.SUBCLASS_INHERITANCE);
105     t.setToString("Exceptions.subtypeOf(" + cls.getName() + ")");
106     return t;
107   }
108
109   public static PointCutter supertypeOf(Class JavaDoc cls)
110   {
111     PointCutter t = new ExceptionTypeFilter(cls, ExceptionTypeFilter.SUPERCLASS_INHERITANCE);
112     t.setToString("Exceptions.superTypeOf(" + cls.getName() + ")");
113  return t;
114   }
115
116   public static PointCutter withMessage(String JavaDoc msg)
117     {
118       PointCutter t = new ExceptionMessageFilter(msg);
119       return t;
120     }
121
122
123 }
124
125
126 //======================================================================
127
//
128
// $Log: Exceptions.java,v $
129
// Revision 1.2 2004/05/12 09:41:55 anicoara
130
// Remove the README.RVM file
131
//
132
// Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
133
// Imported from ETH Zurich
134
//
135
// Revision 1.5 2003/07/02 12:42:56 anicoara
136
// Added CatchJoinPoint Functionality (Requests, Join-Points, Filters, CatchCuts, Tests)
137
//
138
// Revision 1.4 2003/06/26 12:54:19 popovici
139
// Bug fix in 'Exceptions.supertype'; (used to check subtype)
140
//
141
// Revision 1.3 2003/05/25 11:46:47 popovici
142
// Improved 'toString' presentation of aspects
143
//
144
// Revision 1.2 2003/05/06 15:51:35 popovici
145
// Mozilla-ification
146
//
147
// Revision 1.1 2003/05/05 13:58:00 popovici
148
// renaming from runes to prose
149
//
150
// Revision 1.3 2003/04/27 13:08:52 popovici
151
// Specializers renamed to PointCutter
152
//
153
// Revision 1.2 2003/04/17 15:15:19 popovici
154
// Extension->Aspect renaming
155
//
156
// Revision 1.1 2003/04/17 14:51:14 popovici
157
// ExceptionS renamed to Exception; method renamings
158
//
159
// Revision 1.9 2003/04/17 13:54:28 popovici
160
// Refactorization of 'ExecutionS' into 'Within' and 'Executions'.
161
// Method names refer now to 'types'
162
//
163
// Revision 1.8 2003/04/17 12:49:34 popovici
164
// Refactoring of the crosscut package
165
// ExceptionCut renamed to ThrowCut
166
// McutSignature is now SignaturePattern
167
//
168
// Revision 1.7 2003/04/17 08:47:34 popovici
169
// Important functionality additions
170
// - Cflow specializers
171
// - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
172
// - Transactional capabilities
173
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
174
// between static and dynamic specializers.
175
// - Functionality pulled up in abstract classes
176
// - Uniformization of advice methods patterns and names
177
//
178
// Revision 1.6 2003/03/05 12:08:38 popovici
179
// Deobfuscation of exception filters. They are now
180
// top level classes. This is just an intermediate refactoring
181
// step. Many Exceptions. predicate will be eliminated
182
// by more powerful Specializers like 'Within'
183
//
184
// Revision 1.5 2003/03/04 18:36:30 popovici
185
// Organization of imprts
186
//
187
// Revision 1.4 2003/03/04 11:27:22 popovici
188
// Important refactorization step (march):
189
// - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
190
// - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
191
// structures
192
//
193
// Revision 1.3 2003/01/27 13:04:47 pschoch
194
// toString() method improved
195
//
196
// Revision 1.2 2002/11/26 17:15:13 pschoch
197
// RootComponent now added (replaces RootComponent now added (replaces old ProseSystem)
198
// ProseSystem now owns and starts the Aspect interface.
199
// ProseSystem now containes a 'test' AspectManager
200
// AspectManager now owns the JoinPointManager.
201
// ExtensionManger can be 'connected' to the JVM, or disconnected. The
202
// JoinPointManager of a connected Ext.Mgr enables joinpoints; the
203
// JoinPointManger of a disconnected Ext.Mgr never enables join-points
204
// Documentation updated accordingly.
205
//
206
// Revision 1.1 2002/10/31 18:26:53 pschoch
207
// Capability of crosscutting Exceptions added to prose.
208
//
209
Popular Tags