src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java

changeset 1568
5f0731e4e5e6
parent 1477
8c0c63a6e3b7
child 1570
f91144b7da75
equal deleted inserted replaced
1488:56c97aff46bb 1568:5f0731e4e5e6
1 /* 1 /*
2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
296 * @return a content for the target package link 296 * @return a content for the target package link
297 */ 297 */
298 public Content getTargetPackageLink(PackageDoc pd, String target, 298 public Content getTargetPackageLink(PackageDoc pd, String target,
299 Content label) { 299 Content label) {
300 return getHyperLink(pathString(pd, DocPaths.PACKAGE_SUMMARY), label, "", target); 300 return getHyperLink(pathString(pd, DocPaths.PACKAGE_SUMMARY), label, "", target);
301 }
302
303 /**
304 * Get Profile Package link, with target frame.
305 *
306 * @param pd the packageDoc object
307 * @param target name of the target frame
308 * @param label tag for the link
309 * @param profileName the name of the profile being documented
310 * @return a content for the target profile packages link
311 */
312 public Content getTargetProfilePackageLink(PackageDoc pd, String target,
313 Content label, String profileName) {
314 return getHyperLink(pathString(pd, DocPaths.profilePackageSummary(profileName)),
315 label, "", target);
316 }
317
318 /**
319 * Get Profile link, with target frame.
320 *
321 * @param target name of the target frame
322 * @param label tag for the link
323 * @param profileName the name of the profile being documented
324 * @return a content for the target profile link
325 */
326 public Content getTargetProfileLink(String target, Content label,
327 String profileName) {
328 return getHyperLink(pathToRoot.resolve(
329 DocPaths.profileSummary(profileName)), label, "", target);
330 }
331
332 /**
333 * Get the type name for profile search.
334 *
335 * @param cd the classDoc object for which the type name conversion is needed
336 * @return a type name string for the type
337 */
338 public String getTypeNameForProfile(ClassDoc cd) {
339 StringBuilder typeName =
340 new StringBuilder((cd.containingPackage()).name().replace(".", "/"));
341 typeName.append("/")
342 .append(cd.name().replace(".", "$"));
343 return typeName.toString();
344 }
345
346 /**
347 * Check if a type belongs to a profile.
348 *
349 * @param cd the classDoc object that needs to be checked
350 * @param profileValue the profile in which the type needs to be checked
351 * @return true if the type is in the profile
352 */
353 public boolean isTypeInProfile(ClassDoc cd, int profileValue) {
354 return (configuration.profiles.getProfile(getTypeNameForProfile(cd)) <= profileValue);
355 }
356
357 public void addClassesSummary(ClassDoc[] classes, String label,
358 String tableSummary, String[] tableHeader, Content summaryContentTree,
359 int profileValue) {
360 if(classes.length > 0) {
361 Arrays.sort(classes);
362 Content caption = getTableCaption(label);
363 Content table = HtmlTree.TABLE(HtmlStyle.packageSummary, 0, 3, 0,
364 tableSummary, caption);
365 table.addContent(getSummaryTableHeader(tableHeader, "col"));
366 Content tbody = new HtmlTree(HtmlTag.TBODY);
367 for (int i = 0; i < classes.length; i++) {
368 if (!isTypeInProfile(classes[i], profileValue)) {
369 continue;
370 }
371 if (!Util.isCoreClass(classes[i]) ||
372 !configuration.isGeneratedDoc(classes[i])) {
373 continue;
374 }
375 Content classContent = new RawHtml(getLink(new LinkInfoImpl(
376 configuration, LinkInfoImpl.CONTEXT_PACKAGE, classes[i],
377 false)));
378 Content tdClass = HtmlTree.TD(HtmlStyle.colFirst, classContent);
379 HtmlTree tr = HtmlTree.TR(tdClass);
380 if (i%2 == 0)
381 tr.addStyle(HtmlStyle.altColor);
382 else
383 tr.addStyle(HtmlStyle.rowColor);
384 HtmlTree tdClassDescription = new HtmlTree(HtmlTag.TD);
385 tdClassDescription.addStyle(HtmlStyle.colLast);
386 if (Util.isDeprecated(classes[i])) {
387 tdClassDescription.addContent(deprecatedLabel);
388 if (classes[i].tags("deprecated").length > 0) {
389 addSummaryDeprecatedComment(classes[i],
390 classes[i].tags("deprecated")[0], tdClassDescription);
391 }
392 }
393 else
394 addSummaryComment(classes[i], tdClassDescription);
395 tr.addContent(tdClassDescription);
396 tbody.addContent(tr);
397 }
398 table.addContent(tbody);
399 Content li = HtmlTree.LI(HtmlStyle.blockList, table);
400 summaryContentTree.addContent(li);
401 }
301 } 402 }
302 403
303 /** 404 /**
304 * Generates the HTML document tree and prints it out. 405 * Generates the HTML document tree and prints it out.
305 * 406 *

mercurial