KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > tools > ajdoc > PointcutDocImpl


1 /* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  *
3  * This file is part of the debugger and core tools for the AspectJ(tm)
4  * programming language; see http://aspectj.org
5  *
6  * The contents of this file are subject to the Mozilla Public License
7  * Version 1.1 (the "License"); you may not use this file except in
8  * compliance with the License. You may obtain a copy of the License at
9  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is AspectJ.
17  *
18  * The Initial Developer of the Original Code is Xerox Corporation. Portions
19  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
20  * All Rights Reserved.
21  */

22 package org.aspectj.tools.ajdoc;
23
24 import org.aspectj.ajdoc.ClassDoc;
25 import org.aspectj.ajdoc.PointcutDoc;
26 import org.aspectj.compiler.base.ast.Dec;
27 import org.aspectj.compiler.base.ast.Formals;
28 import org.aspectj.compiler.base.ast.NameType;
29 import org.aspectj.compiler.base.ast.TypeD;
30 import org.aspectj.compiler.base.ast.TypeDec;
31 import org.aspectj.compiler.base.ast.TypeDs;
32 import org.aspectj.compiler.crosscuts.ast.PointcutDec;
33
34 import java.util.Collection JavaDoc;
35 import java.util.Collections JavaDoc;
36
37 public class PointcutDocImpl
38     extends ExecutableMemberDocImpl
39     implements PointcutDoc {
40
41     /** The pointcut to which we delegate. */
42     private final PointcutDec pointcutDec;
43
44     public PointcutDocImpl(ClassDoc containingClass, PointcutDec pointcutDec) {
45         super(containingClass);
46         this.pointcutDec = pointcutDec;
47     }
48
49     /**
50      * Returns a empty list because advice cannot
51      * be placed on a pointcut.
52      *
53      * @return Collection.EMPTY_LIST;
54      */

55     protected Collection JavaDoc createAdvice() {
56         return Collections.EMPTY_LIST;
57     }
58
59     /**
60      * Returns the underlying Dec -- a PointcutDec.
61      *
62      * @return the underlying Dec -- a PointcutDec.
63      */

64     protected Dec dec() {
65         return pointcutDec;
66     }
67
68     /**
69      * Returns the Formals of the underlying PointcutDec.
70      *
71      * @return the Formals of the underlying PointcutDec.
72      */

73     protected Formals getFormals() {
74         return pointcutDec.getFormals();
75     }
76
77     /**
78      * Returns null because pointcut cannot throw execptions.
79      *
80      * @return null.
81      */

82     public TypeDs getThrows() {
83         return null;
84     }
85
86     /**
87      * Returns the return type of this method.
88      *
89      * @return the Type representing the type this
90      * method returns.
91      */

92     public com.sun.javadoc.Type resultType() {
93         TypeD typed = pointcutDec.getResultTypeD();
94         if (typed == null) return null; //TODO: maybe return VOID
95
return null; //TODOtyped.getType();
96
}
97
98     /**
99      * Returns the type that nearest super class that defines
100      * this method.
101      *
102      * @return the type that nearest super class that defines
103      * this method.
104      */

105     public com.sun.javadoc.ClassDoc overriddenClass() {
106         //TODO: This sucks!!!
107
TypeDec where = pointcutDec.getDeclaringType().getTypeDec();
108         NameType superType = (NameType)where.getSuperClassType();
109         while (superType != null) {
110             PointcutDec pc = Util.pointcutDec(superType,
111                                               pointcutDec.getId(),
112                                               pointcutDec.getFormals());
113             if (pc != null && !pc.getId().equals("NOT_FOUND")) {
114                 // XXX TypeDec result = superType.getTypeDec();
115
return null; //TODOresult;
116
}
117             if (superType.getTypeDec().getFullName().
118                 equals("java.lang.Object")) {
119                 return null;
120             }
121             superType = (NameType)superType.getTypeDec().getSuperClassType();
122         }
123         return null;
124     }
125     
126     /**
127      * Returns <code>true</code>.
128      *
129      * @return <code>true</code>.
130      */

131     public boolean isPointcut() {
132         return true;
133     }
134     
135     /**
136      * Returns <code>true</code> if this method is <code>abstract</code>.
137      *
138      * @return <code>true</code> if this method is <code>abstract</code>.
139      */

140     public boolean isAbstract() {
141         return pointcutDec.isAbstract();
142     }
143 }
144
Popular Tags