author | mcimadamore |
Tue, 13 Jan 2009 13:27:14 +0000 | |
changeset 1789 | 7ac8c0815000 |
parent 1264 | 076a3cde30d5 |
child 5520 | 86e4b9a9da40 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
1264 | 2 |
* Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Sun designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Sun in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
* have any questions. |
|
24 |
*/ |
|
25 |
||
26 |
package com.sun.tools.doclets.formats.html; |
|
27 |
||
28 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
|
29 |
import com.sun.tools.doclets.internal.toolkit.*; |
|
30 |
||
31 |
import com.sun.javadoc.*; |
|
32 |
import java.io.*; |
|
33 |
import java.util.*; |
|
34 |
/** |
|
35 |
* Class to generate file for each package contents in the left-hand bottom |
|
36 |
* frame. This will list all the Class Kinds in the package. A click on any |
|
37 |
* class-kind will update the right-hand frame with the clicked class-kind page. |
|
38 |
* |
|
39 |
* @author Atul M Dambalkar |
|
40 |
*/ |
|
41 |
public class PackageFrameWriter extends HtmlDocletWriter { |
|
42 |
||
43 |
/** |
|
44 |
* The package being documented. |
|
45 |
*/ |
|
46 |
private PackageDoc packageDoc; |
|
47 |
||
48 |
/** |
|
49 |
* The classes to be documented. Use this to filter out classes |
|
50 |
* that will not be documented. |
|
51 |
*/ |
|
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1264
diff
changeset
|
52 |
private Set<ClassDoc> documentedClasses; |
10 | 53 |
|
54 |
/** |
|
55 |
* The name of the output file. |
|
56 |
*/ |
|
57 |
public static final String OUTPUT_FILE_NAME = "package-frame.html"; |
|
58 |
||
59 |
/** |
|
60 |
* Constructor to construct PackageFrameWriter object and to generate |
|
61 |
* "package-frame.html" file in the respective package directory. |
|
62 |
* For example for package "java.lang" this will generate file |
|
63 |
* "package-frame.html" file in the "java/lang" directory. It will also |
|
64 |
* create "java/lang" directory in the current or the destination directory |
|
65 |
* if it doesen't exist. |
|
66 |
* |
|
67 |
* @param configuration the configuration of the doclet. |
|
68 |
* @param packageDoc PackageDoc under consideration. |
|
69 |
*/ |
|
70 |
public PackageFrameWriter(ConfigurationImpl configuration, |
|
71 |
PackageDoc packageDoc) |
|
72 |
throws IOException { |
|
73 |
super(configuration, DirectoryManager.getDirectoryPath(packageDoc), OUTPUT_FILE_NAME, DirectoryManager.getRelativePath(packageDoc)); |
|
74 |
this.packageDoc = packageDoc; |
|
75 |
if (configuration.root.specifiedPackages().length == 0) { |
|
868 | 76 |
documentedClasses = new HashSet<ClassDoc>(Arrays.asList(configuration.root.classes())); |
10 | 77 |
} |
78 |
} |
|
79 |
||
80 |
/** |
|
81 |
* Generate a package summary page for the left-hand bottom frame. Construct |
|
82 |
* the PackageFrameWriter object and then uses it generate the file. |
|
83 |
* |
|
84 |
* @param configuration the current configuration of the doclet. |
|
85 |
* @param packageDoc The package for which "pacakge-frame.html" is to be generated. |
|
86 |
*/ |
|
87 |
public static void generate(ConfigurationImpl configuration, |
|
88 |
PackageDoc packageDoc) { |
|
89 |
PackageFrameWriter packgen; |
|
90 |
try { |
|
91 |
packgen = new PackageFrameWriter(configuration, packageDoc); |
|
92 |
String pkgName = Util.getPackageName(packageDoc); |
|
93 |
packgen.printHtmlHeader(pkgName, configuration.metakeywords.getMetaKeywords(packageDoc), false); |
|
94 |
packgen.printPackageHeader(pkgName); |
|
95 |
packgen.generateClassListing(); |
|
96 |
packgen.printBodyHtmlEnd(); |
|
97 |
packgen.close(); |
|
98 |
} catch (IOException exc) { |
|
99 |
configuration.standardmessage.error( |
|
100 |
"doclet.exception_encountered", |
|
101 |
exc.toString(), OUTPUT_FILE_NAME); |
|
102 |
throw new DocletAbortException(); |
|
103 |
} |
|
104 |
} |
|
105 |
||
106 |
/** |
|
107 |
* Generate class listing for all the classes in this package. Divide class |
|
108 |
* listing as per the class kind and generate separate listing for |
|
109 |
* Classes, Interfaces, Exceptions and Errors. |
|
110 |
*/ |
|
111 |
protected void generateClassListing() { |
|
112 |
Configuration config = configuration(); |
|
113 |
if (packageDoc.isIncluded()) { |
|
114 |
generateClassKindListing(packageDoc.interfaces(), |
|
115 |
configuration.getText("doclet.Interfaces")); |
|
116 |
generateClassKindListing(packageDoc.ordinaryClasses(), |
|
117 |
configuration.getText("doclet.Classes")); |
|
118 |
generateClassKindListing(packageDoc.enums(), |
|
119 |
configuration.getText("doclet.Enums")); |
|
120 |
generateClassKindListing(packageDoc.exceptions(), |
|
121 |
configuration.getText("doclet.Exceptions")); |
|
122 |
generateClassKindListing(packageDoc.errors(), |
|
123 |
configuration.getText("doclet.Errors")); |
|
124 |
generateClassKindListing(packageDoc.annotationTypes(), |
|
125 |
configuration.getText("doclet.AnnotationTypes")); |
|
126 |
} else { |
|
127 |
String name = Util.getPackageName(packageDoc); |
|
128 |
generateClassKindListing(config.classDocCatalog.interfaces(name), |
|
129 |
configuration.getText("doclet.Interfaces")); |
|
130 |
generateClassKindListing(config.classDocCatalog.ordinaryClasses(name), |
|
131 |
configuration.getText("doclet.Classes")); |
|
132 |
generateClassKindListing(config.classDocCatalog.enums(name), |
|
133 |
configuration.getText("doclet.Enums")); |
|
134 |
generateClassKindListing(config.classDocCatalog.exceptions(name), |
|
135 |
configuration.getText("doclet.Exceptions")); |
|
136 |
generateClassKindListing(config.classDocCatalog.errors(name), |
|
137 |
configuration.getText("doclet.Errors")); |
|
138 |
generateClassKindListing(config.classDocCatalog.annotationTypes(name), |
|
139 |
configuration.getText("doclet.AnnotationTypes")); |
|
140 |
} |
|
141 |
} |
|
142 |
||
143 |
/** |
|
144 |
* Generate specific class kind listing. Also add label to the listing. |
|
145 |
* |
|
146 |
* @param arr Array of specific class kinds, namely Class or Interface or |
|
147 |
* Exception or Error. |
|
148 |
* @param label Label for the listing |
|
149 |
*/ |
|
150 |
protected void generateClassKindListing(ClassDoc[] arr, String label) { |
|
151 |
if(arr.length > 0) { |
|
152 |
Arrays.sort(arr); |
|
153 |
printPackageTableHeader(); |
|
154 |
fontSizeStyle("+1", "FrameHeadingFont"); |
|
155 |
boolean printedHeader = false; |
|
156 |
for (int i = 0; i < arr.length; i++) { |
|
157 |
if (documentedClasses != null && |
|
158 |
!documentedClasses.contains(arr[i])) { |
|
159 |
continue; |
|
160 |
} |
|
161 |
if (!Util.isCoreClass(arr[i]) || ! |
|
162 |
configuration.isGeneratedDoc(arr[i])) { |
|
163 |
continue; |
|
164 |
} |
|
165 |
if (!printedHeader) { |
|
166 |
print(label); |
|
167 |
fontEnd(); |
|
168 |
println(" "); |
|
169 |
fontStyle("FrameItemFont"); |
|
170 |
printedHeader = true; |
|
171 |
} |
|
172 |
br(); |
|
173 |
printLink(new LinkInfoImpl( |
|
174 |
LinkInfoImpl.PACKAGE_FRAME, |
|
175 |
arr[i], |
|
176 |
(arr[i].isInterface() ? |
|
177 |
italicsText(arr[i].name()) : |
|
178 |
arr[i].name()),"classFrame") |
|
179 |
); |
|
180 |
} |
|
181 |
fontEnd(); |
|
182 |
printPackageTableFooter(); |
|
183 |
println(); |
|
184 |
} |
|
185 |
} |
|
186 |
||
187 |
/** |
|
188 |
* Print the package link at the top of the class kind listing. Clicking |
|
189 |
* this link, package-summary page will appear in the right hand frame. |
|
190 |
* |
|
191 |
* @param heading Top Heading to be used for the class kind listing. |
|
192 |
*/ |
|
193 |
protected void printPackageHeader(String heading) { |
|
194 |
fontSizeStyle("+1", "FrameTitleFont"); |
|
195 |
printTargetPackageLink(packageDoc, "classFrame", heading); |
|
196 |
fontEnd(); |
|
197 |
} |
|
198 |
||
199 |
/** |
|
200 |
* The table for the class kind listing. |
|
201 |
*/ |
|
202 |
protected void printPackageTableHeader() { |
|
203 |
table(); |
|
204 |
tr(); |
|
205 |
tdNowrap(); |
|
206 |
} |
|
207 |
||
208 |
/** |
|
209 |
* Closing Html tags for table of class kind listing. |
|
210 |
*/ |
|
211 |
protected void printPackageTableFooter() { |
|
212 |
tdEnd(); |
|
213 |
trEnd(); |
|
214 |
tableEnd(); |
|
215 |
} |
|
216 |
} |