KickJava   Java API By Example, From Geeks To Geeks.

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


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.tools.ajdoc.Quietable;
25
26 import com.sun.javadoc.RootDoc;
27 import com.sun.tools.doclets.DocletAbortException;
28 import com.sun.tools.doclets.standard.AllClassesFrameWriter;
29 import com.sun.tools.doclets.standard.FrameOutputWriter;
30 import com.sun.tools.doclets.standard.HelpWriter;
31 import com.sun.tools.doclets.standard.PackageIndexFrameWriter;
32 import com.sun.tools.doclets.standard.PackageIndexWriter;
33 import com.sun.tools.doclets.standard.PackageListWriter;
34 import com.sun.tools.doclets.standard.PackagesFileWriter;
35 import com.sun.tools.doclets.standard.SerializedFormWriter;
36 import com.sun.tools.doclets.standard.StylesheetWriter;
37
38 import java.io.IOException JavaDoc;
39
40 /**
41  * Main doclet for ajdoc. It defines a number of
42  * passes to use in generating the documentation.
43  *
44  * @author Jeff Palm
45  */

46 public class Standard extends AbstractStandard {
47     private static Standard SINGLETON; // todo: prefer early/final?
48
public static final Standard getSingleton() {
49         if (null == SINGLETON) {
50             SINGLETON = new Standard();
51         }
52         return SINGLETON;
53     }
54     private Standard() {}
55
56     public static boolean start(RootDoc root) throws IOException JavaDoc {
57         return start(getSingleton(), root);
58     }
59
60     public ConfigurationStandard getConfiguration() {
61         return (ConfigurationStandard)configuration();
62     }
63
64     public static void quiet() {
65         if (configuration().root instanceof Quietable) {
66             ((Quietable)configuration().root).quiet();
67         }
68     }
69     public static void speak() {
70         if (configuration().root instanceof Quietable) {
71             ((Quietable)configuration().root).speak();
72         }
73     }
74
75     public static class ClassUseMapperPass extends Pass {
76         protected boolean cond() {
77             return cs.classuse;
78         }
79         protected void gen() throws DocletAbortException {
80             ClassUseMapper.generate(root, std.classtree);
81         }
82         public String JavaDoc title() { return "class use mapper"; }
83     }
84
85     public static class TreeWriterPass extends Pass {
86         protected boolean cond() {
87             return cs.createtree;
88         }
89         protected void gen() throws DocletAbortException {
90             TreeWriter.generate(std.classtree);
91         }
92         public String JavaDoc title() { return "tree writer"; }
93     }
94
95     public static class SplitIndexWriterPass extends Pass {
96         protected boolean cond() {
97             return cs.createindex && cs.splitindex;
98         }
99         protected void gen() throws DocletAbortException {
100             SplitIndexWriter.generate(std.indexBuilder(root, false));
101         }
102         public String JavaDoc title() { return "split index"; }
103     }
104
105     public static class SingleIndexWriterPass extends Pass {
106         protected boolean cond() {
107             return cs.createindex && !cs.splitindex;
108         }
109         protected void gen() throws DocletAbortException {
110             SingleIndexWriter.generate(std.indexBuilder(root, false));
111         }
112         public String JavaDoc title() { return "single index"; }
113     }
114
115     public static class DeprecatedListWriterPass extends Pass {
116         protected boolean cond() {
117             return !cs.nodeprecatedlist && !cs.nodeprecated;
118         }
119         protected void gen() throws DocletAbortException {
120             DeprecatedListWriter.generate(root);
121         }
122         public String JavaDoc title() { return "deprecated list"; }
123     }
124
125     public static class AllClassesFrameWriterPass extends Pass {
126         protected void gen() throws DocletAbortException {
127             AllClassesFrameWriter.generate(std.indexBuilder(root, true));
128         }
129         public String JavaDoc title() { return "all classes frame"; }
130     }
131
132     public static class FrameOutputWriterPass extends Pass {
133         protected void gen() throws DocletAbortException {
134             FrameOutputWriter.generate();
135         }
136         public String JavaDoc title() { return "output frame"; }
137     }
138
139     public static class PackagesFileWriterPass extends Pass {
140         protected void gen() throws DocletAbortException {
141             PackagesFileWriter.generate();
142         }
143         public String JavaDoc title() { return "packages files"; }
144     }
145
146     public static class PackageIndexWriterPass extends Pass {
147         protected boolean cond(ConfigurationStandard cs) {
148             return cs.createoverview;
149         }
150         protected void gen() throws DocletAbortException {
151             PackageIndexWriter.generate(root);
152         }
153         public String JavaDoc title() { return "package index"; }
154     }
155     
156     public static class PackageIndexFrameWriterPass extends Pass {
157         protected boolean cond() {
158             return cs.packages.length > 1;
159         }
160         protected void gen() throws DocletAbortException {
161             PackageIndexFrameWriter.generate();
162         }
163         public String JavaDoc title() { return "package index frame"; }
164     }
165     
166     protected Class JavaDoc[] preGenerationClasses() {
167         return new Class JavaDoc[] {
168             ClassUseMapperPass.class,
169             TreeWriterPass.class,
170             SplitIndexWriterPass.class,
171             SingleIndexWriterPass.class,
172             DeprecatedListWriterPass.class,
173             AllClassesFrameWriterPass.class,
174             FrameOutputWriterPass.class,
175             PackagesFileWriterPass.class,
176             PackageIndexWriterPass.class,
177             PackageIndexFrameWriterPass.class,
178         };
179     }
180
181     public static class SerializedFormWriterPass extends Pass {
182         protected void gen() throws DocletAbortException {
183             SerializedFormWriter.generate(root);
184         }
185         public String JavaDoc title() { return "serialized form"; }
186     }
187
188     public static class PackageListWriterPass extends Pass {
189         protected void gen() throws DocletAbortException {
190             PackageListWriter.generate(root);
191         }
192         public String JavaDoc title() { return "package list"; }
193     }
194
195     public static class HelpWriterPass extends Pass {
196         protected boolean cond() {
197             return cs.helpfile.length() == 0 &&
198                 !cs.nohelp;
199         }
200         protected void gen() throws DocletAbortException {
201             HelpWriter.generate();
202         }
203         public String JavaDoc title() { return "help"; }
204     }
205
206     public static class StylesheetWriterPass extends Pass {
207         protected boolean cond() {
208             return cs.stylesheetfile.length() == 0;
209         }
210         protected void gen() throws DocletAbortException {
211             StylesheetWriter.generate();
212         }
213         public String JavaDoc title() { return "style sheet"; }
214     }
215
216     
217     protected Class JavaDoc[] postGenerationClasses() {
218         return new Class JavaDoc[] {
219             SerializedFormWriterPass.class,
220             PackageListWriterPass.class,
221             HelpWriterPass.class,
222             StylesheetWriterPass.class,
223         };
224     }
225
226     public static class NoPublicClassesToDocumentCheck extends Check {
227         protected boolean cond() {
228             return root.classes().length == 0;
229         }
230         protected String JavaDoc message() {
231             return "doclet.No_Public_Classes_To_Document";
232         }
233     }
234     public static class NoNonDeprecatedClassToDocumentCheck extends Check {
235         protected boolean cond() {
236             return cs.topFile.length() == 0;
237         }
238         protected String JavaDoc message() {
239             return "doclet.No_Non_Deprecated_Classes_To_Document";
240         }
241     }
242
243     protected Class JavaDoc[] checkClasses() {
244         return new Class JavaDoc[] {
245             NoPublicClassesToDocumentCheck.class,
246             NoNonDeprecatedClassToDocumentCheck.class,
247         };
248     }
249 }
250         
251
252
Popular Tags