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 Andrei Popovici. Portions
17: // created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
18: // All Rights Reserved.
19: //
20: // Contributor(s):
21:
22: package ch.ethz.prose.crosscut;
23:
24: import java.io.Serializable;
25: import java.lang.Class;
26:
27: class ThrowHandleSignaturePattern extends SignaturePattern implements
28: Serializable {
29: private static final long serialVersionUID = 3257571693764359730L;
30: private final AbstractCrosscut crosscut;
31:
32: /**
33: * Create an <code>UserDefinedMCSignature</code> that encapsulates the
34: * method to be executed.
35: * <p>
36: * Postcondition: methodObj is properly initialized
37: * <p>
38: * Implementation:
39: * <ul>
40: * <li> if <code>crsc</code> (i.e., a subclass of FunctionalCrossscut)
41: * <em>defines</em> exaclty one method, this method is
42: * the advice method.
43: *
44: * <li> If <code>crsc</code> defines several methods, the one whose
45: * name corresponds to <code>crsc.ADVICE_NAME()</code> is the advice method
46: * </ul>
47: * @throws MissingInformationExeception crsc does not define a method at all,
48: * or if it defines several, none of them matches <code>crsc.ADVICE_NAME()</code>.
49: *
50: */
51: protected ThrowHandleSignaturePattern(ThrowCut crsc)
52: throws MissingInformationException {
53: this .crosscut = crsc;
54: initFromMethod(crsc.getClass(), "THROW_ARGS", ANY.class,
55: ThrowCut.class);
56: }
57:
58: /** Returns <code>true</code> if the signature of
59: * <code>methoObj</code>, seen as a pattern,
60: * matches the signature (the parameter types) for
61: * <code>actualMehtod</code>.
62: */
63: protected boolean matchesExceptionClass(Class cls) {
64: if (signatureCathegory == SIGNATURE__EMPTY)
65: return true;
66: else {
67: return getLength() == 1 && // must have the format (TYPE)
68: isAssignable(cls, signature[1]);
69: }
70: }
71:
72: public String toString() {
73: return methodObj.toString();
74: }
75: }
|