01: //
02: // This file is part of the prose package.
03: //
04: // The contents of this file are subject to the Mozilla Public License
05: // Version 1.1 (the "License"); you may not use this file except in
06: // compliance with the License. You may obtain a copy of the License at
07: // http://www.mozilla.org/MPL/
08: //
09: // 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 Angela Nicoara. Portions
17: // created by Angela Nicoara are Copyright (C) 2002 Angela Nicoara.
18: // All Rights Reserved.
19: //
20: // Contributor(s):
21: // $Id$
22: // =====================================================================
23: //
24: //(history at end)
25: //
26:
27: package ch.ethz.prose.crosscut;
28:
29: import java.io.Serializable;
30: import java.lang.Class;
31:
32: class CatchHandleSignaturePattern extends SignaturePattern implements
33: Serializable {
34: private static final long serialVersionUID = 4049922649348257848L;
35: private final AbstractCrosscut crosscut;
36:
37: /**
38: * Create an <code>UserDefinedMCSignature</code> that encapsulates the
39: * method to be executed.
40: * <p>
41: * Postcondition: methodObj is properly initialized
42: * <p>
43: * Implementation:
44: * <ul>
45: * <li> if <code>crsc</code> (i.e., a subclass of FunctionalCrossscut)
46: * <em>defines</em> exaclty one method, this method is
47: * the advice method.
48: *
49: * <li> If <code>crsc</code> defines several methods, the one whose
50: * name corresponds to <code>crsc.ADVICE_NAME()</code> is the advice method
51: * </ul>
52: * @throws MissingInformationExeception crsc does not define a method at all,
53: * or if it defines several, none of them matches <code>crsc.ADVICE_NAME()</code>.
54: *
55: */
56: protected CatchHandleSignaturePattern(CatchCut crsc)
57: throws MissingInformationException {
58: this .crosscut = crsc;
59: initFromMethod(crsc.getClass(), "CATCH_ARGS", ANY.class,
60: CatchCut.class);
61: }
62:
63: /** Returns <code>true</code> if the signature of
64: * <code>methoObj</code>, seen as a pattern,
65: * matches the signature (the parameter types) for
66: * <code>actualMehtod</code>.
67: */
68: protected boolean matchesExceptionClass(Class cls) {
69: if (signatureCathegory == SIGNATURE__EMPTY)
70: return true;
71: else {
72: return getLength() == 1 && // must have the format (TYPE)
73: isAssignable(cls, signature[1]);
74: }
75: }
76:
77: public String toString() {
78: return methodObj.toString();
79: }
80: }
81:
82: //======================================================================
83: //
84: // $Log$
85: //
|