ClassUseWriter.java revision 3595:81692f730015
1/* 2 * Copyright (c) 1998, 2016, Oracle and/or its affiliates. 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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle 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 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. 24 */ 25 26package jdk.javadoc.internal.doclets.formats.html; 27 28import java.io.IOException; 29import java.util.ArrayList; 30import java.util.Collections; 31import java.util.HashMap; 32import java.util.List; 33import java.util.Map; 34import java.util.Set; 35import java.util.SortedSet; 36import java.util.TreeSet; 37 38import javax.lang.model.element.Element; 39import javax.lang.model.element.PackageElement; 40import javax.lang.model.element.TypeElement; 41import javax.tools.Diagnostic; 42 43import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; 44import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; 45import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; 46import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; 47import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; 48import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; 49import jdk.javadoc.internal.doclets.toolkit.Content; 50import jdk.javadoc.internal.doclets.toolkit.Messages; 51import jdk.javadoc.internal.doclets.toolkit.util.ClassTree; 52import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper; 53import jdk.javadoc.internal.doclets.toolkit.util.DocPath; 54import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; 55import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; 56 57/** 58 * Generate class usage information. 59 * 60 * <p><b>This is NOT part of any supported API. 61 * If you write code that depends on this, you do so at your own risk. 62 * This code and its internal interfaces are subject to change or 63 * deletion without notice.</b> 64 * 65 * @author Robert G. Field 66 * @author Bhavesh Patel (Modified) 67 */ 68public class ClassUseWriter extends SubWriterHolderWriter { 69 70 final TypeElement typeElement; 71 Set<PackageElement> pkgToPackageAnnotations = null; 72 final Map<PackageElement, List<Element>> pkgToClassTypeParameter; 73 final Map<PackageElement, List<Element>> pkgToClassAnnotations; 74 final Map<PackageElement, List<Element>> pkgToMethodTypeParameter; 75 final Map<PackageElement, List<Element>> pkgToMethodArgTypeParameter; 76 final Map<PackageElement, List<Element>> pkgToMethodReturnTypeParameter; 77 final Map<PackageElement, List<Element>> pkgToMethodAnnotations; 78 final Map<PackageElement, List<Element>> pkgToMethodParameterAnnotations; 79 final Map<PackageElement, List<Element>> pkgToFieldTypeParameter; 80 final Map<PackageElement, List<Element>> pkgToFieldAnnotations; 81 final Map<PackageElement, List<Element>> pkgToSubclass; 82 final Map<PackageElement, List<Element>> pkgToSubinterface; 83 final Map<PackageElement, List<Element>> pkgToImplementingClass; 84 final Map<PackageElement, List<Element>> pkgToField; 85 final Map<PackageElement, List<Element>> pkgToMethodReturn; 86 final Map<PackageElement, List<Element>> pkgToMethodArgs; 87 final Map<PackageElement, List<Element>> pkgToMethodThrows; 88 final Map<PackageElement, List<Element>> pkgToConstructorAnnotations; 89 final Map<PackageElement, List<Element>> pkgToConstructorParameterAnnotations; 90 final Map<PackageElement, List<Element>> pkgToConstructorArgs; 91 final Map<PackageElement, List<Element>> pkgToConstructorArgTypeParameter; 92 final Map<PackageElement, List<Element>> pkgToConstructorThrows; 93 final SortedSet<PackageElement> pkgSet; 94 final MethodWriterImpl methodSubWriter; 95 final ConstructorWriterImpl constrSubWriter; 96 final FieldWriterImpl fieldSubWriter; 97 final NestedClassWriterImpl classSubWriter; 98 // Summary for various use tables. 99 final String classUseTableSummary; 100 final String subclassUseTableSummary; 101 final String subinterfaceUseTableSummary; 102 final String fieldUseTableSummary; 103 final String methodUseTableSummary; 104 final String constructorUseTableSummary; 105 106 /** 107 * The HTML tree for main tag. 108 */ 109 protected HtmlTree mainTree = HtmlTree.MAIN(); 110 111 /** 112 * Constructor. 113 * 114 * @param filename the file to be generated. 115 * @throws IOException 116 * @throws DocletAbortException 117 */ 118 public ClassUseWriter(ConfigurationImpl configuration, 119 ClassUseMapper mapper, DocPath filename, 120 TypeElement typeElement) throws IOException { 121 super(configuration, filename); 122 this.typeElement = typeElement; 123 if (mapper.classToPackageAnnotations.containsKey(typeElement)) { 124 pkgToPackageAnnotations = new TreeSet<>(utils.makeClassUseComparator()); 125 pkgToPackageAnnotations.addAll(mapper.classToPackageAnnotations.get(typeElement)); 126 } 127 configuration.currentTypeElement = typeElement; 128 this.pkgSet = new TreeSet<>(utils.makePackageComparator()); 129 this.pkgToClassTypeParameter = pkgDivide(mapper.classToClassTypeParam); 130 this.pkgToClassAnnotations = pkgDivide(mapper.classToClassAnnotations); 131 this.pkgToMethodTypeParameter = pkgDivide(mapper.classToMethodTypeParam); 132 this.pkgToMethodArgTypeParameter = pkgDivide(mapper.classToMethodArgTypeParam); 133 this.pkgToFieldTypeParameter = pkgDivide(mapper.classToFieldTypeParam); 134 this.pkgToFieldAnnotations = pkgDivide(mapper.annotationToField); 135 this.pkgToMethodReturnTypeParameter = pkgDivide(mapper.classToMethodReturnTypeParam); 136 this.pkgToMethodAnnotations = pkgDivide(mapper.classToMethodAnnotations); 137 this.pkgToMethodParameterAnnotations = pkgDivide(mapper.classToMethodParamAnnotation); 138 this.pkgToSubclass = pkgDivide(mapper.classToSubclass); 139 this.pkgToSubinterface = pkgDivide(mapper.classToSubinterface); 140 this.pkgToImplementingClass = pkgDivide(mapper.classToImplementingClass); 141 this.pkgToField = pkgDivide(mapper.classToField); 142 this.pkgToMethodReturn = pkgDivide(mapper.classToMethodReturn); 143 this.pkgToMethodArgs = pkgDivide(mapper.classToMethodArgs); 144 this.pkgToMethodThrows = pkgDivide(mapper.classToMethodThrows); 145 this.pkgToConstructorAnnotations = pkgDivide(mapper.classToConstructorAnnotations); 146 this.pkgToConstructorParameterAnnotations = pkgDivide(mapper.classToConstructorParamAnnotation); 147 this.pkgToConstructorArgs = pkgDivide(mapper.classToConstructorArgs); 148 this.pkgToConstructorArgTypeParameter = pkgDivide(mapper.classToConstructorArgTypeParam); 149 this.pkgToConstructorThrows = pkgDivide(mapper.classToConstructorThrows); 150 //tmp test 151 if (pkgSet.size() > 0 && 152 mapper.classToPackage.containsKey(this.typeElement) && 153 !pkgSet.equals(mapper.classToPackage.get(this.typeElement))) { 154 configuration.reporter.print(Diagnostic.Kind.WARNING, 155 "Internal error: package sets don't match: " 156 + pkgSet + " with: " + mapper.classToPackage.get(this.typeElement)); 157 } 158 methodSubWriter = new MethodWriterImpl(this); 159 constrSubWriter = new ConstructorWriterImpl(this); 160 fieldSubWriter = new FieldWriterImpl(this); 161 classSubWriter = new NestedClassWriterImpl(this); 162 classUseTableSummary = configuration.getText("doclet.Use_Table_Summary", 163 configuration.getText("doclet.classes")); 164 subclassUseTableSummary = configuration.getText("doclet.Use_Table_Summary", 165 configuration.getText("doclet.subclasses")); 166 subinterfaceUseTableSummary = configuration.getText("doclet.Use_Table_Summary", 167 configuration.getText("doclet.subinterfaces")); 168 fieldUseTableSummary = configuration.getText("doclet.Use_Table_Summary", 169 configuration.getText("doclet.fields")); 170 methodUseTableSummary = configuration.getText("doclet.Use_Table_Summary", 171 configuration.getText("doclet.methods")); 172 constructorUseTableSummary = configuration.getText("doclet.Use_Table_Summary", 173 configuration.getText("doclet.constructors")); 174 } 175 176 /** 177 * Write out class use pages. 178 * @throws DocletAbortException 179 */ 180 public static void generate(ConfigurationImpl configuration, ClassTree classtree) { 181 ClassUseMapper mapper = new ClassUseMapper(configuration, classtree); 182 for (TypeElement aClass : configuration.docEnv.getIncludedTypeElements()) { 183 // If -nodeprecated option is set and the containing package is marked 184 // as deprecated, do not generate the class-use page. We will still generate 185 // the class-use page if the class is marked as deprecated but the containing 186 // package is not since it could still be linked from that package-use page. 187 if (!(configuration.nodeprecated && 188 configuration.utils.isDeprecated(configuration.utils.containingPackage(aClass)))) 189 ClassUseWriter.generate(configuration, mapper, aClass); 190 } 191 for (PackageElement pkg : configuration.packages) { 192 // If -nodeprecated option is set and the package is marked 193 // as deprecated, do not generate the package-use page. 194 if (!(configuration.nodeprecated && configuration.utils.isDeprecated(pkg))) 195 PackageUseWriter.generate(configuration, mapper, pkg); 196 } 197 } 198 199 private Map<PackageElement, List<Element>> pkgDivide(Map<TypeElement, ? extends List<? extends Element>> classMap) { 200 Map<PackageElement, List<Element>> map = new HashMap<>(); 201 List<? extends Element> elements = (List<? extends Element>) classMap.get(typeElement); 202 if (elements != null) { 203 Collections.sort(elements, utils.makeClassUseComparator()); 204 for (Element e : elements) { 205 PackageElement pkg = utils.containingPackage(e); 206 pkgSet.add(pkg); 207 List<Element> inPkg = map.get(pkg); 208 if (inPkg == null) { 209 inPkg = new ArrayList<>(); 210 map.put(pkg, inPkg); 211 } 212 inPkg.add(e); 213 } 214 } 215 return map; 216 } 217 218 /** 219 * Generate a class page. 220 */ 221 public static void generate(ConfigurationImpl configuration, ClassUseMapper mapper, 222 TypeElement typeElement) { 223 ClassUseWriter clsgen; 224 DocPath path = DocPath.forPackage(configuration.utils, typeElement) 225 .resolve(DocPaths.CLASS_USE) 226 .resolve(DocPath.forName(configuration.utils, typeElement)); 227 try { 228 clsgen = new ClassUseWriter(configuration, mapper, path, typeElement); 229 clsgen.generateClassUseFile(); 230 } catch (IOException exc) { 231 Messages messages = configuration.getMessages(); 232 messages.error("doclet.exception_encountered", 233 exc.toString(), path.getPath()); 234 throw new DocletAbortException(exc); 235 } 236 } 237 238 /** 239 * Generate the class use elements. 240 */ 241 protected void generateClassUseFile() throws IOException { 242 HtmlTree body = getClassUseHeader(); 243 HtmlTree div = new HtmlTree(HtmlTag.DIV); 244 div.addStyle(HtmlStyle.classUseContainer); 245 if (pkgSet.size() > 0) { 246 addClassUse(div); 247 } else { 248 div.addContent(contents.getContent("doclet.ClassUse_No.usage.of.0", 249 utils.getFullyQualifiedName(typeElement))); 250 } 251 if (configuration.allowTag(HtmlTag.MAIN)) { 252 mainTree.addContent(div); 253 body.addContent(mainTree); 254 } else { 255 body.addContent(div); 256 } 257 HtmlTree htmlTree = (configuration.allowTag(HtmlTag.FOOTER)) 258 ? HtmlTree.FOOTER() 259 : body; 260 addNavLinks(false, htmlTree); 261 addBottom(htmlTree); 262 if (configuration.allowTag(HtmlTag.FOOTER)) { 263 body.addContent(htmlTree); 264 } 265 printHtmlDocument(null, true, body); 266 } 267 268 /** 269 * Add the class use documentation. 270 * 271 * @param contentTree the content tree to which the class use information will be added 272 */ 273 protected void addClassUse(Content contentTree) throws IOException { 274 HtmlTree ul = new HtmlTree(HtmlTag.UL); 275 ul.addStyle(HtmlStyle.blockList); 276 if (configuration.packages.size() > 1) { 277 addPackageList(ul); 278 addPackageAnnotationList(ul); 279 } 280 addClassList(ul); 281 contentTree.addContent(ul); 282 } 283 284 /** 285 * Add the packages elements that use the given class. 286 * 287 * @param contentTree the content tree to which the packages elements will be added 288 */ 289 protected void addPackageList(Content contentTree) throws IOException { 290 Content caption = getTableCaption(configuration.getContent( 291 "doclet.ClassUse_Packages.that.use.0", 292 getLink(new LinkInfoImpl(configuration, 293 LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)))); 294 Content table = (configuration.isOutputHtml5()) 295 ? HtmlTree.TABLE(HtmlStyle.useSummary, caption) 296 : HtmlTree.TABLE(HtmlStyle.useSummary, useTableSummary, caption); 297 table.addContent(getSummaryTableHeader(packageTableHeader, "col")); 298 Content tbody = new HtmlTree(HtmlTag.TBODY); 299 boolean altColor = true; 300 for (PackageElement pkg : pkgSet) { 301 HtmlTree tr = new HtmlTree(HtmlTag.TR); 302 tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); 303 altColor = !altColor; 304 addPackageUse(pkg, tr); 305 tbody.addContent(tr); 306 } 307 table.addContent(tbody); 308 Content li = HtmlTree.LI(HtmlStyle.blockList, table); 309 contentTree.addContent(li); 310 } 311 312 /** 313 * Add the package annotation elements. 314 * 315 * @param contentTree the content tree to which the package annotation elements will be added 316 */ 317 protected void addPackageAnnotationList(Content contentTree) throws IOException { 318 if (!utils.isAnnotationType(typeElement) || 319 pkgToPackageAnnotations == null || 320 pkgToPackageAnnotations.isEmpty()) { 321 return; 322 } 323 Content caption = getTableCaption(configuration.getContent( 324 "doclet.ClassUse_PackageAnnotation", 325 getLink(new LinkInfoImpl(configuration, 326 LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)))); 327 Content table = (configuration.isOutputHtml5()) 328 ? HtmlTree.TABLE(HtmlStyle.useSummary, caption) 329 : HtmlTree.TABLE(HtmlStyle.useSummary, useTableSummary, caption); 330 table.addContent(getSummaryTableHeader(packageTableHeader, "col")); 331 Content tbody = new HtmlTree(HtmlTag.TBODY); 332 boolean altColor = true; 333 for (PackageElement pkg : pkgToPackageAnnotations) { 334 HtmlTree tr = new HtmlTree(HtmlTag.TR); 335 tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); 336 altColor = !altColor; 337 Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst, getPackageLink(pkg)); 338 tr.addContent(tdFirst); 339 HtmlTree tdLast = new HtmlTree(HtmlTag.TD); 340 tdLast.addStyle(HtmlStyle.colLast); 341 addSummaryComment(pkg, tdLast); 342 tr.addContent(tdLast); 343 tbody.addContent(tr); 344 } 345 table.addContent(tbody); 346 Content li = HtmlTree.LI(HtmlStyle.blockList, table); 347 contentTree.addContent(li); 348 } 349 350 /** 351 * Add the class elements that use the given class. 352 * 353 * @param contentTree the content tree to which the class elements will be added 354 */ 355 protected void addClassList(Content contentTree) throws IOException { 356 HtmlTree ul = new HtmlTree(HtmlTag.UL); 357 ul.addStyle(HtmlStyle.blockList); 358 for (PackageElement pkg : pkgSet) { 359 Content markerAnchor = getMarkerAnchor(getPackageAnchorName(pkg)); 360 HtmlTree htmlTree = (configuration.allowTag(HtmlTag.SECTION)) 361 ? HtmlTree.SECTION(markerAnchor) 362 : HtmlTree.LI(HtmlStyle.blockList, markerAnchor); 363 Content link = contents.getContent("doclet.ClassUse_Uses.of.0.in.1", 364 getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, 365 typeElement)), 366 getPackageLink(pkg, utils.getPackageName(pkg))); 367 Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link); 368 htmlTree.addContent(heading); 369 addClassUse(pkg, htmlTree); 370 if (configuration.allowTag(HtmlTag.SECTION)) { 371 ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); 372 } else { 373 ul.addContent(htmlTree); 374 } 375 } 376 Content li = HtmlTree.LI(HtmlStyle.blockList, ul); 377 contentTree.addContent(li); 378 } 379 380 /** 381 * Add the package use information. 382 * 383 * @param pkg the package that uses the given class 384 * @param contentTree the content tree to which the package use information will be added 385 */ 386 protected void addPackageUse(PackageElement pkg, Content contentTree) throws IOException { 387 Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst, 388 getHyperLink(getPackageAnchorName(pkg), new StringContent(utils.getPackageName(pkg)))); 389 contentTree.addContent(tdFirst); 390 HtmlTree tdLast = new HtmlTree(HtmlTag.TD); 391 tdLast.addStyle(HtmlStyle.colLast); 392 addSummaryComment(pkg, tdLast); 393 contentTree.addContent(tdLast); 394 } 395 396 /** 397 * Add the class use information. 398 * 399 * @param pkg the package that uses the given class 400 * @param contentTree the content tree to which the class use information will be added 401 */ 402 protected void addClassUse(PackageElement pkg, Content contentTree) throws IOException { 403 Content classLink = getLink(new LinkInfoImpl(configuration, 404 LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)); 405 Content pkgLink = getPackageLink(pkg, utils.getPackageName(pkg)); 406 classSubWriter.addUseInfo(pkgToClassAnnotations.get(pkg), 407 configuration.getContent("doclet.ClassUse_Annotation", classLink, 408 pkgLink), classUseTableSummary, contentTree); 409 classSubWriter.addUseInfo(pkgToClassTypeParameter.get(pkg), 410 configuration.getContent("doclet.ClassUse_TypeParameter", classLink, 411 pkgLink), classUseTableSummary, contentTree); 412 classSubWriter.addUseInfo(pkgToSubclass.get(pkg), 413 configuration.getContent("doclet.ClassUse_Subclass", classLink, 414 pkgLink), subclassUseTableSummary, contentTree); 415 classSubWriter.addUseInfo(pkgToSubinterface.get(pkg), 416 configuration.getContent("doclet.ClassUse_Subinterface", classLink, 417 pkgLink), subinterfaceUseTableSummary, contentTree); 418 classSubWriter.addUseInfo(pkgToImplementingClass.get(pkg), 419 configuration.getContent("doclet.ClassUse_ImplementingClass", classLink, 420 pkgLink), classUseTableSummary, contentTree); 421 fieldSubWriter.addUseInfo(pkgToField.get(pkg), 422 configuration.getContent("doclet.ClassUse_Field", classLink, 423 pkgLink), fieldUseTableSummary, contentTree); 424 fieldSubWriter.addUseInfo(pkgToFieldAnnotations.get(pkg), 425 configuration.getContent("doclet.ClassUse_FieldAnnotations", classLink, 426 pkgLink), fieldUseTableSummary, contentTree); 427 fieldSubWriter.addUseInfo(pkgToFieldTypeParameter.get(pkg), 428 configuration.getContent("doclet.ClassUse_FieldTypeParameter", classLink, 429 pkgLink), fieldUseTableSummary, contentTree); 430 methodSubWriter.addUseInfo(pkgToMethodAnnotations.get(pkg), 431 configuration.getContent("doclet.ClassUse_MethodAnnotations", classLink, 432 pkgLink), methodUseTableSummary, contentTree); 433 methodSubWriter.addUseInfo(pkgToMethodParameterAnnotations.get(pkg), 434 configuration.getContent("doclet.ClassUse_MethodParameterAnnotations", classLink, 435 pkgLink), methodUseTableSummary, contentTree); 436 methodSubWriter.addUseInfo(pkgToMethodTypeParameter.get(pkg), 437 configuration.getContent("doclet.ClassUse_MethodTypeParameter", classLink, 438 pkgLink), methodUseTableSummary, contentTree); 439 methodSubWriter.addUseInfo(pkgToMethodReturn.get(pkg), 440 configuration.getContent("doclet.ClassUse_MethodReturn", classLink, 441 pkgLink), methodUseTableSummary, contentTree); 442 methodSubWriter.addUseInfo(pkgToMethodReturnTypeParameter.get(pkg), 443 configuration.getContent("doclet.ClassUse_MethodReturnTypeParameter", classLink, 444 pkgLink), methodUseTableSummary, contentTree); 445 methodSubWriter.addUseInfo(pkgToMethodArgs.get(pkg), 446 configuration.getContent("doclet.ClassUse_MethodArgs", classLink, 447 pkgLink), methodUseTableSummary, contentTree); 448 methodSubWriter.addUseInfo(pkgToMethodArgTypeParameter.get(pkg), 449 configuration.getContent("doclet.ClassUse_MethodArgsTypeParameters", classLink, 450 pkgLink), methodUseTableSummary, contentTree); 451 methodSubWriter.addUseInfo(pkgToMethodThrows.get(pkg), 452 configuration.getContent("doclet.ClassUse_MethodThrows", classLink, 453 pkgLink), methodUseTableSummary, contentTree); 454 constrSubWriter.addUseInfo(pkgToConstructorAnnotations.get(pkg), 455 configuration.getContent("doclet.ClassUse_ConstructorAnnotations", classLink, 456 pkgLink), constructorUseTableSummary, contentTree); 457 constrSubWriter.addUseInfo(pkgToConstructorParameterAnnotations.get(pkg), 458 configuration.getContent("doclet.ClassUse_ConstructorParameterAnnotations", classLink, 459 pkgLink), constructorUseTableSummary, contentTree); 460 constrSubWriter.addUseInfo(pkgToConstructorArgs.get(pkg), 461 configuration.getContent("doclet.ClassUse_ConstructorArgs", classLink, 462 pkgLink), constructorUseTableSummary, contentTree); 463 constrSubWriter.addUseInfo(pkgToConstructorArgTypeParameter.get(pkg), 464 configuration.getContent("doclet.ClassUse_ConstructorArgsTypeParameters", classLink, 465 pkgLink), constructorUseTableSummary, contentTree); 466 constrSubWriter.addUseInfo(pkgToConstructorThrows.get(pkg), 467 configuration.getContent("doclet.ClassUse_ConstructorThrows", classLink, 468 pkgLink), constructorUseTableSummary, contentTree); 469 } 470 471 /** 472 * Get the header for the class use Listing. 473 * 474 * @return a content tree representing the class use header 475 */ 476 protected HtmlTree getClassUseHeader() { 477 String cltype = configuration.getText(utils.isInterface(typeElement) 478 ? "doclet.Interface" 479 : "doclet.Class"); 480 String clname = utils.getFullyQualifiedName(typeElement); 481 String title = configuration.getText("doclet.Window_ClassUse_Header", 482 cltype, clname); 483 HtmlTree bodyTree = getBody(true, getWindowTitle(title)); 484 HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER)) 485 ? HtmlTree.HEADER() 486 : bodyTree; 487 addTop(htmlTree); 488 addNavLinks(true, htmlTree); 489 if (configuration.allowTag(HtmlTag.HEADER)) { 490 bodyTree.addContent(htmlTree); 491 } 492 ContentBuilder headContent = new ContentBuilder(); 493 headContent.addContent(contents.getContent("doclet.ClassUse_Title", cltype)); 494 headContent.addContent(new HtmlTree(HtmlTag.BR)); 495 headContent.addContent(clname); 496 Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, 497 true, HtmlStyle.title, headContent); 498 Content div = HtmlTree.DIV(HtmlStyle.header, heading); 499 if (configuration.allowTag(HtmlTag.MAIN)) { 500 mainTree.addContent(div); 501 } else { 502 bodyTree.addContent(div); 503 } 504 return bodyTree; 505 } 506 507 /** 508 * Get the module link. 509 * 510 * @return a content tree for the module link 511 */ 512 @Override 513 protected Content getNavLinkModule() { 514 Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement), 515 contents.moduleLabel); 516 Content li = HtmlTree.LI(linkContent); 517 return li; 518 } 519 520 /** 521 * Get this package link. 522 * 523 * @return a content tree for the package link 524 */ 525 protected Content getNavLinkPackage() { 526 Content linkContent = 527 getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), contents.packageLabel); 528 Content li = HtmlTree.LI(linkContent); 529 return li; 530 } 531 532 /** 533 * Get class page link. 534 * 535 * @return a content tree for the class page link 536 */ 537 protected Content getNavLinkClass() { 538 Content linkContent = getLink(new LinkInfoImpl( 539 configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement) 540 .label(configuration.getText("doclet.Class"))); 541 Content li = HtmlTree.LI(linkContent); 542 return li; 543 } 544 545 /** 546 * Get the use link. 547 * 548 * @return a content tree for the use link 549 */ 550 protected Content getNavLinkClassUse() { 551 Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.useLabel); 552 return li; 553 } 554 555 /** 556 * Get the tree link. 557 * 558 * @return a content tree for the tree link 559 */ 560 protected Content getNavLinkTree() { 561 Content linkContent = utils.isEnclosingPackageIncluded(typeElement) 562 ? getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), contents.treeLabel) 563 : getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), contents.treeLabel); 564 Content li = HtmlTree.LI(linkContent); 565 return li; 566 } 567} 568