langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
author jjg
Thu, 15 Nov 2012 19:54:20 -0800
changeset 14544 d71d992cb905
parent 14542 7062120649c2
child 17560 9f6771abbd1a
permissions -rw-r--r--
8002079: update DocFile to use a JavaFileManager Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 7681
diff changeset
     2
 * Copyright (c) 1997, 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: 2223
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: 2223
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: 2223
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2223
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2223
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.markup;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1787
diff changeset
    28
import java.io.*;
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1787
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.*;
14262
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents: 14260
diff changeset
    32
import com.sun.tools.doclets.formats.html.ConfigurationImpl;
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1787
diff changeset
    33
import com.sun.tools.doclets.internal.toolkit.*;
14544
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14542
diff changeset
    34
import com.sun.tools.doclets.internal.toolkit.util.DocFile;
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
    35
import com.sun.tools.doclets.internal.toolkit.util.DocLink;
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    36
import com.sun.tools.doclets.internal.toolkit.util.DocPath;
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    37
import com.sun.tools.doclets.internal.toolkit.util.DocPaths;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * Class for the Html Format Code Generation specific to JavaDoc.
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * This Class contains methods related to the Html Code Generation which
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * are used by the Sub-Classes in the package com.sun.tools.doclets.standard
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * and com.sun.tools.doclets.oneone.
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 7681
diff changeset
    46
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 7681
diff changeset
    47
 *  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: 7681
diff changeset
    48
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 7681
diff changeset
    49
 *  deletion without notice.</b>
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 7681
diff changeset
    50
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 * @since 1.2
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 * @author Robert Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
public abstract class HtmlDocWriter extends HtmlWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
     * Constructor. Initializes the destination file name through the super
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
     * class HtmlWriter.
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     * @param filename String file name.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     */
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    63
    public HtmlDocWriter(Configuration configuration, DocPath filename)
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    64
            throws IOException {
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    65
        super(configuration, filename);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
        configuration.message.notice("doclet.Generating_0",
14544
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14542
diff changeset
    67
            DocFile.createFileForOutput(configuration, filename).getPath());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     * Accessor for configuration.
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
    public abstract Configuration configuration();
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     * Return Html Hyper Link string.
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     * @param link       String name of the file.
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * @param label      Tag for the link.
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
    80
     * @param strong       Boolean that sets label to strong.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
     * @return String    Hyper Link.
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     */
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
    83
    public String getHyperLinkString(DocPath link,
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
    84
                               String label, boolean strong) {
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
    85
        return getHyperLinkString(link, label, strong, "", "", "");
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
    86
    }
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
    87
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
    88
    public String getHyperLinkString(DocLink link,
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
    89
                               String label, boolean strong) {
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
    90
        return getHyperLinkString(link, label, strong, "", "", "");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     * Get Html Hyper Link string.
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     * @param link       String name of the file.
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     * @param label      Tag for the link.
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
    98
     * @param strong       Boolean that sets label to strong.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
     * @param stylename  String style of text defined in style sheet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
     * @return String    Hyper Link.
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
     */
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   102
    public String getHyperLinkString(DocPath link,
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   103
                               String label, boolean strong,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
                               String stylename) {
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   105
        return getHyperLinkString(link, label, strong, stylename, "", "");
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   106
    }
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   107
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   108
    public String getHyperLinkString(DocLink link,
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   109
                               String label, boolean strong,
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   110
                               String stylename) {
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   111
        return getHyperLinkString(link, label, strong, stylename, "", "");
7614
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
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   114
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   115
     * Get Html Hyper Link string.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   116
     *
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   117
     * @param where      Position of the link in the file. Character '#' is not
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   118
     *                   needed.
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   119
     * @param label      Tag for the link.
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   120
     * @return a content tree for the hyper link
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   121
     */
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   122
    public Content getHyperLink(String where,
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   123
                               Content label) {
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   124
        return getHyperLink(DocLink.fragment(where), label, "", "");
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   125
    }
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   126
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   127
    /**
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   128
     * Get Html Hyper Link string.
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   129
     *
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   130
     * @param link       String name of the file.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   131
     * @param label      Tag for the link.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   132
     * @return a content tree for the hyper link
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   133
     */
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   134
    public Content getHyperLink(DocPath link,
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   135
                               Content label) {
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   136
        return getHyperLink(link, label, "", "");
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   137
    }
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   138
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   139
    public Content getHyperLink(DocLink link,
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   140
                               Content label) {
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   141
        return getHyperLink(link, label, "", "");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
     * Get Html Hyper Link string.
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
     * @param link       String name of the file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
     * @param label      Tag for the link.
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   149
     * @param strong       Boolean that sets label to strong.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
     * @param stylename  String style of text defined in style sheet.
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   151
     * @param title      String that describes the links content for accessibility.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
     * @param target     Target frame.
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
     * @return String    Hyper Link.
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
     */
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   155
    public String getHyperLinkString(DocPath link,
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   156
                               String label, boolean strong,
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   157
                               String stylename, String title, String target) {
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   158
        return getHyperLinkString(new DocLink(link), label, strong,
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   159
                stylename, title, target);
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   160
    }
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   161
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   162
    public String getHyperLinkString(DocLink link,
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   163
                               String label, boolean strong,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
                               String stylename, String title, String target) {
14263
473b1eaede64 8000310: Clean up use of StringBuffer in langtools
jjg
parents: 14262
diff changeset
   165
        StringBuilder retlink = new StringBuilder();
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   166
        retlink.append("<a href=\"").append(link).append('"');
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
        if (title != null && title.length() != 0) {
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   168
            retlink.append(" title=\"").append(title).append('"');
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
        if (target != null && target.length() != 0) {
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   171
            retlink.append(" target=\"").append(target).append('"');
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
        retlink.append(">");
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
        if (stylename != null && stylename.length() != 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
            retlink.append("<FONT CLASS=\"");
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
            retlink.append(stylename);
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
            retlink.append("\">");
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
        }
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   179
        if (strong) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   180
            retlink.append("<span class=\"strong\">");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
        retlink.append(label);
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   183
        if (strong) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   184
            retlink.append("</span>");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
        if (stylename != null && stylename.length() != 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
            retlink.append("</FONT>");
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
        }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   189
        retlink.append("</a>");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
        return retlink.toString();
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 Html Hyper Link.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
     * @param link       String name of the file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
     * @param label      Tag for the link.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   198
     * @param title      String that describes the link's content for accessibility.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   199
     * @param target     Target frame.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   200
     * @return a content tree for the hyper link.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
     */
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   202
    public Content getHyperLink(DocPath link,
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   203
            Content label, String title, String target) {
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   204
        return getHyperLink(new DocLink(link), label, title, target);
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   205
    }
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   206
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   207
    public Content getHyperLink(DocLink link,
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   208
            Content label, String title, String target) {
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   209
        HtmlTree anchor = HtmlTree.A(link.toString(), label);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   210
        if (title != null && title.length() != 0) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   211
            anchor.addAttr(HtmlAttr.TITLE, title);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   212
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   213
        if (target != null && target.length() != 0) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   214
            anchor.addAttr(HtmlAttr.TARGET, target);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   215
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   216
        return anchor;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   217
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   218
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   219
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
     * Get link string without positioning in the file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
     * @param link       String name of the file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
     * @param label      Tag for the link.
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
     * @return Strign    Hyper link.
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
     */
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   226
    public String getHyperLinkString(DocPath link, String label) {
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   227
        return getHyperLinkString(link, label, false);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
     * Get the name of the package, this class is in.
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
     * @param cd    ClassDoc.
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
    public String getPkgName(ClassDoc cd) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
        String pkgName = cd.containingPackage().name();
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
        if (pkgName.length() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
            pkgName += ".";
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
            return pkgName;
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
        return "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1869
diff changeset
   244
    public boolean getMemberDetailsListPrinted() {
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1869
diff changeset
   245
        return memberDetailsListPrinted;
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1869
diff changeset
   246
    }
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1869
diff changeset
   247
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1869
diff changeset
   248
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
     * Print the frameset version of the Html file header.
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
     * Called only when generating an HTML frameset file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
     *
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   252
     * @param title Title of this HTML document
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   253
     * @param noTimeStamp If true, don't print time stamp in header
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   254
     * @param frameset the frameset to be added to the HTML document
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   256
    public void printFramesetDocument(String title, boolean noTimeStamp,
14265
4e8e488eeae0 8000666: javadoc should write directly to Writer instead of composing strings
jjg
parents: 14263
diff changeset
   257
            Content frameset) throws IOException {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14366
diff changeset
   258
        Content htmlDocType = DocType.FRAMESET;
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   259
        Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   260
        Content head = new HtmlTree(HtmlTag.HEAD);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
        if (! noTimeStamp) {
14262
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents: 14260
diff changeset
   262
            Content headComment = new Comment(getGeneratedByString());
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   263
            head.addContent(headComment);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
        if (configuration.charset.length() > 0) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   266
            Content meta = HtmlTree.META("Content-Type", "text/html",
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   267
                    configuration.charset);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   268
            head.addContent(meta);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
        }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   270
        Content windowTitle = HtmlTree.TITLE(new StringContent(title));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   271
        head.addContent(windowTitle);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   272
        head.addContent(getFramesetJavaScript());
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   273
        Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   274
                head, frameset);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   275
        Content htmlDocument = new HtmlDocument(htmlDocType,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   276
                htmlComment, htmlTree);
14266
69453558960d 8000673: remove dead code from HtmlWriter and subtypes
jjg
parents: 14265
diff changeset
   277
        write(htmlDocument);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
     * Print the appropriate spaces to format the class tree in the class page.
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
     * @param len   Number of spaces.
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
    public String spaces(int len) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
        String space = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
        for (int i = 0; i < len; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
            space += " ";
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
        return space;
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
14262
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents: 14260
diff changeset
   294
    protected String getGeneratedByString() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
        Calendar calendar = new GregorianCalendar(TimeZone.getDefault());
14262
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents: 14260
diff changeset
   296
        Date today = calendar.getTime();
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents: 14260
diff changeset
   297
        return "Generated by javadoc ("+ ConfigurationImpl.BUILD_DATE + ") on " + today;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
}