KickJava   Java API By Example, From Geeks To Geeks.

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


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
24 import org.aspectj.ajdoc.AspectDoc;
25 import org.aspectj.ajdoc.IntroducedSuperDoc;
26 import org.aspectj.ajdoc.IntroductionDoc;
27
28 import com.sun.javadoc.ClassDoc;
29 import com.sun.javadoc.ProgramElementDoc;
30 import com.sun.javadoc.Type;
31
32 import java.util.ArrayList JavaDoc;
33 import java.util.Collections JavaDoc;
34 import java.util.HashSet JavaDoc;
35 import java.util.Iterator JavaDoc;
36 import java.util.List JavaDoc;
37 import java.util.Set JavaDoc;
38
39 public class SuperIntroductionSubWriter extends AbstractSubWriter {
40
41     protected Class JavaDoc delegateClass() {
42         return null; //XXX ????
43
}
44
45     public SuperIntroductionSubWriter
46         (com.sun.tools.doclets.standard.SubWriterHolderWriter writer,
47          AspectDoc ad)
48     {
49         super(writer, ad);
50     }
51     
52     public SuperIntroductionSubWriter
53         (com.sun.tools.doclets.standard.SubWriterHolderWriter writer)
54     {
55         super(writer);
56     }
57
58     protected final String JavaDoc keyName() { return "Super_Introduction"; }
59
60     public void printInheritedSummaryAnchor(ClassDoc cd) {}
61     public void printInheritedSummaryLabel(ClassDoc cd) {}
62     protected void printInheritedSummaryLink(ClassDoc cd, ProgramElementDoc ped) {}
63
64     protected void printSummaryLink(ClassDoc cd, ProgramElementDoc member) {
65         IntroducedSuperDoc intro = (IntroducedSuperDoc)member;
66         writer.codeEnd();
67         writer.printText("doclet.declare_parents");
68         print(' ');
69         Type[] targets = intro.targets();
70         for (int i = 0; i < targets.length; i++) {
71             if (i > 0) print(", ");
72             printTypeLink(targets[i]);
73         }
74         print(' ');
75         String JavaDoc str = intro.isImplements() ? "implements" : "extends";
76         writer.printClassLink(cd, link(intro), str, false);
77         print(' ');
78         Type[] types = intro.types();
79         for (int i = 0; i < types.length; i++) {
80             if (i > 0) print(", ");
81             printTypeLink(types[i]);
82         }
83
84     }
85
86     protected static String JavaDoc link(IntroducedSuperDoc intro) {
87         String JavaDoc str = intro.isImplements() ? "+implements" : "+extends";
88         Type[] types = intro.types();
89         str += "%";
90         for (int i = 0; i < types.length; i++) str += types[i].qualifiedTypeName();
91         str += "%";
92         ClassDoc[] targets = intro.targets();
93         for (int i = 0; i < targets.length; i++) str += targets[i].qualifiedTypeName();
94         return str;
95     }
96
97     protected void printSummaryType(ProgramElementDoc member) {}
98
99     protected void printBodyHtmlEnd(ClassDoc cd) {}
100
101     protected void nonfinalPrintMember(ProgramElementDoc member) {
102         IntroducedSuperDoc intro = (IntroducedSuperDoc)member;
103         writer.anchor(link(intro));
104         String JavaDoc head = intro.isImplements() ? "+implements " : "+extends ";
105         Type[] types = intro.types();
106         for (int i = 0; i < types.length; i++) {
107             head += (i > 0 ? ", " : "") + types[i].typeName();
108         }
109         printHead(head);
110         printFullComment(intro);
111     }
112
113     protected void printDeprecatedLink(ProgramElementDoc member) {
114         //TODO: ???
115
}
116
117     protected List JavaDoc getMembers(ClassDoc cd) {
118         if (!(cd instanceof AspectDoc)) return Collections.EMPTY_LIST;
119         IntroductionDoc[] introductions = ((AspectDoc)cd).introductions();
120         List JavaDoc list = new ArrayList JavaDoc();
121         if (introductions == null) return list;
122         for (int i = 0; i < introductions.length; i++) {
123             IntroductionDoc intro = introductions[i];
124             if (intro instanceof IntroducedSuperDoc) {
125                 list.add(intro);
126             }
127         }
128         return list;
129     }
130
131     public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) {
132         org.aspectj.ajdoc.IntroducedSuperDoc intro =
133             (org.aspectj.ajdoc.IntroducedSuperDoc)member;
134         ClassDoc[] targets = intro.targets();
135         if (targets.length > 0) {
136             writer.dt();
137             writer.boldText("doclet.Introduced_on");
138             writer.dd();
139             writer.code();
140             Set JavaDoc targetSet = new HashSet JavaDoc();
141             for (int i = 0; i < targets.length; i++) {
142                 targetSet.add(targets[i]);
143             }
144             List JavaDoc targetList = new ArrayList JavaDoc(targetSet);
145             Collections.sort(targetList);
146             for (Iterator JavaDoc i = targetList.iterator(); i.hasNext();) {
147                 ClassDoc target = (ClassDoc)i.next();
148                 writer.printClassLink(target);
149                 if (i.hasNext()) writer.print(", ");
150                 
151             }
152             writer.codeEnd();
153         }
154     }
155
156     public void printSummaryCrosscuts(ClassDoc cd,
157                                       ProgramElementDoc member) {
158         Set JavaDoc set = new HashSet JavaDoc();
159         org.aspectj.ajdoc.IntroducedSuperDoc intro =
160             (org.aspectj.ajdoc.IntroducedSuperDoc)member;
161         ClassDoc[] targets = intro.targets();
162         for (int i = 0; i < targets.length; i++) {
163             set.add(targets[i]);
164         }
165         if (targets.length > 0) {
166             writer.boldText("doclet.Advises");
167             List JavaDoc list = new ArrayList JavaDoc(set);
168             Collections.sort(list);
169             for (Iterator JavaDoc i = list.iterator(); i.hasNext();) {
170                 print(' ');
171                 ClassDoc target = (ClassDoc)i.next();
172                 writer.printClassLink(target);
173                 if (i.hasNext()) print(",");
174             }
175         }
176     }
177
178     public boolean hasCrosscuts(ClassDoc cd, ProgramElementDoc member) {
179         return true;
180     }
181 }
182
Popular Tags