10
|
1 |
/*
|
|
2 |
* Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
|
|
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.*;
|
|
29 |
import com.sun.tools.doclets.internal.toolkit.util.*;
|
|
30 |
import com.sun.tools.doclets.internal.toolkit.builders.*;
|
|
31 |
import com.sun.javadoc.*;
|
|
32 |
|
|
33 |
/**
|
|
34 |
* Generate the Class Information Page.
|
|
35 |
* @see com.sun.javadoc.ClassDoc
|
|
36 |
* @see java.util.Collections
|
|
37 |
* @see java.util.List
|
|
38 |
* @see java.util.ArrayList
|
|
39 |
* @see java.util.HashMap
|
|
40 |
*
|
|
41 |
* @author Atul M Dambalkar
|
|
42 |
* @author Robert Field
|
|
43 |
*/
|
|
44 |
public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
|
|
45 |
implements AnnotationTypeWriter {
|
|
46 |
|
|
47 |
protected AnnotationTypeDoc annotationType;
|
|
48 |
|
|
49 |
protected Type prev;
|
|
50 |
|
|
51 |
protected Type next;
|
|
52 |
|
|
53 |
/**
|
|
54 |
* @param annotationType the annotation type being documented.
|
|
55 |
* @param prevType the previous class that was documented.
|
|
56 |
* @param nextType the next class being documented.
|
|
57 |
*/
|
|
58 |
public AnnotationTypeWriterImpl (AnnotationTypeDoc annotationType,
|
|
59 |
Type prevType, Type nextType)
|
|
60 |
throws Exception {
|
|
61 |
super(ConfigurationImpl.getInstance(),
|
|
62 |
DirectoryManager.getDirectoryPath(annotationType.containingPackage()),
|
|
63 |
annotationType.name() + ".html",
|
|
64 |
DirectoryManager.getRelativePath(annotationType.containingPackage().name()));
|
|
65 |
this.annotationType = annotationType;
|
|
66 |
configuration.currentcd = annotationType.asClassDoc();
|
|
67 |
this.prev = prevType;
|
|
68 |
this.next = nextType;
|
|
69 |
}
|
|
70 |
|
|
71 |
/**
|
|
72 |
* Print this package link
|
|
73 |
*/
|
|
74 |
protected void navLinkPackage() {
|
|
75 |
navCellStart();
|
|
76 |
printHyperLink("package-summary.html", "",
|
|
77 |
configuration.getText("doclet.Package"), true, "NavBarFont1");
|
|
78 |
navCellEnd();
|
|
79 |
}
|
|
80 |
|
|
81 |
/**
|
|
82 |
* Print class page indicator
|
|
83 |
*/
|
|
84 |
protected void navLinkClass() {
|
|
85 |
navCellRevStart();
|
|
86 |
fontStyle("NavBarFont1Rev");
|
|
87 |
boldText("doclet.Class");
|
|
88 |
fontEnd();
|
|
89 |
navCellEnd();
|
|
90 |
}
|
|
91 |
|
|
92 |
/**
|
|
93 |
* Print class use link
|
|
94 |
*/
|
|
95 |
protected void navLinkClassUse() {
|
|
96 |
navCellStart();
|
|
97 |
printHyperLink("class-use/" + filename, "",
|
|
98 |
configuration.getText("doclet.navClassUse"), true, "NavBarFont1");
|
|
99 |
navCellEnd();
|
|
100 |
}
|
|
101 |
|
|
102 |
/**
|
|
103 |
* Print previous package link
|
|
104 |
*/
|
|
105 |
protected void navLinkPrevious() {
|
|
106 |
if (prev == null) {
|
|
107 |
printText("doclet.Prev_Class");
|
|
108 |
} else {
|
|
109 |
printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS,
|
|
110 |
prev.asClassDoc(), "",
|
|
111 |
configuration.getText("doclet.Prev_Class"), true));
|
|
112 |
}
|
|
113 |
}
|
|
114 |
|
|
115 |
/**
|
|
116 |
* Print next package link
|
|
117 |
*/
|
|
118 |
protected void navLinkNext() {
|
|
119 |
if (next == null) {
|
|
120 |
printText("doclet.Next_Class");
|
|
121 |
} else {
|
|
122 |
printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS,
|
|
123 |
next.asClassDoc(), "",
|
|
124 |
configuration.getText("doclet.Next_Class"), true));
|
|
125 |
}
|
|
126 |
}
|
|
127 |
|
|
128 |
/**
|
|
129 |
* {@inheritDoc}
|
|
130 |
*/
|
|
131 |
public void writeHeader(String header) {
|
|
132 |
|
|
133 |
String pkgname = (annotationType.containingPackage() != null)?
|
|
134 |
annotationType.containingPackage().name(): "";
|
|
135 |
String clname = annotationType.name();
|
|
136 |
|
|
137 |
printHtmlHeader(clname,
|
|
138 |
configuration.metakeywords.getMetaKeywords(annotationType), true);
|
|
139 |
printTop();
|
|
140 |
navLinks(true);
|
|
141 |
hr();
|
|
142 |
println("<!-- ======== START OF CLASS DATA ======== -->");
|
|
143 |
h2();
|
|
144 |
if (pkgname.length() > 0) {
|
|
145 |
font("-1"); print(pkgname); fontEnd(); br();
|
|
146 |
}
|
|
147 |
print(header + getTypeParameterLinks(new LinkInfoImpl(
|
|
148 |
LinkInfoImpl.CONTEXT_CLASS_HEADER,
|
|
149 |
annotationType, false)));
|
|
150 |
h2End();
|
|
151 |
}
|
|
152 |
|
|
153 |
/**
|
|
154 |
* {@inheritDoc}
|
|
155 |
*/
|
|
156 |
public void writeFooter() {
|
|
157 |
println("<!-- ========= END OF CLASS DATA ========= -->");
|
|
158 |
hr();
|
|
159 |
navLinks(false);
|
|
160 |
printBottom();
|
|
161 |
printBodyHtmlEnd();
|
|
162 |
}
|
|
163 |
|
|
164 |
/**
|
|
165 |
* {@inheritDoc}
|
|
166 |
*/
|
|
167 |
public void writeAnnotationTypeSignature(String modifiers) {
|
|
168 |
dl();
|
|
169 |
dt();
|
|
170 |
preNoNewLine();
|
|
171 |
writeAnnotationInfo(annotationType);
|
|
172 |
print(modifiers);
|
|
173 |
String name = annotationType.name() +
|
|
174 |
getTypeParameterLinks(new LinkInfoImpl(
|
|
175 |
LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, annotationType, false));
|
|
176 |
if (configuration().linksource) {
|
|
177 |
printSrcLink(annotationType, name);
|
|
178 |
} else {
|
|
179 |
bold(name);
|
|
180 |
}
|
|
181 |
dlEnd();
|
|
182 |
preEnd();
|
|
183 |
p();
|
|
184 |
}
|
|
185 |
|
|
186 |
/**
|
|
187 |
* {@inheritDoc}
|
|
188 |
*/
|
|
189 |
public void writeAnnotationTypeDescription() {
|
|
190 |
if(!configuration.nocomment) {
|
|
191 |
// generate documentation for the class.
|
|
192 |
if (annotationType.inlineTags().length > 0) {
|
|
193 |
printInlineComment(annotationType);
|
|
194 |
p();
|
|
195 |
}
|
|
196 |
}
|
|
197 |
}
|
|
198 |
|
|
199 |
/**
|
|
200 |
* {@inheritDoc}
|
|
201 |
*/
|
|
202 |
public void writeAnnotationTypeTagInfo() {
|
|
203 |
boolean needHr = annotationType.elements().length > 0;
|
|
204 |
if(!configuration.nocomment) {
|
|
205 |
// Print Information about all the tags here
|
|
206 |
printTags(annotationType);
|
|
207 |
if (needHr) {
|
|
208 |
hr();
|
|
209 |
}
|
|
210 |
p();
|
|
211 |
} else if (needHr) {
|
|
212 |
hr();
|
|
213 |
}
|
|
214 |
}
|
|
215 |
|
|
216 |
/**
|
|
217 |
* {@inheritDoc}
|
|
218 |
*/
|
|
219 |
public void writeAnnotationTypeDeprecationInfo() {
|
|
220 |
hr();
|
|
221 |
Tag[] deprs = annotationType.tags("deprecated");
|
|
222 |
if (Util.isDeprecated(annotationType)) {
|
|
223 |
boldText("doclet.Deprecated");
|
|
224 |
if (deprs.length > 0) {
|
|
225 |
Tag[] commentTags = deprs[0].inlineTags();
|
|
226 |
if (commentTags.length > 0) {
|
|
227 |
|
|
228 |
space();
|
|
229 |
printInlineDeprecatedComment(annotationType, deprs[0]);
|
|
230 |
}
|
|
231 |
}
|
|
232 |
p();
|
|
233 |
}
|
|
234 |
}
|
|
235 |
|
|
236 |
protected void navLinkTree() {
|
|
237 |
navCellStart();
|
|
238 |
printHyperLink("package-tree.html", "",
|
|
239 |
configuration.getText("doclet.Tree"), true, "NavBarFont1");
|
|
240 |
navCellEnd();
|
|
241 |
}
|
|
242 |
|
|
243 |
protected void printSummaryDetailLinks() {
|
|
244 |
try {
|
|
245 |
tr();
|
|
246 |
tdVAlignClass("top", "NavBarCell3");
|
|
247 |
font("-2");
|
|
248 |
print(" ");
|
|
249 |
navSummaryLinks();
|
|
250 |
fontEnd();
|
|
251 |
tdEnd();
|
|
252 |
|
|
253 |
tdVAlignClass("top", "NavBarCell3");
|
|
254 |
font("-2");
|
|
255 |
navDetailLinks();
|
|
256 |
fontEnd();
|
|
257 |
tdEnd();
|
|
258 |
trEnd();
|
|
259 |
} catch (Exception e) {
|
|
260 |
e.printStackTrace();
|
|
261 |
throw new DocletAbortException();
|
|
262 |
}
|
|
263 |
}
|
|
264 |
|
|
265 |
protected void navSummaryLinks() throws Exception {
|
|
266 |
printText("doclet.Summary");
|
|
267 |
space();
|
|
268 |
MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
|
|
269 |
configuration.getBuilderFactory().getMemberSummaryBuilder(this);
|
|
270 |
writeNavSummaryLink(memberSummaryBuilder,
|
|
271 |
"doclet.navAnnotationTypeRequiredMember",
|
|
272 |
VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED);
|
|
273 |
navGap();
|
|
274 |
writeNavSummaryLink(memberSummaryBuilder,
|
|
275 |
"doclet.navAnnotationTypeOptionalMember",
|
|
276 |
VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL);
|
|
277 |
}
|
|
278 |
|
|
279 |
private void writeNavSummaryLink(MemberSummaryBuilder builder,
|
|
280 |
String label, int type) {
|
|
281 |
AbstractMemberWriter writer = ((AbstractMemberWriter) builder.
|
|
282 |
getMemberSummaryWriter(type));
|
|
283 |
if (writer == null) {
|
|
284 |
printText(label);
|
|
285 |
} else {
|
|
286 |
writer.printNavSummaryLink(null,
|
|
287 |
! builder.getVisibleMemberMap(type).noVisibleMembers());
|
|
288 |
}
|
|
289 |
}
|
|
290 |
|
|
291 |
/**
|
|
292 |
* Method navDetailLinks
|
|
293 |
*
|
|
294 |
* @throws Exception
|
|
295 |
*
|
|
296 |
*/
|
|
297 |
protected void navDetailLinks() throws Exception {
|
|
298 |
printText("doclet.Detail");
|
|
299 |
space();
|
|
300 |
MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
|
|
301 |
configuration.getBuilderFactory().getMemberSummaryBuilder(this);
|
|
302 |
AbstractMemberWriter writerOptional =
|
|
303 |
((AbstractMemberWriter) memberSummaryBuilder.
|
|
304 |
getMemberSummaryWriter(VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL));
|
|
305 |
AbstractMemberWriter writerRequired =
|
|
306 |
((AbstractMemberWriter) memberSummaryBuilder.
|
|
307 |
getMemberSummaryWriter(VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED));
|
|
308 |
if (writerOptional != null){
|
|
309 |
writerOptional.printNavDetailLink(annotationType.elements().length > 0);
|
|
310 |
} else if (writerRequired != null){
|
|
311 |
writerRequired.printNavDetailLink(annotationType.elements().length > 0);
|
|
312 |
} else {
|
|
313 |
printText("doclet.navAnnotationTypeMember");
|
|
314 |
}
|
|
315 |
}
|
|
316 |
|
|
317 |
protected void navGap() {
|
|
318 |
space();
|
|
319 |
print('|');
|
|
320 |
space();
|
|
321 |
}
|
|
322 |
|
|
323 |
/**
|
|
324 |
* If this is an inner class or interface, write the enclosing class or
|
|
325 |
* interface.
|
|
326 |
*/
|
|
327 |
public void writeNestedClassInfo() {
|
|
328 |
ClassDoc outerClass = annotationType.containingClass();
|
|
329 |
if (outerClass != null) {
|
|
330 |
dl();
|
|
331 |
dt();
|
|
332 |
if (annotationType.isInterface()) {
|
|
333 |
boldText("doclet.Enclosing_Interface");
|
|
334 |
} else {
|
|
335 |
boldText("doclet.Enclosing_Class");
|
|
336 |
}
|
|
337 |
dd();
|
|
338 |
printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass,
|
|
339 |
false));
|
|
340 |
ddEnd();
|
|
341 |
dlEnd();
|
|
342 |
}
|
|
343 |
}
|
|
344 |
|
|
345 |
/**
|
|
346 |
* {@inheritDoc}
|
|
347 |
*/
|
|
348 |
public AnnotationTypeDoc getAnnotationTypeDoc() {
|
|
349 |
return annotationType;
|
|
350 |
}
|
|
351 |
|
|
352 |
/**
|
|
353 |
* {@inheritDoc}
|
|
354 |
*/
|
|
355 |
public void completeMemberSummaryBuild() {
|
|
356 |
p();
|
|
357 |
}
|
|
358 |
}
|