KickJava   Java API By Example, From Geeks To Geeks.

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


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.AspectDoc;
24 import org.aspectj.ajdoc.IntroducedDoc;
25 import org.aspectj.ajdoc.IntroductionDoc;
26
27 import com.sun.javadoc.ClassDoc;
28 import com.sun.javadoc.MemberDoc;
29 import com.sun.javadoc.ProgramElementDoc;
30
31 import java.util.ArrayList JavaDoc;
32 import java.util.Collections JavaDoc;
33 import java.util.HashSet JavaDoc;
34 import java.util.Iterator JavaDoc;
35 import java.util.List JavaDoc;
36 import java.util.Set JavaDoc;
37
38 public class MethodIntroductionSubWriter extends MethodSubWriter {
39
40     public MethodIntroductionSubWriter
41         (com.sun.tools.doclets.standard.SubWriterHolderWriter writer,
42          AspectDoc ad)
43     {
44         super(writer, ad);
45     }
46     
47     public MethodIntroductionSubWriter
48         (com.sun.tools.doclets.standard.SubWriterHolderWriter writer)
49     {
50         super(writer);
51     }
52
53     protected final String JavaDoc keyName() { return "Method_Introduction"; }
54
55     public void printInheritedSummaryAnchor(ClassDoc cd) {}
56     public void printInheritedSummaryLabel(ClassDoc cd) {}
57     protected void printInheritedSummaryLink(ClassDoc cd, ProgramElementDoc ped) {}
58
59     protected List JavaDoc getMembers(ClassDoc cd) {
60         if (!(cd instanceof AspectDoc)) return super.getMembers(cd);
61         IntroductionDoc[] introductions = ((AspectDoc)cd).introductions();
62         List JavaDoc list = new ArrayList JavaDoc();
63         if (introductions == null) return list;
64         for (int i = 0; i < introductions.length; i++) {
65             IntroductionDoc id = introductions[i];
66             if (!(id instanceof IntroducedDoc)) continue;
67             MemberDoc member = ((IntroducedDoc)id).member();
68             if (member.isMethod()) {
69                 //MethodDec method = (MethodDec)member;
70
//TODO: method.bindSignatures(((ClassDec)cd).getTypeScope());
71
list.add(member); //method);
72
}
73         }
74         return list;
75     }
76
77     /** print in the detail context at the bottom of the page
78      * the links out to affected classes/members for this method introduction
79      * (in this aspect)
80      */

81     public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) {
82         org.aspectj.ajdoc.MethodDoc method = (org.aspectj.ajdoc.MethodDoc)member;
83         IntroducedDoc intro = method.introduced();
84         ClassDoc[] targets = intro.targets();
85         if (targets.length > 0) {
86             writer.dt();
87             writer.boldText("doclet.Introduced_on");
88             writer.dd();
89             writer.code();
90             for (int i = 0; i < targets.length; i++) {
91                 if (i > 0) writer.print(", ");
92                 ClassDoc target = targets[i];
93                 writer.printClassLink(target,
94                                       "methods_introduced_from_class_" +
95                                       cd.qualifiedName(),
96                                       target.name());
97             }
98             writer.codeEnd();
99             writer.ddEnd(); // XXX added for balance
100
}
101     }
102
103     /** print in the summary context at the top of the page
104      * the links out to affected classes/members for this method introduction
105      * (in this aspect)
106      */

107     public void printSummaryCrosscuts(ClassDoc cd,
108                                          ProgramElementDoc member) {
109         Set JavaDoc set = new HashSet JavaDoc();
110         org.aspectj.ajdoc.MemberDoc md = (org.aspectj.ajdoc.MemberDoc)member;
111         IntroducedDoc intro = md.introduced();
112         ClassDoc[] targets = intro.targets();
113         for (int i = 0; i < targets.length; i++) {
114             set.add(targets[i]);
115         }
116         if (targets.length > 0) {
117             writer.boldText("doclet.Advises");
118             List JavaDoc list = new ArrayList JavaDoc(set);
119             Collections.sort(list);
120             for (Iterator JavaDoc i = list.iterator(); i.hasNext();) {
121                 print(' ');
122                 ClassDoc target = (ClassDoc)i.next();
123                 
124                 writer.printClassLink(target,
125                                       "methods_introduced_from_class_"
126                                       + cd.qualifiedName(),
127                                       target.name());
128                 if (i.hasNext()) print(",");
129             }
130         }
131     }
132
133     public boolean hasCrosscuts(ClassDoc classDoc, ProgramElementDoc member) {
134         return true;
135     }
136 }
137
Popular Tags