langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java
author ksrini
Mon, 05 Jun 2017 13:45:34 -0700
changeset 45417 f7479ee8de69
parent 44564 4e1df2513486
permissions -rw-r--r--
8177848: Rename Configuration(Impl) classes Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
44564
4e1df2513486 8177562: Small updates to module summary page
jjg
parents: 42831
diff changeset
     2
 * Copyright (c) 1997, 2017, 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
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    26
package jdk.javadoc.internal.doclets.formats.html.markup;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1863
diff changeset
    28
import java.io.*;
14549
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
    29
import java.util.*;
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1863
diff changeset
    30
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
    31
import jdk.javadoc.doclet.DocletEnvironment.ModuleMode;
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 44564
diff changeset
    32
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    33
import jdk.javadoc.internal.doclets.toolkit.Content;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
    34
import jdk.javadoc.internal.doclets.toolkit.Resources;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    35
import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
40587
1c355ea550ed 8164130: Simplify doclet IOException handling
jjg
parents: 40303
diff changeset
    36
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    37
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    38
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
    39
import jdk.javadoc.internal.doclets.toolkit.util.TableTabTypes;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    40
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * Class for the Html format code generation.
14266
69453558960d 8000673: remove dead code from HtmlWriter and subtypes
jjg
parents: 14265
diff changeset
    44
 * Initializes PrintWriter with FileWriter, to enable print
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * related methods to generate the code to the named File through FileWriter.
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    47
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    48
 *  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: 14259
diff changeset
    49
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    50
 *  deletion without notice.</b>
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    51
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 * @author Atul M Dambalkar
2320
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
    53
 * @author Bhavesh Patel (Modified)
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 */
14266
69453558960d 8000673: remove dead code from HtmlWriter and subtypes
jjg
parents: 14265
diff changeset
    55
public class HtmlWriter {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
     * The window title of this file
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    protected String winTitle;
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     * The configuration
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     */
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 44564
diff changeset
    65
    protected BaseConfiguration configuration;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    /**
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
    68
     * Header for table displaying modules and description.
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
    69
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
    70
    protected final List<String> moduleTableHeader;
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
    71
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
    72
    /**
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
    73
     * Header for tables displaying packages and description.
2320
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
    74
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    75
    protected final List<String> packageTableHeader;
2320
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
    76
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
    77
    /**
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
    78
     * Header for tables displaying modules and description.
39670
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
    79
     */
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
    80
    protected final List<String> requiresTableHeader;
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
    81
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
    82
    /**
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
    83
     * Header for tables displaying packages and description.
39670
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
    84
     */
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
    85
    protected final List<String> exportedPackagesTableHeader;
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
    86
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
    87
    /**
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
    88
     * Header for tables displaying modules and exported packages.
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
    89
     */
44564
4e1df2513486 8177562: Small updates to module summary page
jjg
parents: 42831
diff changeset
    90
    protected final List<String> indirectPackagesTableHeader;
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
    91
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
    92
    /**
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
    93
     * Header for tables displaying types and description.
39670
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
    94
     */
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
    95
    protected final List<String> usesTableHeader;
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
    96
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
    97
    /**
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
    98
     * Header for tables displaying types and description.
39670
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
    99
     */
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
   100
    protected final List<String> providesTableHeader;
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
   101
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
   102
    /**
2320
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
   103
     * Summary for use tables displaying class and package use.
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
   104
     */
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
   105
    protected final String useTableSummary;
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
   106
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
   107
    /**
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
   108
     * Column header for class docs displaying Modifier and Type header.
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
   109
     */
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
   110
    protected final String modifierTypeHeader;
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
   111
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   112
    private final DocFile docFile;
14266
69453558960d 8000673: remove dead code from HtmlWriter and subtypes
jjg
parents: 14265
diff changeset
   113
33920
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 30528
diff changeset
   114
    protected Content script;
14549
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   115
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   116
2320
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
   117
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     * Constructor.
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     * @param path The directory path to be created for this file
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     *             or null if none to be created.
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     */
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 44564
diff changeset
   123
    public HtmlWriter(BaseConfiguration configuration, DocPath path) {
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   124
        docFile = DocFile.createFileForOutput(configuration, path);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        this.configuration = configuration;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   126
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   127
        // The following should be converted to shared Content objects
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   128
        // and moved to Contents, but that will require additional
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   129
        // changes at the use sites.
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   130
        Resources resources = configuration.getResources();
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   131
        moduleTableHeader = Arrays.asList(
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   132
            resources.getText("doclet.Module"),
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   133
            resources.getText("doclet.Description"));
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   134
        packageTableHeader = new ArrayList<>();
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   135
        packageTableHeader.add(resources.getText("doclet.Package"));
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   136
        packageTableHeader.add(resources.getText("doclet.Description"));
39670
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
   137
        requiresTableHeader = new ArrayList<>();
44564
4e1df2513486 8177562: Small updates to module summary page
jjg
parents: 42831
diff changeset
   138
            requiresTableHeader.add(resources.getText("doclet.Modifier"));
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   139
        requiresTableHeader.add(resources.getText("doclet.Module"));
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   140
        requiresTableHeader.add(resources.getText("doclet.Description"));
39670
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
   141
        exportedPackagesTableHeader = new ArrayList<>();
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   142
        exportedPackagesTableHeader.add(resources.getText("doclet.Package"));
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
   143
        if (configuration.docEnv.getModuleMode() == ModuleMode.ALL) {
44564
4e1df2513486 8177562: Small updates to module summary page
jjg
parents: 42831
diff changeset
   144
            exportedPackagesTableHeader.add(resources.getText("doclet.Module"));
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
   145
        }
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   146
        exportedPackagesTableHeader.add(resources.getText("doclet.Description"));
44564
4e1df2513486 8177562: Small updates to module summary page
jjg
parents: 42831
diff changeset
   147
        indirectPackagesTableHeader = new ArrayList<>();
4e1df2513486 8177562: Small updates to module summary page
jjg
parents: 42831
diff changeset
   148
        indirectPackagesTableHeader.add(resources.getText("doclet.From"));
4e1df2513486 8177562: Small updates to module summary page
jjg
parents: 42831
diff changeset
   149
        indirectPackagesTableHeader.add(resources.getText("doclet.Packages"));
39670
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
   150
        usesTableHeader = new ArrayList<>();
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   151
        usesTableHeader.add(resources.getText("doclet.Type"));
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   152
        usesTableHeader.add(resources.getText("doclet.Description"));
39670
9d1eafbf29c6 8154261: Module summary page should display directives for the module
bpatel
parents: 36526
diff changeset
   153
        providesTableHeader = new ArrayList<>();
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   154
        providesTableHeader.add(resources.getText("doclet.Type"));
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   155
        providesTableHeader.add(resources.getText("doclet.Description"));
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   156
        useTableSummary = resources.getText("doclet.Use_Table_Summary",
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   157
                resources.getText("doclet.packages"));
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   158
        modifierTypeHeader = resources.getText("doclet.0_and_1",
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   159
                resources.getText("doclet.Modifier"),
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   160
                resources.getText("doclet.Type"));
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   161
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   162
40587
1c355ea550ed 8164130: Simplify doclet IOException handling
jjg
parents: 40303
diff changeset
   163
    public void write(Content c) throws DocFileIOException {
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   164
        try (Writer writer = docFile.openWriter()) {
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   165
            c.write(writer, true);
40587
1c355ea550ed 8164130: Simplify doclet IOException handling
jjg
parents: 40303
diff changeset
   166
        } catch (IOException e) {
1c355ea550ed 8164130: Simplify doclet IOException handling
jjg
parents: 40303
diff changeset
   167
            throw new DocFileIOException(docFile, DocFileIOException.Mode.WRITE, e);
19907
41ae54351dea 8023700: Use non breaking space in various labels
jjg
parents: 18404
diff changeset
   168
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   172
     * Returns an HtmlTree for the SCRIPT tag.
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
     * @return an HtmlTree for the SCRIPT tag
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
    protected HtmlTree getWinTitleScript(){
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   177
        HtmlTree scriptTree = HtmlTree.SCRIPT();
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   178
        if(winTitle != null && winTitle.length() > 0) {
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   179
            String scriptCode = "<!--\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   180
                    "    try {\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   181
                    "        if (location.href.indexOf('is-external=true') == -1) {\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   182
                    "            parent.document.title=\"" + escapeJavaScriptChars(winTitle) + "\";\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   183
                    "        }\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   184
                    "    }\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   185
                    "    catch(err) {\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   186
                    "    }\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   187
                    "//-->\n";
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   188
            RawHtml scriptContent = new RawHtml(scriptCode.replace("\n", DocletConstants.NL));
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   189
            scriptTree.addContent(scriptContent);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   190
        }
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   191
        return scriptTree;
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   192
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   193
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   194
    /**
21026
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   195
     * Returns a String with escaped special JavaScript characters.
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   196
     *
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   197
     * @param s String that needs to be escaped
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   198
     * @return a valid escaped JavaScript string
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   199
     */
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   200
    private static String escapeJavaScriptChars(String s) {
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   201
        StringBuilder sb = new StringBuilder();
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   202
        for (int i = 0; i < s.length(); i++) {
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   203
            char ch = s.charAt(i);
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   204
            switch (ch) {
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   205
                case '\b':
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   206
                    sb.append("\\b");
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   207
                    break;
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   208
                case '\t':
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   209
                    sb.append("\\t");
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   210
                    break;
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   211
                case '\n':
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   212
                    sb.append("\\n");
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   213
                    break;
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   214
                case '\f':
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   215
                    sb.append("\\f");
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   216
                    break;
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   217
                case '\r':
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   218
                    sb.append("\\r");
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   219
                    break;
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   220
                case '"':
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   221
                    sb.append("\\\"");
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   222
                    break;
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   223
                case '\'':
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   224
                    sb.append("\\\'");
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   225
                    break;
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   226
                case '\\':
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   227
                    sb.append("\\\\");
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   228
                    break;
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   229
                default:
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   230
                    if (ch < 32 || ch >= 127) {
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   231
                        sb.append(String.format("\\u%04X", (int)ch));
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   232
                    } else {
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   233
                        sb.append(ch);
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   234
                    }
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   235
                    break;
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   236
            }
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   237
        }
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   238
        return sb.toString();
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   239
    }
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   240
b35314edf87a 8016675: Make Javadoc pages more robust
bpatel
parents: 18404
diff changeset
   241
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   242
     * Returns a content tree for the SCRIPT tag for the main page(index.html).
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   243
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   244
     * @return a content for the SCRIPT tag
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   245
     */
29429
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 25874
diff changeset
   246
    protected Content getFramesJavaScript() {
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   247
        HtmlTree scriptTree = HtmlTree.SCRIPT();
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   248
        String scriptCode = "\n" +
41630
9cc5bcc88057 8151921: Improved page resolution
bpatel
parents: 40587
diff changeset
   249
                "    tmpTargetPage = \"\" + window.location.search;\n" +
9cc5bcc88057 8151921: Improved page resolution
bpatel
parents: 40587
diff changeset
   250
                "    if (tmpTargetPage != \"\" && tmpTargetPage != \"undefined\")\n" +
9cc5bcc88057 8151921: Improved page resolution
bpatel
parents: 40587
diff changeset
   251
                "        tmpTargetPage = tmpTargetPage.substring(1);\n" +
9cc5bcc88057 8151921: Improved page resolution
bpatel
parents: 40587
diff changeset
   252
                "    if (tmpTargetPage.indexOf(\":\") != -1 || (tmpTargetPage != \"\" && !validURL(tmpTargetPage)))\n" +
9cc5bcc88057 8151921: Improved page resolution
bpatel
parents: 40587
diff changeset
   253
                "        tmpTargetPage = \"undefined\";\n" +
9cc5bcc88057 8151921: Improved page resolution
bpatel
parents: 40587
diff changeset
   254
                "    targetPage = tmpTargetPage;\n" +
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   255
                "    function validURL(url) {\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   256
                "        try {\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   257
                "            url = decodeURIComponent(url);\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   258
                "        }\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   259
                "        catch (error) {\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   260
                "            return false;\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   261
                "        }\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   262
                "        var pos = url.indexOf(\".html\");\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   263
                "        if (pos == -1 || pos != url.length - 5)\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   264
                "            return false;\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   265
                "        var allowNumber = false;\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   266
                "        var allowSep = false;\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   267
                "        var seenDot = false;\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   268
                "        for (var i = 0; i < url.length - 5; i++) {\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   269
                "            var ch = url.charAt(i);\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   270
                "            if ('a' <= ch && ch <= 'z' ||\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   271
                "                    'A' <= ch && ch <= 'Z' ||\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   272
                "                    ch == '$' ||\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   273
                "                    ch == '_' ||\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   274
                "                    ch.charCodeAt(0) > 127) {\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   275
                "                allowNumber = true;\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   276
                "                allowSep = true;\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   277
                "            } else if ('0' <= ch && ch <= '9'\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   278
                "                    || ch == '-') {\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   279
                "                if (!allowNumber)\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   280
                "                     return false;\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   281
                "            } else if (ch == '/' || ch == '.') {\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   282
                "                if (!allowSep)\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   283
                "                    return false;\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   284
                "                allowNumber = false;\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   285
                "                allowSep = false;\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   286
                "                if (ch == '.')\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   287
                "                     seenDot = true;\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   288
                "                if (ch == '/' && seenDot)\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   289
                "                     return false;\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   290
                "            } else {\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   291
                "                return false;\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   292
                "            }\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   293
                "        }\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   294
                "        return true;\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   295
                "    }\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   296
                "    function loadFrames() {\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   297
                "        if (targetPage != \"\" && targetPage != \"undefined\")\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   298
                "             top.classFrame.location = top.targetPage;\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   299
                "    }\n";
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   300
        RawHtml scriptContent = new RawHtml(scriptCode.replace("\n", DocletConstants.NL));
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   301
        scriptTree.addContent(scriptContent);
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   302
        return scriptTree;
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   303
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   304
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   305
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   306
     * Returns an HtmlTree for the BODY tag.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   307
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   308
     * @param includeScript  set true if printing windowtitle script
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   309
     * @param title title for the window
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   310
     * @return an HtmlTree for the BODY tag
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   311
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   312
    public HtmlTree getBody(boolean includeScript, String title) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   313
        HtmlTree body = new HtmlTree(HtmlTag.BODY);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   314
        // Set window title string which is later printed
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   315
        this.winTitle = title;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   316
        // Don't print windowtitle script for overview-frame, allclasses-frame
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   317
        // and package-frame
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   318
        if (includeScript) {
14549
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   319
            this.script = getWinTitleScript();
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   320
            body.addContent(script);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   321
            Content noScript = HtmlTree.NOSCRIPT(
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   322
                    HtmlTree.DIV(configuration.getContent("doclet.No_Script_Message")));
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   323
            body.addContent(noScript);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   324
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   325
        return body;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   326
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   327
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   328
    /**
14549
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   329
     * Generated javascript variables for the document.
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   330
     *
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   331
     * @param typeMap map comprising of method and type relationship
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
   332
     * @param tabTypes set comprising of all table tab types for this class
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
   333
     * @param elementName packages or methods table for which tabs need to be displayed
14549
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   334
     */
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
   335
    public void generateTableTabTypesScript(Map<String,Integer> typeMap,
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
   336
            Set<? extends TableTabTypes> tabTypes, String elementName) {
14549
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   337
        String sep = "";
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
   338
        StringBuilder vars = new StringBuilder("var ");
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
   339
        vars.append(elementName)
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
   340
                .append(" = {");
14549
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   341
        for (Map.Entry<String,Integer> entry : typeMap.entrySet()) {
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   342
            vars.append(sep);
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   343
            sep = ",";
30528
dadaac1f5cc2 8065077: MethodTypes are not localized
bpatel
parents: 29957
diff changeset
   344
            vars.append("\"")
dadaac1f5cc2 8065077: MethodTypes are not localized
bpatel
parents: 29957
diff changeset
   345
                    .append(entry.getKey())
dadaac1f5cc2 8065077: MethodTypes are not localized
bpatel
parents: 29957
diff changeset
   346
                    .append("\":")
dadaac1f5cc2 8065077: MethodTypes are not localized
bpatel
parents: 29957
diff changeset
   347
                    .append(entry.getValue());
14549
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   348
        }
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   349
        vars.append("};").append(DocletConstants.NL);
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   350
        sep = "";
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   351
        vars.append("var tabs = {");
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
   352
        for (TableTabTypes entry : tabTypes) {
14549
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   353
            vars.append(sep);
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   354
            sep = ",";
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
   355
            vars.append(entry.tableTabs().value())
30528
dadaac1f5cc2 8065077: MethodTypes are not localized
bpatel
parents: 29957
diff changeset
   356
                    .append(":")
dadaac1f5cc2 8065077: MethodTypes are not localized
bpatel
parents: 29957
diff changeset
   357
                    .append("[")
dadaac1f5cc2 8065077: MethodTypes are not localized
bpatel
parents: 29957
diff changeset
   358
                    .append("\"")
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
   359
                    .append(entry.tableTabs().tabId())
30528
dadaac1f5cc2 8065077: MethodTypes are not localized
bpatel
parents: 29957
diff changeset
   360
                    .append("\"")
dadaac1f5cc2 8065077: MethodTypes are not localized
bpatel
parents: 29957
diff changeset
   361
                    .append(sep)
dadaac1f5cc2 8065077: MethodTypes are not localized
bpatel
parents: 29957
diff changeset
   362
                    .append("\"")
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41630
diff changeset
   363
                    .append(configuration.getText(entry.tableTabs().resourceKey()))
30528
dadaac1f5cc2 8065077: MethodTypes are not localized
bpatel
parents: 29957
diff changeset
   364
                    .append("\"]");
14549
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   365
        }
30528
dadaac1f5cc2 8065077: MethodTypes are not localized
bpatel
parents: 29957
diff changeset
   366
        vars.append("};")
dadaac1f5cc2 8065077: MethodTypes are not localized
bpatel
parents: 29957
diff changeset
   367
                .append(DocletConstants.NL);
14549
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   368
        addStyles(HtmlStyle.altColor, vars);
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   369
        addStyles(HtmlStyle.rowColor, vars);
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   370
        addStyles(HtmlStyle.tableTab, vars);
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   371
        addStyles(HtmlStyle.activeTableTab, vars);
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36270
diff changeset
   372
        script.addContent(new RawHtml(vars));
14549
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   373
    }
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   374
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   375
    /**
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   376
     * Adds javascript style variables to the document.
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   377
     *
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   378
     * @param style style to be added as a javascript variable
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   379
     * @param vars variable string to which the style variable will be added
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   380
     */
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   381
    public void addStyles(HtmlStyle style, StringBuilder vars) {
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   382
        vars.append("var ").append(style).append(" = \"").append(style)
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   383
                .append("\";").append(DocletConstants.NL);
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   384
    }
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   385
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14368
diff changeset
   386
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   387
     * Returns an HtmlTree for the TITLE tag.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   388
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   389
     * @return an HtmlTree for the TITLE tag
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   390
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   391
    public HtmlTree getTitle() {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   392
        HtmlTree title = HtmlTree.TITLE(new StringContent(winTitle));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   393
        return title;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   394
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
2320
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
   396
    /*
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
   397
     * Returns a header for Modifier and Type column of a table.
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
   398
     */
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
   399
    public String getModifierTypeHeader() {
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
   400
        return modifierTypeHeader;
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2223
diff changeset
   401
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
}