ClassUseWriter.java revision 3233:b5d08bc0d224
1/*
2 * Copyright (c) 1998, 2015, 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.util.ClassTree;
51import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper;
52import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
53import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
54import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
55
56/**
57 * Generate class usage information.
58 *
59 *  <p><b>This is NOT part of any supported API.
60 *  If you write code that depends on this, you do so at your own risk.
61 *  This code and its internal interfaces are subject to change or
62 *  deletion without notice.</b>
63 *
64 * @author Robert G. Field
65 * @author Bhavesh Patel (Modified)
66 */
67public class ClassUseWriter extends SubWriterHolderWriter {
68
69    final TypeElement typeElement;
70    Set<PackageElement> pkgToPackageAnnotations = null;
71    final Map<PackageElement, List<Element>> pkgToClassTypeParameter;
72    final Map<PackageElement, List<Element>> pkgToClassAnnotations;
73    final Map<PackageElement, List<Element>> pkgToMethodTypeParameter;
74    final Map<PackageElement, List<Element>> pkgToMethodArgTypeParameter;
75    final Map<PackageElement, List<Element>> pkgToMethodReturnTypeParameter;
76    final Map<PackageElement, List<Element>> pkgToMethodAnnotations;
77    final Map<PackageElement, List<Element>> pkgToMethodParameterAnnotations;
78    final Map<PackageElement, List<Element>> pkgToFieldTypeParameter;
79    final Map<PackageElement, List<Element>> pkgToFieldAnnotations;
80    final Map<PackageElement, List<Element>> pkgToSubclass;
81    final Map<PackageElement, List<Element>> pkgToSubinterface;
82    final Map<PackageElement, List<Element>> pkgToImplementingClass;
83    final Map<PackageElement, List<Element>> pkgToField;
84    final Map<PackageElement, List<Element>> pkgToMethodReturn;
85    final Map<PackageElement, List<Element>> pkgToMethodArgs;
86    final Map<PackageElement, List<Element>> pkgToMethodThrows;
87    final Map<PackageElement, List<Element>> pkgToConstructorAnnotations;
88    final Map<PackageElement, List<Element>> pkgToConstructorParameterAnnotations;
89    final Map<PackageElement, List<Element>> pkgToConstructorArgs;
90    final Map<PackageElement, List<Element>> pkgToConstructorArgTypeParameter;
91    final Map<PackageElement, List<Element>> pkgToConstructorThrows;
92    final SortedSet<PackageElement> pkgSet;
93    final MethodWriterImpl methodSubWriter;
94    final ConstructorWriterImpl constrSubWriter;
95    final FieldWriterImpl fieldSubWriter;
96    final NestedClassWriterImpl classSubWriter;
97    // Summary for various use tables.
98    final String classUseTableSummary;
99    final String subclassUseTableSummary;
100    final String subinterfaceUseTableSummary;
101    final String fieldUseTableSummary;
102    final String methodUseTableSummary;
103    final String constructorUseTableSummary;
104
105    /**
106     * The HTML tree for main tag.
107     */
108    protected HtmlTree mainTree = HtmlTree.MAIN();
109
110    /**
111     * Constructor.
112     *
113     * @param filename the file to be generated.
114     * @throws IOException
115     * @throws DocletAbortException
116     */
117    public ClassUseWriter(ConfigurationImpl configuration,
118                          ClassUseMapper mapper, DocPath filename,
119                          TypeElement typeElement) throws IOException {
120        super(configuration, filename);
121        this.typeElement = typeElement;
122        if (mapper.classToPackageAnnotations.containsKey(typeElement)) {
123            pkgToPackageAnnotations = new TreeSet<>(utils.makeClassUseComparator());
124            pkgToPackageAnnotations.addAll(mapper.classToPackageAnnotations.get(typeElement));
125        }
126        configuration.currentTypeElement = typeElement;
127        this.pkgSet = new TreeSet<>(utils.makePackageComparator());
128        this.pkgToClassTypeParameter = pkgDivide(mapper.classToClassTypeParam);
129        this.pkgToClassAnnotations = pkgDivide(mapper.classToClassAnnotations);
130        this.pkgToMethodTypeParameter = pkgDivide(mapper.classToMethodTypeParam);
131        this.pkgToMethodArgTypeParameter = pkgDivide(mapper.classToMethodArgTypeParam);
132        this.pkgToFieldTypeParameter = pkgDivide(mapper.classToFieldTypeParam);
133        this.pkgToFieldAnnotations = pkgDivide(mapper.annotationToField);
134        this.pkgToMethodReturnTypeParameter = pkgDivide(mapper.classToMethodReturnTypeParam);
135        this.pkgToMethodAnnotations = pkgDivide(mapper.classToMethodAnnotations);
136        this.pkgToMethodParameterAnnotations = pkgDivide(mapper.classToMethodParamAnnotation);
137        this.pkgToSubclass = pkgDivide(mapper.classToSubclass);
138        this.pkgToSubinterface = pkgDivide(mapper.classToSubinterface);
139        this.pkgToImplementingClass = pkgDivide(mapper.classToImplementingClass);
140        this.pkgToField = pkgDivide(mapper.classToField);
141        this.pkgToMethodReturn = pkgDivide(mapper.classToMethodReturn);
142        this.pkgToMethodArgs = pkgDivide(mapper.classToMethodArgs);
143        this.pkgToMethodThrows = pkgDivide(mapper.classToMethodThrows);
144        this.pkgToConstructorAnnotations = pkgDivide(mapper.classToConstructorAnnotations);
145        this.pkgToConstructorParameterAnnotations = pkgDivide(mapper.classToConstructorParamAnnotation);
146        this.pkgToConstructorArgs = pkgDivide(mapper.classToConstructorArgs);
147        this.pkgToConstructorArgTypeParameter = pkgDivide(mapper.classToConstructorArgTypeParam);
148        this.pkgToConstructorThrows = pkgDivide(mapper.classToConstructorThrows);
149        //tmp test
150        if (pkgSet.size() > 0 &&
151            mapper.classToPackage.containsKey(this.typeElement) &&
152            !pkgSet.equals(mapper.classToPackage.get(this.typeElement))) {
153            configuration.reporter.print(Diagnostic.Kind.WARNING,
154                    "Internal error: package sets don't match: "
155                    + pkgSet + " with: " + mapper.classToPackage.get(this.typeElement));
156        }
157        methodSubWriter = new MethodWriterImpl(this);
158        constrSubWriter = new ConstructorWriterImpl(this);
159        fieldSubWriter = new FieldWriterImpl(this);
160        classSubWriter = new NestedClassWriterImpl(this);
161        classUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
162                configuration.getText("doclet.classes"));
163        subclassUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
164                configuration.getText("doclet.subclasses"));
165        subinterfaceUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
166                configuration.getText("doclet.subinterfaces"));
167        fieldUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
168                configuration.getText("doclet.fields"));
169        methodUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
170                configuration.getText("doclet.methods"));
171        constructorUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
172                configuration.getText("doclet.constructors"));
173    }
174
175    /**
176     * Write out class use pages.
177     * @throws DocletAbortException
178     */
179    public static void generate(ConfigurationImpl configuration, ClassTree classtree)  {
180        ClassUseMapper mapper = new ClassUseMapper(configuration, classtree);
181        for (TypeElement aClass : configuration.root.getIncludedClasses()) {
182            // If -nodeprecated option is set and the containing package is marked
183            // as deprecated, do not generate the class-use page. We will still generate
184            // the class-use page if the class is marked as deprecated but the containing
185            // package is not since it could still be linked from that package-use page.
186            if (!(configuration.nodeprecated &&
187                  configuration.utils.isDeprecated(configuration.utils.containingPackage(aClass))))
188                ClassUseWriter.generate(configuration, mapper, aClass);
189        }
190        for (PackageElement pkg : configuration.packages) {
191            // If -nodeprecated option is set and the package is marked
192            // as deprecated, do not generate the package-use page.
193            if (!(configuration.nodeprecated && configuration.utils.isDeprecated(pkg)))
194                PackageUseWriter.generate(configuration, mapper, pkg);
195        }
196    }
197
198    private Map<PackageElement, List<Element>> pkgDivide(Map<TypeElement, ? extends List<? extends Element>> classMap) {
199        Map<PackageElement, List<Element>> map = new HashMap<>();
200        List<? extends Element> elements = (List<? extends Element>) classMap.get(typeElement);
201        if (elements != null) {
202            Collections.sort(elements, utils.makeClassUseComparator());
203            for (Element e : elements) {
204                PackageElement pkg = utils.containingPackage(e);
205                pkgSet.add(pkg);
206                List<Element> inPkg = map.get(pkg);
207                if (inPkg == null) {
208                    inPkg = new ArrayList<>();
209                    map.put(pkg, inPkg);
210                }
211                inPkg.add(e);
212            }
213        }
214        return map;
215    }
216
217    /**
218     * Generate a class page.
219     */
220    public static void generate(ConfigurationImpl configuration, ClassUseMapper mapper,
221                                TypeElement typeElement) {
222        ClassUseWriter clsgen;
223        DocPath path = DocPath.forPackage(configuration.utils, typeElement)
224                              .resolve(DocPaths.CLASS_USE)
225                              .resolve(DocPath.forName(configuration.utils, typeElement));
226        try {
227            clsgen = new ClassUseWriter(configuration, mapper, path, typeElement);
228            clsgen.generateClassUseFile();
229            clsgen.close();
230        } catch (IOException exc) {
231            configuration.standardmessage.
232                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(getResource("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.getResource(
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.getResource(
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 = getResource("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.getResource("doclet.ClassUse_Annotation", classLink,
408                pkgLink), classUseTableSummary, contentTree);
409        classSubWriter.addUseInfo(pkgToClassTypeParameter.get(pkg),
410                configuration.getResource("doclet.ClassUse_TypeParameter", classLink,
411                pkgLink), classUseTableSummary, contentTree);
412        classSubWriter.addUseInfo(pkgToSubclass.get(pkg),
413                configuration.getResource("doclet.ClassUse_Subclass", classLink,
414                pkgLink), subclassUseTableSummary, contentTree);
415        classSubWriter.addUseInfo(pkgToSubinterface.get(pkg),
416                configuration.getResource("doclet.ClassUse_Subinterface", classLink,
417                pkgLink), subinterfaceUseTableSummary, contentTree);
418        classSubWriter.addUseInfo(pkgToImplementingClass.get(pkg),
419                configuration.getResource("doclet.ClassUse_ImplementingClass", classLink,
420                pkgLink), classUseTableSummary, contentTree);
421        fieldSubWriter.addUseInfo(pkgToField.get(pkg),
422                configuration.getResource("doclet.ClassUse_Field", classLink,
423                pkgLink), fieldUseTableSummary, contentTree);
424        fieldSubWriter.addUseInfo(pkgToFieldAnnotations.get(pkg),
425                configuration.getResource("doclet.ClassUse_FieldAnnotations", classLink,
426                pkgLink), fieldUseTableSummary, contentTree);
427        fieldSubWriter.addUseInfo(pkgToFieldTypeParameter.get(pkg),
428                configuration.getResource("doclet.ClassUse_FieldTypeParameter", classLink,
429                pkgLink), fieldUseTableSummary, contentTree);
430        methodSubWriter.addUseInfo(pkgToMethodAnnotations.get(pkg),
431                configuration.getResource("doclet.ClassUse_MethodAnnotations", classLink,
432                pkgLink), methodUseTableSummary, contentTree);
433        methodSubWriter.addUseInfo(pkgToMethodParameterAnnotations.get(pkg),
434                configuration.getResource("doclet.ClassUse_MethodParameterAnnotations", classLink,
435                pkgLink), methodUseTableSummary, contentTree);
436        methodSubWriter.addUseInfo(pkgToMethodTypeParameter.get(pkg),
437                configuration.getResource("doclet.ClassUse_MethodTypeParameter", classLink,
438                pkgLink), methodUseTableSummary, contentTree);
439        methodSubWriter.addUseInfo(pkgToMethodReturn.get(pkg),
440                configuration.getResource("doclet.ClassUse_MethodReturn", classLink,
441                pkgLink), methodUseTableSummary, contentTree);
442        methodSubWriter.addUseInfo(pkgToMethodReturnTypeParameter.get(pkg),
443                configuration.getResource("doclet.ClassUse_MethodReturnTypeParameter", classLink,
444                pkgLink), methodUseTableSummary, contentTree);
445        methodSubWriter.addUseInfo(pkgToMethodArgs.get(pkg),
446                configuration.getResource("doclet.ClassUse_MethodArgs", classLink,
447                pkgLink), methodUseTableSummary, contentTree);
448        methodSubWriter.addUseInfo(pkgToMethodArgTypeParameter.get(pkg),
449                configuration.getResource("doclet.ClassUse_MethodArgsTypeParameters", classLink,
450                pkgLink), methodUseTableSummary, contentTree);
451        methodSubWriter.addUseInfo(pkgToMethodThrows.get(pkg),
452                configuration.getResource("doclet.ClassUse_MethodThrows", classLink,
453                pkgLink), methodUseTableSummary, contentTree);
454        constrSubWriter.addUseInfo(pkgToConstructorAnnotations.get(pkg),
455                configuration.getResource("doclet.ClassUse_ConstructorAnnotations", classLink,
456                pkgLink), constructorUseTableSummary, contentTree);
457        constrSubWriter.addUseInfo(pkgToConstructorParameterAnnotations.get(pkg),
458                configuration.getResource("doclet.ClassUse_ConstructorParameterAnnotations", classLink,
459                pkgLink), constructorUseTableSummary, contentTree);
460        constrSubWriter.addUseInfo(pkgToConstructorArgs.get(pkg),
461                configuration.getResource("doclet.ClassUse_ConstructorArgs", classLink,
462                pkgLink), constructorUseTableSummary, contentTree);
463        constrSubWriter.addUseInfo(pkgToConstructorArgTypeParameter.get(pkg),
464                configuration.getResource("doclet.ClassUse_ConstructorArgsTypeParameters", classLink,
465                pkgLink), constructorUseTableSummary, contentTree);
466        constrSubWriter.addUseInfo(pkgToConstructorThrows.get(pkg),
467                configuration.getResource("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(getResource("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 this package link.
509     *
510     * @return a content tree for the package link
511     */
512    protected Content getNavLinkPackage() {
513        Content linkContent =
514                getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), packageLabel);
515        Content li = HtmlTree.LI(linkContent);
516        return li;
517    }
518
519    /**
520     * Get class page link.
521     *
522     * @return a content tree for the class page link
523     */
524    protected Content getNavLinkClass() {
525        Content linkContent = getLink(new LinkInfoImpl(
526                configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)
527                .label(configuration.getText("doclet.Class")));
528        Content li = HtmlTree.LI(linkContent);
529        return li;
530    }
531
532    /**
533     * Get the use link.
534     *
535     * @return a content tree for the use link
536     */
537    protected Content getNavLinkClassUse() {
538        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, useLabel);
539        return li;
540    }
541
542    /**
543     * Get the tree link.
544     *
545     * @return a content tree for the tree link
546     */
547    protected Content getNavLinkTree() {
548        Content linkContent = utils.isEnclosingPackageIncluded(typeElement)
549                ? getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), treeLabel)
550                : getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), treeLabel);
551        Content li = HtmlTree.LI(linkContent);
552        return li;
553    }
554}
555