langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
author jjg
Wed, 10 Oct 2012 16:48:21 -0700
changeset 14260 727a84636f12
parent 14258 8d2148961366
child 14357 faf9cde2817b
permissions -rw-r--r--
8000665: fix "internal API" comments on javadoc files Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 7681
diff changeset
     2
 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2216
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2216
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2216
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2216
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2216
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.doclets.formats.html;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
    28
import java.io.*;
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
    29
import java.util.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import com.sun.javadoc.*;
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    32
import com.sun.tools.doclets.formats.html.markup.*;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    33
import com.sun.tools.doclets.internal.toolkit.*;
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 7681
diff changeset
    34
import com.sun.tools.doclets.internal.toolkit.util.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * Generate Index for all the Member Names with Indexing in
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * Unicode Order. This class is a base class for {@link SingleIndexWriter} and
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * {@link SplitIndexWriter}. It uses the functionality from
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * {@link HtmlDocletWriter} to generate the Index Contents.
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    42
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    43
 *  If you write code that depends on this, you do so at your own risk.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    44
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    45
 *  deletion without notice.</b>
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    46
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * @see    IndexBuilder
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 * @author Atul M Dambalkar
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    49
 * @author Bhavesh Patel (Modified)
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
public class AbstractIndexWriter extends HtmlDocletWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     * The index of all the members with unicode character.
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    protected IndexBuilder indexbuilder;
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
     * This constructor will be used by {@link SplitIndexWriter}. Initialises
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
     * path to this file and relative path from this file.
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     * @param path       Path to the file which is getting generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     * @param filename   Name of the file which is getting genrated.
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     * @param relpath    Relative path from this file to the current directory.
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
     * @param indexbuilder Unicode based Index from {@link IndexBuilder}
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    protected AbstractIndexWriter(ConfigurationImpl configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
                                  String path, String filename,
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
                                  String relpath, IndexBuilder indexbuilder)
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
                                  throws IOException {
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
        super(configuration, path, filename, relpath);
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
        this.indexbuilder = indexbuilder;
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     * This Constructor will be used by {@link SingleIndexWriter}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     * @param filename   Name of the file which is getting genrated.
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * @param indexbuilder Unicode based Index form {@link IndexBuilder}
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    protected AbstractIndexWriter(ConfigurationImpl configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
                                  String filename, IndexBuilder indexbuilder)
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
                                  throws IOException {
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
        super(configuration, filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
        this.indexbuilder = indexbuilder;
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    89
     * Get the index label for navigation bar.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    90
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    91
     * @return a content tree for the tree label
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    93
    protected Content getNavLinkIndex() {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    94
        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, indexLabel);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    95
        return li;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    99
     * Add the member information for the unicode character along with the
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
     * list of the members.
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
     *
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   102
     * @param unicode Unicode for which member list information to be generated
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   103
     * @param memberlist List of members for the unicode character
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   104
     * @param contentTree the content tree to which the information will be added
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   106
    protected void addContents(Character unicode, List<? extends Doc> memberlist,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   107
            Content contentTree) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   108
        contentTree.addContent(getMarkerAnchor("_" + unicode + "_"));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   109
        Content headContent = new StringContent(unicode.toString());
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   110
        Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, false,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   111
                HtmlStyle.title, headContent);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   112
        contentTree.addContent(heading);
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
   113
        int memberListSize = memberlist.size();
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
   114
        // Display the list only if there are elements to be displayed.
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
   115
        if (memberListSize > 0) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   116
            Content dl = new HtmlTree(HtmlTag.DL);
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
   117
            for (int i = 0; i < memberListSize; i++) {
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
   118
                Doc element = memberlist.get(i);
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
   119
                if (element instanceof MemberDoc) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   120
                    addDescription((MemberDoc)element, dl);
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
   121
                } else if (element instanceof ClassDoc) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   122
                    addDescription((ClassDoc)element, dl);
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
   123
                } else if (element instanceof PackageDoc) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   124
                    addDescription((PackageDoc)element, dl);
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
   125
                }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
            }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   127
            contentTree.addContent(dl);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   132
     * Add one line summary comment for the package.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     *
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   134
     * @param pkg the package to be documented
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   135
     * @param dlTree the content tree to which the description will be added
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   137
    protected void addDescription(PackageDoc pkg, Content dlTree) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   138
        Content link = getPackageLink(pkg, new StringContent(Util.getPackageName(pkg)));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   139
        Content dt = HtmlTree.DT(link);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   140
        dt.addContent(" - ");
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   141
        dt.addContent(getResource("doclet.package"));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   142
        dt.addContent(" " + pkg.name());
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   143
        dlTree.addContent(dt);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   144
        Content dd = new HtmlTree(HtmlTag.DD);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   145
        addSummaryComment(pkg, dd);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   146
        dlTree.addContent(dd);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   150
     * Add one line summary comment for the class.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
     *
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   152
     * @param cd the class being documented
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   153
     * @param dlTree the content tree to which the description will be added
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   155
    protected void addDescription(ClassDoc cd, Content dlTree) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   156
        Content link = new RawHtml(
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   157
                getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_INDEX, cd, true)));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   158
        Content dt = HtmlTree.DT(link);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   159
        dt.addContent(" - ");
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   160
        addClassInfo(cd, dt);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   161
        dlTree.addContent(dt);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   162
        Content dd = new HtmlTree(HtmlTag.DD);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   163
        addComment(cd, dd);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   164
        dlTree.addContent(dd);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   168
     * Add the classkind(class, interface, exception, error of the class
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     * passed.
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
     *
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   171
     * @param cd the class being documented
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   172
     * @param contentTree the content tree to which the class info will be added
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   174
    protected void addClassInfo(ClassDoc cd, Content contentTree) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   175
        contentTree.addContent(getResource("doclet.in",
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   176
                Util.getTypeName(configuration, cd, false),
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   177
                getPackageLinkString(cd.containingPackage(),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
                Util.getPackageName(cd.containingPackage()), false)));
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   182
     * Add description for Class, Field, Method or Constructor.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
     *
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   184
     * @param member MemberDoc for the member of the Class Kind
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   185
     * @param dlTree the content tree to which the description will be added
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   187
    protected void addDescription(MemberDoc member, Content dlTree) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
        String name = (member instanceof ExecutableMemberDoc)?
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
            member.name() + ((ExecutableMemberDoc)member).flatSignature() :
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
            member.name();
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
        if (name.indexOf("<") != -1 || name.indexOf(">") != -1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
                name = Util.escapeHtmlChars(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
        }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   194
        Content span = HtmlTree.SPAN(HtmlStyle.strong,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   195
                getDocLink(LinkInfoImpl.CONTEXT_INDEX, member, name));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   196
        Content dt = HtmlTree.DT(span);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   197
        dt.addContent(" - ");
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   198
        addMemberDesc(member, dt);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   199
        dlTree.addContent(dt);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   200
        Content dd = new HtmlTree(HtmlTag.DD);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   201
        addComment(member, dd);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   202
        dlTree.addContent(dd);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   206
     * Add comment for each element in the index. If the element is deprecated
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
     * and it has a @deprecated tag, use that comment. Else if the containing
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
     * class for this element is deprecated, then add the word "Deprecated." at
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
     * the start and then print the normal comment.
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
     *
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   211
     * @param element Index element
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   212
     * @param contentTree the content tree to which the comment will be added
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   214
    protected void addComment(ProgramElementDoc element, Content contentTree) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
        Tag[] tags;
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   216
        Content span = HtmlTree.SPAN(HtmlStyle.strong, deprecatedPhrase);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   217
        HtmlTree div = new HtmlTree(HtmlTag.DIV);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   218
        div.addStyle(HtmlStyle.block);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        if (Util.isDeprecated(element)) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   220
            div.addContent(span);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
            if ((tags = element.tags("deprecated")).length > 0)
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   222
                addInlineDeprecatedComment(element, tags[0], div);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   223
            contentTree.addContent(div);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
            ClassDoc cont = element.containingClass();
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
            while (cont != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
                if (Util.isDeprecated(cont)) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   228
                    div.addContent(span);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   229
                    contentTree.addContent(div);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
                    break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
                cont = cont.containingClass();
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
            }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   234
            addSummaryComment(element, contentTree);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   239
     * Add description about the Static Varible/Method/Constructor for a
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
     * member.
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
     *
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   242
     * @param member MemberDoc for the member within the Class Kind
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   243
     * @param contentTree the content tree to which the member description will be added
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   245
    protected void addMemberDesc(MemberDoc member, Content contentTree) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
        ClassDoc containing = member.containingClass();
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   247
        String classdesc = Util.getTypeName(
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   248
                configuration, containing, true) + " ";
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
        if (member.isField()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
            if (member.isStatic()) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   251
                contentTree.addContent(
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   252
                        getResource("doclet.Static_variable_in", classdesc));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
            } else {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   254
                contentTree.addContent(
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   255
                        getResource("doclet.Variable_in", classdesc));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
        } else if (member.isConstructor()) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   258
            contentTree.addContent(
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   259
                    getResource("doclet.Constructor_for", classdesc));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
        } else if (member.isMethod()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
            if (member.isStatic()) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   262
                contentTree.addContent(
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   263
                        getResource("doclet.Static_method_in", classdesc));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
            } else {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   265
                contentTree.addContent(
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   266
                        getResource("doclet.Method_in", classdesc));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
        }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   269
        addPreQualifiedClassLink(LinkInfoImpl.CONTEXT_INDEX, containing,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   270
                false, contentTree);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
}