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