KickJava   Java API By Example, From Geeks To Geeks.

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


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 FieldIntroductionSubWriter extends FieldSubWriter {
39
40     public FieldIntroductionSubWriter
41         (com.sun.tools.doclets.standard.SubWriterHolderWriter writer,
42          AspectDoc ad)
43     {
44         super(writer, ad);
45     }
46     
47     public FieldIntroductionSubWriter
48         (com.sun.tools.doclets.standard.SubWriterHolderWriter writer)
49     {
50         super(writer);
51     }
52
53     protected final String JavaDoc keyName() { return "Field_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.isField()) {
69                 //FieldDec field = (FieldDec)member;
70
//TODO: field.bindSignatures(((ClassDec)cd).getTypeScope());
71
list.add(member); //field);
72
}
73         }
74         return list;
75     }
76     
77     /** print links back to aspect in target class docs?
78      * or forward from aspects to target class members? */

79     public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) {
80         org.aspectj.ajdoc.FieldDoc field = (org.aspectj.ajdoc.FieldDoc)member;
81         IntroducedDoc intro = field.introduced();
82         //String name = field.name();
83
ClassDoc[] targets = intro.targets();
84         if (targets.length > 0) {
85             writer.dt(); // define term
86
writer.boldText("doclet.Introduced_on");
87             writer.dd();
88             writer.code();
89             for (int i = 0; i < targets.length; i++) {
90                 if (i > 0) writer.print(", ");
91                 ClassDoc target = targets[i];
92                 writer.printClassLink(target,
93                                       "fields_introduced_from_class_" +
94                                       cd.qualifiedName(),
95                                       target.name());
96                      
97             }
98             writer.codeEnd();
99             writer.ddEnd(); // XXX added for balance
100
}
101     }
102
103     public void printSummaryCrosscuts(ClassDoc cd,
104                                       ProgramElementDoc member) {
105         Set JavaDoc set = new HashSet JavaDoc();
106         org.aspectj.ajdoc.MemberDoc md = (org.aspectj.ajdoc.MemberDoc)member;
107         IntroducedDoc intro = md.introduced();
108         ClassDoc[] targets = intro.targets();
109         for (int i = 0; i < targets.length; i++) {
110             set.add(targets[i]);
111         }
112         if (targets.length > 0) {
113             writer.boldText("doclet.Advises");
114             List JavaDoc list = new ArrayList JavaDoc(set);
115             Collections.sort(list);
116             for (Iterator JavaDoc i = list.iterator(); i.hasNext();) {
117                 print(' ');
118                 ClassDoc target = (ClassDoc)i.next();
119                 writer.printClassLink(target,
120                                       "fields_introduced_from_class_"
121                                       + cd.qualifiedName(),
122                                       target.name());
123                 if (i.hasNext()) print(",");
124             }
125         }
126     }
127
128     public boolean hasCrosscuts(ClassDoc classDoc, ProgramElementDoc member) {
129         return true;
130     }
131 }
132
Popular Tags