1 /***************************************************************************************
2 * Copyright (c) Jonas Bonér, Alexandre Vasseur. All rights reserved. *
3 * http://aspectwerkz.codehaus.org *
4 * ---------------------------------------------------------------------------------- *
5 * The software in this package is published under the terms of the LGPL license *
6 * a copy of which has been included with this distribution in the license.txt file. *
7 **************************************************************************************/
8 package org.codehaus.aspectwerkz.joinpoint.impl;
9
10 import org.codehaus.aspectwerkz.joinpoint.CatchClauseSignature;
11 import org.codehaus.aspectwerkz.joinpoint.Signature;
12
13 /***
14 * Implementation for the catch clause signature.
15 *
16 * @author <a href="mailto:jboner@codehaus.org">Jonas Bonér </a>
17 */
18 public class CatchClauseSignatureImpl implements CatchClauseSignature {
19 private final Class m_declaringType;
20
21 private final int m_modifiers;
22
23 private final String m_name;
24
25 private Class m_parameterType;
26
27 private String m_joinPointSignature;
28
29 /***
30 * Creates a new catch clause signature.
31 *
32 * @param exceptionClass
33 * @param declaringClass
34 * @param joinPointSignature
35 */
36 public CatchClauseSignatureImpl(final Class exceptionClass,
37 final Class declaringClass,
38 final String joinPointSignature) {
39 m_declaringType = declaringClass;
40 m_joinPointSignature = joinPointSignature;
41 m_parameterType = exceptionClass;
42 m_modifiers = exceptionClass.getModifiers();
43 m_name = exceptionClass.getName();
44 }
45
46 /***
47 * Returns the declaring class.
48 *
49 * @return the declaring class
50 */
51 public Class getDeclaringType() {
52 return m_declaringType;
53 }
54
55 /***
56 * Returns the modifiers for the signature. <p/>Could be used like this:
57 *
58 * <pre>
59 * boolean isPublic = java.lang.reflect.Modifier.isPublic(signature.getModifiers());
60 * </pre>
61 *
62 * @return the mofifiers
63 */
64 public int getModifiers() {
65 return m_modifiers;
66 }
67
68 /***
69 * Returns the name (f.e. name of method of field).
70 *
71 * @return
72 */
73 public String getName() {
74 return m_name;
75 }
76
77 /***
78 * Returns the parameter type.
79 *
80 * @return the parameter type
81 */
82 public Class getParameterType() {
83 return m_parameterType;
84 }
85
86 /***
87 * Returns a string representation of the signature.
88 *
89 * @return a string representation
90 * @TODO: implement toString to something meaningful
91 */
92 public String toString() {
93 return super.toString();
94 }
95
96 /***
97 * Creates a deep copy of the signature.
98 *
99 * @return a deep copy of the signature
100 */
101 public Signature newInstance() {
102 return new CatchClauseSignatureImpl(m_parameterType, m_declaringType, m_joinPointSignature);
103 }
104 }