KickJava   Java API By Example, From Geeks To Geeks.

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


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.IntroducedDoc;
26 import org.aspectj.ajdoc.IntroductionDoc;
27
28 import com.sun.javadoc.ClassDoc;
29 import com.sun.javadoc.MemberDoc;
30 import com.sun.javadoc.ProgramElementDoc;
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 ConstructorIntroductionSubWriter extends ConstructorSubWriter {
40     
41     public ConstructorIntroductionSubWriter
42         (com.sun.tools.doclets.standard.SubWriterHolderWriter writer,
43          AspectDoc ad)
44     {
45         super(writer, ad);
46     }
47
48     public ConstructorIntroductionSubWriter
49         (com.sun.tools.doclets.standard.SubWriterHolderWriter writer)
50     {
51         super(writer);
52     }
53
54     protected final String JavaDoc keyName() { return "Constructor_Introduction"; }
55
56     protected List JavaDoc getMembers(ClassDoc cd) {
57         if (!(cd instanceof AspectDoc)) return super.getMembers(cd);
58         IntroductionDoc[] introductions = ((AspectDoc)cd).introductions();
59         List JavaDoc list = new ArrayList JavaDoc();
60         if (introductions == null) return list;
61         for (int i = 0; i < introductions.length; i++) {
62             IntroductionDoc id = introductions[i];
63             if (!(id instanceof IntroducedDoc)) continue;
64             MemberDoc member = ((IntroducedDoc)id).member();
65             if (member.isConstructor()) {
66                 //ConstructorDec constructor = (ConstructorDec)member;
67
//TODO: constructor.bindSignatures(((ClassDec)cd).getTypeScope());
68
list.add(member); //constructor);
69
}
70         }
71         return list;
72     }
73
74     public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) {
75         org.aspectj.ajdoc.ConstructorDoc constr =
76             (org.aspectj.ajdoc.ConstructorDoc)member;
77         IntroducedDoc intro = constr.introduced();
78         //String name = where(constr);
79
ClassDoc[] targets = intro.targets();
80         if (targets.length > 0) {
81             writer.dt();
82             writer.boldText("doclet.Introduced_on");
83             writer.dd();
84             writer.code();
85             for (int i = 0; i < targets.length; i++) {
86                 if (i > 0) writer.print(", ");
87                 ClassDoc target = targets[i];
88                 writer.printClassLink(target,
89                                       "constructors_introduced_from_class_" +
90                                       cd.qualifiedName(),
91                                       target.name());
92             }
93             writer.codeEnd();
94             writer.ddEnd(); // XXX added for balance
95
}
96     }
97
98     public void printSummaryCrosscuts(ClassDoc cd,
99                                          ProgramElementDoc member) {
100         Set JavaDoc set = new HashSet JavaDoc();
101         org.aspectj.ajdoc.MemberDoc md = (org.aspectj.ajdoc.MemberDoc)member;
102         IntroducedDoc intro = md.introduced();
103         ClassDoc[] targets = intro.targets();
104         for (int i = 0; i < targets.length; i++) {
105             set.add(targets[i]);
106         }
107         if (targets.length > 0) {
108             writer.boldText("doclet.Advises");
109             List JavaDoc list = new ArrayList JavaDoc(set);
110             Collections.sort(list);
111             for (Iterator JavaDoc i = list.iterator(); i.hasNext();) {
112                 print(' ');
113                 ClassDoc target = (ClassDoc)i.next();
114                 writer.printClassLink(target,
115                                       "constructors_introduced_from_class_"
116                                       + cd.qualifiedName(),
117                                       target.name());
118                 if (i.hasNext()) print(",");
119             }
120         }
121     }
122
123     public boolean hasCrosscuts(ClassDoc classDoc, ProgramElementDoc member) {
124         return true;
125     }
126 }
127
Popular Tags