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