langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java
author ohair
Tue, 28 Dec 2010 15:54:52 -0800
changeset 7681 1f0819a3341f
parent 7614 cfadc977ca75
child 14258 8d2148961366
permissions -rw-r--r--
6962318: Update copyright year Reviewed-by: xdono
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
7681
1f0819a3341f 6962318: Update copyright year
ohair
parents: 7614
diff changeset
     2
 * Copyright (c) 2001, 2010, 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: 2320
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: 2320
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: 2320
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2320
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2320
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
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    28
import java.io.*;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    29
import java.util.*;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    30
import com.sun.javadoc.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import com.sun.tools.doclets.internal.toolkit.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import com.sun.tools.doclets.internal.toolkit.util.*;
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    33
import com.sun.tools.doclets.formats.html.markup.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * Write the Constants Summary Page in HTML format.
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * @author Jamie Ho
2320
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 1789
diff changeset
    39
 * @author Bhavesh Patel (Modified)
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * @since 1.4
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
        implements ConstantsSummaryWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
     * The configuration used in this run of the standard doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    ConfigurationImpl configuration;
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     * The current class being documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    private ClassDoc currentClassDoc;
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
2320
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 1789
diff changeset
    55
    private final String constantsTableSummary;
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 1789
diff changeset
    56
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 1789
diff changeset
    57
    private final String[] constantsTableHeader;
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 1789
diff changeset
    58
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
     * Construct a ConstantsSummaryWriter.
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     * @param configuration the configuration used in this run
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     *        of the standard doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    public ConstantsSummaryWriterImpl(ConfigurationImpl configuration)
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
            throws IOException {
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
        super(configuration, ConfigurationImpl.CONSTANTS_FILE_NAME);
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
        this.configuration = configuration;
2320
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 1789
diff changeset
    68
        constantsTableSummary = configuration.getText("doclet.Constants_Table_Summary",
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 1789
diff changeset
    69
                configuration.getText("doclet.Constants_Summary"));
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 1789
diff changeset
    70
        constantsTableHeader = new String[] {
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 1789
diff changeset
    71
            getModifierTypeHeader(),
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 1789
diff changeset
    72
            configuration.getText("doclet.ConstantField"),
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 1789
diff changeset
    73
            configuration.getText("doclet.Value")
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 1789
diff changeset
    74
        };
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    80
    public Content getHeader() {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    81
        String label = configuration.getText("doclet.Constants_Summary");
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    82
        Content bodyTree = getBody(true, getWindowTitle(label));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    83
        addTop(bodyTree);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    84
        addNavLinks(true, bodyTree);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    85
        return bodyTree;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    91
    public Content getContentsHeader() {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    92
        return new HtmlTree(HtmlTag.UL);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    93
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    94
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    95
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    96
     * {@inheritDoc}
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    97
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    98
    public void addLinkToPackageContent(PackageDoc pkg, String parsedPackageName,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    99
            Set<String> printedPackageHeaders, Content contentListTree) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   100
        String packageName = pkg.name();
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   101
        //add link to summary
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   102
        Content link;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   103
        if (packageName.length() == 0) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   104
            link = getHyperLink("#" + DocletConstants.UNNAMED_PACKAGE_ANCHOR,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   105
                    "", defaultPackageLabel, "", "");
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   106
        } else {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   107
            Content packageNameContent = getPackageLabel(parsedPackageName);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   108
            packageNameContent.addContent(".*");
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   109
            link = getHyperLink("#" + parsedPackageName,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   110
                    "", packageNameContent, "", "");
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   111
            printedPackageHeaders.add(parsedPackageName);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   112
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   113
        contentListTree.addContent(HtmlTree.LI(link));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   119
    public Content getContentsList(Content contentListTree) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   120
        Content titleContent = getResource(
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   121
                "doclet.Constants_Summary");
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   122
        Content pHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   123
                HtmlStyle.title, titleContent);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   124
        Content div = HtmlTree.DIV(HtmlStyle.header, pHeading);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   125
        Content headingContent = getResource(
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   126
                "doclet.Contents");
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   127
        div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   128
                headingContent));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   129
        div.addContent(contentListTree);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   130
        return div;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   136
    public Content getConstantSummaries() {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   137
        HtmlTree summariesDiv = new HtmlTree(HtmlTag.DIV);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   138
        summariesDiv.addStyle(HtmlStyle.constantValuesContainer);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   139
        return summariesDiv;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   145
    public void addPackageName(PackageDoc pkg, String parsedPackageName,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   146
            Content summariesTree) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   147
        Content pkgNameContent;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   148
        if (parsedPackageName.length() == 0) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   149
            summariesTree.addContent(getMarkerAnchor(
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   150
                    DocletConstants.UNNAMED_PACKAGE_ANCHOR));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   151
            pkgNameContent = defaultPackageLabel;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        } else {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   153
            summariesTree.addContent(getMarkerAnchor(
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   154
                    parsedPackageName));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   155
            pkgNameContent = getPackageLabel(parsedPackageName);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   157
        Content headingContent = new StringContent(".*");
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   158
        Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   159
                pkgNameContent);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   160
        heading.addContent(headingContent);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   161
        summariesTree.addContent(heading);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   167
    public Content getClassConstantHeader() {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   168
        HtmlTree ul = new HtmlTree(HtmlTag.UL);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   169
        ul.addStyle(HtmlStyle.blockList);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   170
        return ul;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   171
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   172
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   173
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   174
     * Get the table caption and header for the constant summary table
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   175
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   176
     * @param cd classdoc to be documented
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   177
     * @return constant members header content
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   178
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   179
    public Content getConstantMembersHeader(ClassDoc cd) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        //generate links backward only to public classes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
        String classlink = (cd.isPublic() || cd.isProtected())?
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
            getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, cd,
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
                false)) :
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
            cd.qualifiedName();
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
        String name = cd.containingPackage().name();
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
        if (name.length() > 0) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   187
            return getClassName(name + "." + classlink);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
        } else {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   189
            return getClassName(classlink);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
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
     * Get the class name in the table caption and the table header.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   195
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   196
     * @param classStr the class name to print.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   197
     * @return the table caption and header
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   199
    protected Content getClassName(String classStr) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   200
        Content table = HtmlTree.TABLE(0, 3, 0, constantsTableSummary,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   201
                getTableCaption(classStr));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   202
        table.addContent(getSummaryTableHeader(constantsTableHeader, "col"));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   203
        return table;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   209
    public void addConstantMembers(ClassDoc cd, List<FieldDoc> fields,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   210
            Content classConstantTree) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   211
        currentClassDoc = cd;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   212
        Content tbody = new HtmlTree(HtmlTag.TBODY);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   213
        for (int i = 0; i < fields.size(); ++i) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   214
            HtmlTree tr = new HtmlTree(HtmlTag.TR);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   215
            if (i%2 == 0)
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   216
                tr.addStyle(HtmlStyle.altColor);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   217
            else
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   218
                tr.addStyle(HtmlStyle.rowColor);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   219
            addConstantMember(fields.get(i), tr);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   220
            tbody.addContent(tr);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
        }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   222
        Content table = getConstantMembersHeader(cd);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   223
        table.addContent(tbody);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   224
        Content li = HtmlTree.LI(HtmlStyle.blockList, table);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   225
        classConstantTree.addContent(li);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   226
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   227
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   228
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   229
     * Add the row for the constant summary table.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   230
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   231
     * @param member the field to be documented.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   232
     * @param trTree an htmltree object for the table row
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   233
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   234
    private void addConstantMember(FieldDoc member, HtmlTree trTree) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   235
        trTree.addContent(getTypeColumn(member));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   236
        trTree.addContent(getNameColumn(member));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   237
        trTree.addContent(getValue(member));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   238
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   239
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   240
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   241
     * Get the type column for the constant summary table row.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   242
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   243
     * @param member the field to be documented.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   244
     * @return the type column of the constant table row
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   245
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   246
    private Content getTypeColumn(FieldDoc member) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   247
        Content anchor = getMarkerAnchor(currentClassDoc.qualifiedName() +
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   248
                "." + member.name());
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   249
        Content tdType = HtmlTree.TD(HtmlStyle.colFirst, anchor);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   250
        Content code = new HtmlTree(HtmlTag.CODE);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   251
        StringTokenizer mods = new StringTokenizer(member.modifiers());
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   252
        while(mods.hasMoreTokens()) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   253
            Content modifier = new StringContent(mods.nextToken());
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   254
            code.addContent(modifier);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   255
            code.addContent(getSpace());
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   256
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   257
        Content type = new RawHtml(getLink(new LinkInfoImpl(
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   258
                LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, member.type())));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   259
        code.addContent(type);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   260
        tdType.addContent(code);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   261
        return tdType;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   262
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   263
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   264
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   265
     * Get the name column for the constant summary table row.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   266
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   267
     * @param member the field to be documented.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   268
     * @return the name column of the constant table row
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   269
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   270
    private Content getNameColumn(FieldDoc member) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   271
        Content nameContent = new RawHtml(getDocLink(
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   272
                LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, member, member.name(), false));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   273
        Content code = HtmlTree.CODE(nameContent);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   274
        return HtmlTree.TD(code);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   275
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   276
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   277
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   278
     * Get the value column for the constant summary table row.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   279
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   280
     * @param member the field to be documented.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   281
     * @return the value column of the constant table row
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   282
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   283
    private Content getValue(FieldDoc member) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   284
        Content valueContent = new StringContent(member.constantValueExpression());
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   285
        Content code = HtmlTree.CODE(valueContent);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   286
        return HtmlTree.TD(HtmlStyle.colLast, code);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   292
    public void addFooter(Content contentTree) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   293
        addNavLinks(false, contentTree);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   294
        addBottom(contentTree);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   297
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   298
     * {@inheritDoc}
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   299
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   300
    public void printDocument(Content contentTree) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   301
        printHtmlDocument(null, true, contentTree);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
}