KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > internal > lang > reflect > DeclareSoftImpl


1 /* *******************************************************************
2  * Copyright (c) 2005 Contributors.
3  * All rights reserved.
4  * This program and the accompanying materials are made available
5  * under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution and is available at
7  * http://eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Adrian Colyer Initial implementation
11  * ******************************************************************/

12 package org.aspectj.internal.lang.reflect;
13
14 import org.aspectj.lang.reflect.AjType;
15 import org.aspectj.lang.reflect.AjTypeSystem;
16 import org.aspectj.lang.reflect.DeclareSoft;
17 import org.aspectj.lang.reflect.PointcutExpression;
18
19 /**
20  * @author colyer
21  *
22  */

23 public class DeclareSoftImpl implements DeclareSoft {
24
25     private AjType<?> declaringType;
26     private PointcutExpression pointcut;
27     private AjType<?> exceptionType;
28     private String JavaDoc missingTypeName;
29     
30     
31     public DeclareSoftImpl(AjType<?> declaringType, String JavaDoc pcut, String JavaDoc exceptionTypeName) {
32         this.declaringType = declaringType;
33         this.pointcut = new PointcutExpressionImpl(pcut);
34         try {
35             ClassLoader JavaDoc cl = declaringType.getJavaClass().getClassLoader();
36             this.exceptionType = AjTypeSystem.getAjType(Class.forName(exceptionTypeName,false,cl));
37         } catch (ClassNotFoundException JavaDoc ex) {
38             this.missingTypeName = exceptionTypeName;
39         }
40     }
41
42     /* (non-Javadoc)
43      * @see org.aspectj.lang.reflect.DeclareSoft#getDeclaringType()
44      */

45     public AjType getDeclaringType() {
46         return this.declaringType;
47     }
48
49     /* (non-Javadoc)
50      * @see org.aspectj.lang.reflect.DeclareSoft#getSoftenedExceptionType()
51      */

52     public AjType getSoftenedExceptionType() throws ClassNotFoundException JavaDoc {
53         if (this.missingTypeName != null) throw new ClassNotFoundException JavaDoc(this.missingTypeName);
54         return this.exceptionType;
55     }
56
57     /* (non-Javadoc)
58      * @see org.aspectj.lang.reflect.DeclareSoft#getPointcutExpression()
59      */

60     public PointcutExpression getPointcutExpression() {
61         return this.pointcut;
62     }
63
64     public String JavaDoc toString() {
65         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
66         sb.append("declare soft : ");
67         if (this.missingTypeName != null) {
68             sb.append(this.exceptionType.getName());
69         } else {
70             sb.append(this.missingTypeName);
71         }
72         sb.append(" : ");
73         sb.append(getPointcutExpression().asString());
74         return sb.toString();
75     }
76 }
77
Popular Tags