author | ohair |
Tue, 25 May 2010 15:54:51 -0700 | |
changeset 5520 | 86e4b9a9da40 |
parent 2216 | b124d5c924eb |
child 7614 | cfadc977ca75 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
5520 | 2 |
* Copyright (c) 1998, 2004, Oracle and/or its affiliates. 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.doclets.formats.html; |
|
27 |
||
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
28 |
import java.io.*; |
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
29 |
import java.util.*; |
10 | 30 |
|
31 |
import com.sun.javadoc.*; |
|
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
32 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
10 | 33 |
|
34 |
/** |
|
35 |
* Generate Index for all the Member Names with Indexing in |
|
36 |
* Unicode Order. This class is a base class for {@link SingleIndexWriter} and |
|
37 |
* {@link SplitIndexWriter}. It uses the functionality from |
|
38 |
* {@link HtmlDocletWriter} to generate the Index Contents. |
|
39 |
* |
|
40 |
* @see IndexBuilder |
|
41 |
* @author Atul M Dambalkar |
|
42 |
*/ |
|
43 |
public class AbstractIndexWriter extends HtmlDocletWriter { |
|
44 |
||
45 |
/** |
|
46 |
* The index of all the members with unicode character. |
|
47 |
*/ |
|
48 |
protected IndexBuilder indexbuilder; |
|
49 |
||
50 |
/** |
|
51 |
* This constructor will be used by {@link SplitIndexWriter}. Initialises |
|
52 |
* path to this file and relative path from this file. |
|
53 |
* |
|
54 |
* @param path Path to the file which is getting generated. |
|
55 |
* @param filename Name of the file which is getting genrated. |
|
56 |
* @param relpath Relative path from this file to the current directory. |
|
57 |
* @param indexbuilder Unicode based Index from {@link IndexBuilder} |
|
58 |
*/ |
|
59 |
protected AbstractIndexWriter(ConfigurationImpl configuration, |
|
60 |
String path, String filename, |
|
61 |
String relpath, IndexBuilder indexbuilder) |
|
62 |
throws IOException { |
|
63 |
super(configuration, path, filename, relpath); |
|
64 |
this.indexbuilder = indexbuilder; |
|
65 |
} |
|
66 |
||
67 |
/** |
|
68 |
* This Constructor will be used by {@link SingleIndexWriter}. |
|
69 |
* |
|
70 |
* @param filename Name of the file which is getting genrated. |
|
71 |
* @param indexbuilder Unicode based Index form {@link IndexBuilder} |
|
72 |
*/ |
|
73 |
protected AbstractIndexWriter(ConfigurationImpl configuration, |
|
74 |
String filename, IndexBuilder indexbuilder) |
|
75 |
throws IOException { |
|
76 |
super(configuration, filename); |
|
77 |
this.indexbuilder = indexbuilder; |
|
78 |
} |
|
79 |
||
80 |
/** |
|
1787
1aa079321cd2
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents:
10
diff
changeset
|
81 |
* Print the text "Index" in strong format in the navigation bar. |
10 | 82 |
*/ |
83 |
protected void navLinkIndex() { |
|
84 |
navCellRevStart(); |
|
85 |
fontStyle("NavBarFont1Rev"); |
|
1787
1aa079321cd2
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents:
10
diff
changeset
|
86 |
strongText("doclet.Index"); |
10 | 87 |
fontEnd(); |
88 |
navCellEnd(); |
|
89 |
} |
|
90 |
||
91 |
/** |
|
92 |
* Generate the member information for the unicode character along with the |
|
93 |
* list of the members. |
|
94 |
* |
|
95 |
* @param unicode Unicode for which member list information to be generated. |
|
96 |
* @param memberlist List of members for the unicode character. |
|
97 |
*/ |
|
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1787
diff
changeset
|
98 |
protected void generateContents(Character unicode, List<? extends Doc> memberlist) { |
10 | 99 |
anchor("_" + unicode + "_"); |
100 |
h2(); |
|
1787
1aa079321cd2
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents:
10
diff
changeset
|
101 |
strong(unicode.toString()); |
10 | 102 |
h2End(); |
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
103 |
int memberListSize = memberlist.size(); |
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
104 |
// Display the list only if there are elements to be displayed. |
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
105 |
if (memberListSize > 0) { |
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
106 |
dl(); |
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
107 |
for (int i = 0; i < memberListSize; i++) { |
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
108 |
Doc element = memberlist.get(i); |
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
109 |
if (element instanceof MemberDoc) { |
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
110 |
printDescription((MemberDoc)element); |
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
111 |
} else if (element instanceof ClassDoc) { |
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
112 |
printDescription((ClassDoc)element); |
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
113 |
} else if (element instanceof PackageDoc) { |
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
114 |
printDescription((PackageDoc)element); |
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
115 |
} |
10 | 116 |
} |
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
117 |
dlEnd(); |
10 | 118 |
} |
119 |
hr(); |
|
120 |
} |
|
121 |
||
122 |
||
123 |
/** |
|
124 |
* Print one line summary comment for the package. |
|
125 |
* |
|
126 |
* @param pkg PackageDoc passed. |
|
127 |
*/ |
|
128 |
protected void printDescription(PackageDoc pkg) { |
|
129 |
dt(); |
|
130 |
printPackageLink(pkg, Util.getPackageName(pkg), true); |
|
131 |
print(" - "); |
|
132 |
print(configuration.getText("doclet.package") + " " + pkg.name()); |
|
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
133 |
dtEnd(); |
10 | 134 |
dd(); |
135 |
printSummaryComment(pkg); |
|
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
136 |
ddEnd(); |
10 | 137 |
} |
138 |
||
139 |
/** |
|
140 |
* Print one line summary comment for the class. |
|
141 |
* |
|
142 |
* @param cd ClassDoc passed. |
|
143 |
*/ |
|
144 |
protected void printDescription(ClassDoc cd) { |
|
145 |
dt(); |
|
146 |
printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_INDEX, cd, true)); |
|
147 |
print(" - "); |
|
148 |
printClassInfo(cd); |
|
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
149 |
dtEnd(); |
10 | 150 |
dd(); |
151 |
printComment(cd); |
|
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
152 |
ddEnd(); |
10 | 153 |
} |
154 |
||
155 |
/** |
|
156 |
* Print the classkind(class, interface, exception, error of the class |
|
157 |
* passed. |
|
158 |
* |
|
159 |
* @param cd ClassDoc. |
|
160 |
*/ |
|
161 |
protected void printClassInfo(ClassDoc cd) { |
|
162 |
print(configuration.getText("doclet.in", |
|
163 |
Util.getTypeName(configuration, cd, false), |
|
164 |
getPackageLink(cd.containingPackage(), |
|
165 |
Util.getPackageName(cd.containingPackage()), false))); |
|
166 |
} |
|
167 |
||
168 |
||
169 |
/** |
|
170 |
* Generate Description for Class, Field, Method or Constructor. |
|
171 |
* for Java.* Packages Class Members. |
|
172 |
* |
|
173 |
* @param member MemberDoc for the member of the Class Kind. |
|
174 |
* @see com.sun.javadoc.MemberDoc |
|
175 |
*/ |
|
176 |
protected void printDescription(MemberDoc member) { |
|
177 |
String name = (member instanceof ExecutableMemberDoc)? |
|
178 |
member.name() + ((ExecutableMemberDoc)member).flatSignature() : |
|
179 |
member.name(); |
|
180 |
if (name.indexOf("<") != -1 || name.indexOf(">") != -1) { |
|
181 |
name = Util.escapeHtmlChars(name); |
|
182 |
} |
|
183 |
ClassDoc containing = member.containingClass(); |
|
184 |
dt(); |
|
185 |
printDocLink(LinkInfoImpl.CONTEXT_INDEX, member, name, true); |
|
186 |
println(" - "); |
|
187 |
printMemberDesc(member); |
|
188 |
println(); |
|
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
189 |
dtEnd(); |
10 | 190 |
dd(); |
191 |
printComment(member); |
|
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
192 |
ddEnd(); |
10 | 193 |
println(); |
194 |
} |
|
195 |
||
196 |
||
197 |
/** |
|
198 |
* Print comment for each element in the index. If the element is deprecated |
|
199 |
* and it has a @deprecated tag, use that comment. Else if the containing |
|
200 |
* class for this element is deprecated, then add the word "Deprecated." at |
|
201 |
* the start and then print the normal comment. |
|
202 |
* |
|
203 |
* @param element Index element. |
|
204 |
*/ |
|
205 |
protected void printComment(ProgramElementDoc element) { |
|
206 |
Tag[] tags; |
|
207 |
if (Util.isDeprecated(element)) { |
|
1787
1aa079321cd2
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents:
10
diff
changeset
|
208 |
strongText("doclet.Deprecated"); space(); |
10 | 209 |
if ((tags = element.tags("deprecated")).length > 0) |
210 |
printInlineDeprecatedComment(element, tags[0]); |
|
211 |
} else { |
|
212 |
ClassDoc cont = element.containingClass(); |
|
213 |
while (cont != null) { |
|
214 |
if (Util.isDeprecated(cont)) { |
|
1787
1aa079321cd2
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents:
10
diff
changeset
|
215 |
strongText("doclet.Deprecated"); space(); |
10 | 216 |
break; |
217 |
} |
|
218 |
cont = cont.containingClass(); |
|
219 |
} |
|
220 |
printSummaryComment(element); |
|
221 |
} |
|
222 |
} |
|
223 |
||
224 |
/** |
|
225 |
* Print description about the Static Varible/Method/Constructor for a |
|
226 |
* member. |
|
227 |
* |
|
228 |
* @param member MemberDoc for the member within the Class Kind. |
|
229 |
* @see com.sun.javadoc.MemberDoc |
|
230 |
*/ |
|
231 |
protected void printMemberDesc(MemberDoc member) { |
|
232 |
ClassDoc containing = member.containingClass(); |
|
233 |
String classdesc = Util.getTypeName(configuration, containing, true) + " " + |
|
234 |
getPreQualifiedClassLink(LinkInfoImpl.CONTEXT_INDEX, containing, |
|
235 |
false); |
|
236 |
if (member.isField()) { |
|
237 |
if (member.isStatic()) { |
|
238 |
printText("doclet.Static_variable_in", classdesc); |
|
239 |
} else { |
|
240 |
printText("doclet.Variable_in", classdesc); |
|
241 |
} |
|
242 |
} else if (member.isConstructor()) { |
|
243 |
printText("doclet.Constructor_for", classdesc); |
|
244 |
} else if (member.isMethod()) { |
|
245 |
if (member.isStatic()) { |
|
246 |
printText("doclet.Static_method_in", classdesc); |
|
247 |
} else { |
|
248 |
printText("doclet.Method_in", classdesc); |
|
249 |
} |
|
250 |
} |
|
251 |
} |
|
252 |
} |