KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > tools > doclets > standard > PointcutSubWriter


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.doclets.standard;
23 import org.aspectj.ajdoc.PointcutDoc;
24
25 import com.sun.javadoc.ClassDoc;
26 import com.sun.javadoc.MemberDoc;
27 import com.sun.javadoc.ParamTag;
28 import com.sun.javadoc.Parameter;
29 import com.sun.javadoc.ProgramElementDoc;
30 import com.sun.javadoc.SeeTag;
31 import com.sun.javadoc.Tag;
32 import com.sun.javadoc.Type;
33 import com.sun.tools.doclets.Util;
34
35 import java.util.List JavaDoc;
36
37 public class PointcutSubWriter extends AbstractSubWriter {
38
39     protected Class JavaDoc delegateClass() {
40         return null;
41     }
42
43     public PointcutSubWriter
44         (com.sun.tools.doclets.standard.SubWriterHolderWriter writer,
45          ClassDoc classdoc)
46     {
47         super(writer, classdoc);
48     }
49
50     public PointcutSubWriter
51         (com.sun.tools.doclets.standard.SubWriterHolderWriter writer)
52     {
53         super(writer);
54     }
55
56     protected final String JavaDoc keyName() { return "Pointcut"; }
57
58 // public void printInheritedSummaryAnchor(ClassDoc cd) {
59
// writer.anchor("pointcuts_inherited_from_class_" + cd.qualifiedName());
60
// }
61

62 // public void printInheritedSummaryLabel(ClassDoc cd) {
63
// String classlink = writer.getPreQualifiedClassLink(cd);
64
// writer.bold();
65
// writer.printText("doclet.Pointcuts_Inherited_From",
66
// Statics.type(cd),
67
// classlink);
68
// writer.boldEnd();
69
// }
70

71     void printSignature(MemberDoc member) {
72         PointcutDoc pcd = (PointcutDoc)member;
73         writer.displayLength = 0;
74     writer.pre();
75         printModifiers(pcd);
76         bold(pcd.name());
77         printParameters(pcd);
78         printResultType(pcd);
79     writer.preEnd();
80     }
81
82     void printResultType(PointcutDoc pcd) {
83         Type result = pcd.resultType();
84         if (result != null) {
85             writer.code();
86             print(" returns ");
87             printTypeLink(result);
88             writer.codeEnd();
89         }
90     }
91
92     protected void printSummaryLink(ClassDoc cd, ProgramElementDoc member) {
93         PointcutDoc pcd = (PointcutDoc)member;
94         String JavaDoc name = member.name();
95         writer.bold();
96         writer.printClassLink(cd, name + pcd.signature(), name, false);
97         writer.boldEnd();
98         writer.displayLength = name.length();
99         printParameters(pcd);
100         printResultType(pcd);
101
102     }
103     
104     protected void printInheritedSummaryLink(ClassDoc cd,
105                                              ProgramElementDoc member) {
106         PointcutDoc pcd = (PointcutDoc)member;
107         String JavaDoc name = member.name();
108         writer.printClassLink(cd, name + pcd.signature(), name, false);
109     }
110
111     protected void printSummaryType(ProgramElementDoc member) {
112         PointcutDoc pcd = (PointcutDoc)member;
113         writer.printTypeSummaryHeader();
114         printModifier(pcd);
115         writer.printTypeSummaryFooter();
116         
117     }
118
119     protected void printBodyHtmlEnd(ClassDoc cd) {
120     }
121
122     protected void nonfinalPrintMember(ProgramElementDoc member) {
123         PointcutDoc pcd = (PointcutDoc)member;
124         writer.anchor(pcd.name() + pcd.signature());
125         printHead(pcd);
126         printSignature(pcd);
127         printFullComment(pcd);
128     }
129
130     protected void printDeprecatedLink(ProgramElementDoc member) {
131         writer.printClassLink(member.containingClass(),
132                               member.name(),
133                               ((PointcutDoc)member).qualifiedName());
134     }
135
136     protected List JavaDoc getMembers(ClassDoc cd) {
137         return Util.asList(((org.aspectj.ajdoc.ClassDoc)cd).pointcuts());
138     }
139
140     protected void printParameters(PointcutDoc member) {
141         print('(');
142         Parameter[] params = member.parameters();
143         for (int i = 0; i < params.length; i++) {
144             printParam(params[i]);
145             if (i < params.length-1) {
146                 writer.print(',');
147                 writer.print(' ');
148             }
149         }
150         writer.print(')');
151     }
152
153     protected void printParam(Parameter param) {
154         printTypedName(param.type(), param.name());
155     }
156
157     protected void printParamTags(ParamTag[] params) {
158         if (params.length > 0) {
159             writer.dt();
160             writer.boldText("doclet.Parameters");
161             for (int i = 0; i < params.length; ++i) {
162                 ParamTag pt = params[i];
163                 writer.dd();
164                 writer.code();
165                 print(pt.parameterName());
166                 writer.codeEnd();
167                 print(" - ");
168                 writer.printInlineComment(pt);
169             }
170         }
171     }
172
173     protected void printReturnTag(Tag[] returnsTag) {
174         if (returnsTag.length > 0) {
175             writer.dt();
176             writer.boldText("doclet.Returns");
177             writer.dd();
178             writer.printInlineComment(returnsTag[0]);
179         }
180     }
181     
182     protected void printOverridden(ClassDoc overridden, PointcutDoc pcd) {
183         if (overridden != null) {
184             String JavaDoc name = pcd.name();
185             writer.dt();
186             writer.boldText("doclet.Overrides");
187             writer.dd();
188             writer.printText("doclet.in_class",
189                              writer.codeText
190                              (writer.getClassLink(overridden,
191                                                   name + pcd.signature(),
192                                                   name, false)),
193                              writer.codeText
194                              (writer.getClassLink(overridden)));
195         }
196     }
197
198     protected void printTags(ProgramElementDoc member) {
199         PointcutDoc pcd = (PointcutDoc)member;
200         ParamTag[] params = pcd.paramTags();
201         Tag[] returnsTag = pcd.tags("return");
202         Tag[] sinces = pcd.tags("since");
203         SeeTag[] sees = pcd.seeTags();
204         ClassDoc[] intfacs = member.containingClass().interfaces();
205         ClassDoc overridden = pcd.overriddenClass();
206         if (intfacs.length > 0 || overridden != null) {
207             writer.dd();
208             writer.dl();
209             printOverridden(overridden, pcd);
210             writer.dlEnd();
211             writer.ddEnd();
212         }
213         if (params.length +
214             returnsTag.length +
215             sinces.length +
216             sees.length > 0) {
217             writer.dd();
218             writer.dl();
219             printParamTags(params);
220             printReturnTag(returnsTag);
221             writer.printSinceTag(pcd);
222             writer.printSeeTags(pcd);
223             writer.dlEnd();
224             writer.ddEnd();
225         }
226     }
227 }
228
Popular Tags