KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > prose > crosscut > CatchHandleSignaturePattern


1 package ch.ethz.prose.crosscut;
2
3 import java.lang.IllegalAccessException JavaDoc;
4 import java.io.Serializable JavaDoc;
5 import java.lang.InstantiationException JavaDoc;
6 import java.lang.reflect.Field JavaDoc;
7 import java.lang.Error JavaDoc;
8 import java.lang.Class JavaDoc;
9 import ch.ethz.inf.util.Logger;
10 import java.lang.SecurityException JavaDoc;
11 import java.lang.ArrayIndexOutOfBoundsException JavaDoc;
12
13   class CatchHandleSignaturePattern extends SignaturePattern implements Serializable JavaDoc
14   {
15     private final AbstractCrosscut crosscut;
16
17
18
19     /**
20      * Create an <code>UserDefinedMCSignature</code> that encapsulates the
21      * method to be executed.
22      * <p>
23      * Postcondition: methodObj is properly initialized
24      * <p>
25      * Implementation:
26      * <ul>
27      * <li> if <code>crsc</code> (i.e., a subclass of FunctionalCrossscut)
28      * <em>defines</em> exaclty one method, this method is
29      * the advice method.
30      *
31      * <li> If <code>crsc</code> defines several methods, the one whose
32      * name corresponds to <code>crsc.ADVICE_NAME()</code> is the advice method
33      * </ul>
34      * @throws MissingInformationExeception crsc does not define a method at all,
35      * or if it defines several, none of them matches <code>crsc.ADVICE_NAME()</code>.
36      *
37      */

38     protected CatchHandleSignaturePattern(CatchCut crsc) throws MissingInformationException
39       {
40     this.crosscut = crsc;
41     initFromMethod(crsc.getClass(),"CATCH_ARGS",ANY.class,CatchCut.class);
42       }
43
44
45     /** Returns <code>true</code> if the signature of
46      * <code>methoObj</code>, seen as a pattern,
47      * matches the signature (the parameter types) for
48      * <code>actualMehtod</code>.
49      */

50      protected boolean matchesExceptionClass(Class JavaDoc cls)
51       {
52       if (signatureCathegory == SIGNATURE__EMPTY)
53           return true;
54       else
55           {
56           return getLength() == 1 && // must have the format (TYPE)
57
isAssignable(cls,signature[1]);
58           }
59       }
60
61
62
63     public String JavaDoc toString()
64       {
65     return methodObj.toString();
66       }
67   }
68
Popular Tags