langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
author briangoetz
Wed, 18 Dec 2013 10:29:25 -0500
changeset 22159 682da512ec17
parent 22153 f9f06fcca59d
child 22163 3651128c74eb
permissions -rw-r--r--
8030253: Update langtools to use strings-in-switch 8030262: Update langtools to use foreach loops 8030245: Update langtools to use try-with-resources and multi-catch Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14545
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: 2212
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: 2212
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: 2212
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2212
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2212
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.internal.toolkit;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 14061
diff changeset
    28
import java.io.*;
8d2148961366 8000663: clean up langtools imports
jjg
parents: 14061
diff changeset
    29
import java.util.*;
17563
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
    30
import java.util.regex.Matcher;
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
    31
import java.util.regex.Pattern;
22153
f9f06fcca59d 8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents: 19937
diff changeset
    32
import javax.tools.JavaFileManager;
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 14061
diff changeset
    33
8d2148961366 8000663: clean up langtools imports
jjg
parents: 14061
diff changeset
    34
import com.sun.javadoc.*;
15723
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
    35
import com.sun.tools.javac.sym.Profiles;
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
    36
import com.sun.tools.javac.jvm.Profile;
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 14061
diff changeset
    37
import com.sun.tools.doclets.internal.toolkit.builders.BuilderFactory;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
import com.sun.tools.doclets.internal.toolkit.taglets.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
import com.sun.tools.doclets.internal.toolkit.util.*;
22153
f9f06fcca59d 8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents: 19937
diff changeset
    40
import com.sun.tools.javac.util.StringUtils;
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
 * Configure the output based on the options. Doclets should sub-class
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * Configuration, to configure and add their own options. This class contains
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * all user options which are supported by the 1.1 doclet and the standard
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    48
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    49
 *  If you write code that depends on this, you do so at your own risk.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    50
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    51
 *  deletion without notice.</b>
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 * @author Robert Field.
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 * @author Atul Dambalkar.
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
 * @author Jamie Ho
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
public abstract class Configuration {
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    /**
16324
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
    60
     * Exception used to report a problem during setOptions.
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
    61
     */
16560
c6c7f0c26568 8010361: fix some langtools findbugs issues
jjg
parents: 16324
diff changeset
    62
    public static class Fault extends Exception {
16324
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
    63
        private static final long serialVersionUID = 0;
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
    64
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
    65
        Fault(String msg) {
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
    66
            super(msg);
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
    67
        }
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
    68
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
    69
        Fault(String msg, Exception cause) {
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
    70
            super(msg, cause);
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
    71
        }
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
    72
    }
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
    73
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
    74
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     * The factory for builders.
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
    protected BuilderFactory builderFactory;
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     * The taglet manager.
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
    public TagletManager tagletManager;
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
     * The path to the builder XML input file.
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    public String builderXMLPath;
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     * The default path to the builder XML.
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    private static final String DEFAULT_BUILDER_XML = "resources/doclet.xml";
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     * The path to Taglets
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
    public String tagletpath = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
     * This is true if option "-serialwarn" is used. Defualt value is false to
14545
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14544
diff changeset
   101
     * suppress excessive warnings about serial tag.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    public boolean serialwarn = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     * The specified amount of space between tab stops.
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     */
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
   108
    public int sourcetab;
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
   109
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
   110
    public String tabSpaces;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     * True if we should generate browsable sources.
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
    public boolean linksource = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     * True if command line option "-nosince" is used. Default value is
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     * false.
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    public boolean nosince = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
     * True if we should recursively copy the doc-file subdirectories
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
    public boolean copydocfilesubdirs = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     * The META charset tag used for cross-platform viewing.
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    public String charset = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     * True if user wants to add member names as meta keywords.
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     * Set to false because meta keywords are ignored in general
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     * by most Internet search engines.
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
    public boolean keywords = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    /**
1475
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 1264
diff changeset
   141
     * The meta tag keywords instance.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     */
1475
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 1264
diff changeset
   143
    public final MetaKeywords metakeywords = new MetaKeywords(this);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
     * The list of doc-file subdirectories to exclude
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   148
    protected Set<String> excludedDocFileDirs;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
     * The list of qualifiers to exclude
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   153
    protected Set<String> excludedQualifiers;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     * The Root of the generated Program Structure from the Doclet API.
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
    public RootDoc root;
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     * Destination directory name, in which doclet will generate the entire
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
     * documentation. Default is current directory.
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    public String destDirName = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
     * Destination directory name, in which doclet will copy the doc-files to.
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
    public String docFileDestDirName = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
     * Encoding for this document. Default is default encoding for this
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
     * platform.
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
    public String docencoding = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
     * True if user wants to suppress descriptions and tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
    public boolean nocomment = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
     * Encoding for this document. Default is default encoding for this
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
     * platform.
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
    public String encoding = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
     * Generate author specific information for all the classes if @author
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
     * tag is used in the doc comment and if -author option is used.
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
     * <code>showauthor</code> is set to true if -author option is used.
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
     * Default is don't show author information.
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
    public boolean showauthor = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
    /**
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
   197
     * Generate documentation for JavaFX getters and setters automatically
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
   198
     * by copying it from the appropriate property definition.
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
   199
     */
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
   200
    public boolean javafx = false;
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
   201
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
   202
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
     * Generate version specific information for the all the classes
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
     * if @version tag is used in the doc comment and if -version option is
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
     * used. <code>showversion</code> is set to true if -version option is
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
     * used.Default is don't show version information.
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
    public boolean showversion = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
     * Sourcepath from where to read the source files. Default is classpath.
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
    public String sourcepath = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
    /**
15723
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   217
     * Argument for command line option "-Xprofilespath".
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   218
     */
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   219
    public String profilespath = "";
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   220
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   221
    /**
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   222
     * Generate profiles documentation if profilespath is set and valid profiles
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   223
     * are present.
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   224
     */
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   225
    public boolean showProfiles = false;
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   226
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   227
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
     * Don't generate deprecated API information at all, if -nodeprecated
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
     * option is used. <code>nodepracted</code> is set to true if
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
     * -nodeprecated option is used. Default is generate deprected API
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
     * information.
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
    public boolean nodeprecated = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
     * The catalog of classes specified on the command-line
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
    public ClassDocCatalog classDocCatalog;
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
     * Message Retriever for the doclet, to retrieve message from the resource
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
     * file for this Configuration, which is common for 1.1 and standard
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
     * doclets.
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
     * TODO:  Make this private!!!
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
    public MessageRetriever message = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
     * True if user wants to suppress time stamp in output.
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
     * Default is false.
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
    public boolean notimestamp= false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
    /**
1475
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 1264
diff changeset
   256
     * The package grouping instance.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
     */
1475
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 1264
diff changeset
   258
    public final Group group = new Group(this);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
    /**
1475
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 1264
diff changeset
   261
     * The tracker of external package links.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
    public final Extern extern = new Extern(this);
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
     * Return the build date for the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
    public abstract String getDocletSpecificBuildDate();
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
     * This method should be defined in all those doclets(configurations),
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
     * which want to derive themselves from this Configuration. This method
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
     * can be used to set its own command line options.
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
     * @param options The array of option names and values.
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
     * @throws DocletAbortException
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
     */
16324
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   278
    public abstract void setSpecificDocletOptions(String[][] options) throws Fault;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
     * Return the doclet specific {@link MessageRetriever}
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
     * @return the doclet specific MessageRetriever.
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
    public abstract MessageRetriever getDocletSpecificMsg();
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
    /**
15723
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   287
     * A profiles object used to access profiles across various pages.
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   288
     */
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   289
    public Profiles profiles;
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   290
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   291
    /**
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   292
     * An map of the profiles to packages.
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   293
     */
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   294
    public Map<String,PackageDoc[]> profilePackages;
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   295
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   296
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
     * An array of the packages specified on the command-line merged
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
     * with the array of packages that contain the classes specified on the
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
     * command-line.  The array is sorted.
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
    public PackageDoc[] packages;
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
     * Constructor. Constructs the message retriever with resource file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
    public Configuration() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
        message =
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
            new MessageRetriever(this,
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
            "com.sun.tools.doclets.internal.toolkit.resources.doclets");
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   310
        excludedDocFileDirs = new HashSet<String>();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   311
        excludedQualifiers = new HashSet<String>();
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
   312
        setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
     * Return the builder factory for this doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
     * @return the builder factory for this doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
    public BuilderFactory getBuilderFactory() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
        if (builderFactory == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
            builderFactory = new BuilderFactory(this);
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
        return builderFactory;
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
     * This method should be defined in all those doclets
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
     * which want to inherit from this Configuration. This method
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
     * should return the number of arguments to the command line
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
     * option (including the option name).  For example,
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
     * -notimestamp is a single-argument option, so this method would
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
     * return 1.
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
     * @param option Command line option under consideration.
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
     * @return number of arguments to option (including the
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
     * option name). Zero return means option not known.
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
     * Negative value means error occurred.
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
    public int optionLength(String option) {
22153
f9f06fcca59d 8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents: 19937
diff changeset
   341
        option = StringUtils.toLowerCase(option);
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   342
        switch (option) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   343
            case "-author":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   344
            case "-docfilessubdirs":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   345
            case "-javafx":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   346
            case "-keywords":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   347
            case "-linksource":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   348
            case "-nocomment":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   349
            case "-nodeprecated":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   350
            case "-nosince":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   351
            case "-notimestamp":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   352
            case "-quiet":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   353
            case "-xnodate":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   354
            case "-version":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   355
                return 1;
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   356
            case "-d":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   357
            case "-docencoding":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   358
            case "-encoding":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   359
            case "-excludedocfilessubdir":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   360
            case "-link":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   361
            case "-sourcetab":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   362
            case "-noqualifier":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   363
            case "-output":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   364
            case "-sourcepath":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   365
            case "-tag":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   366
            case "-taglet":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   367
            case "-tagletpath":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   368
            case "-xprofilespath":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   369
                return 2;
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   370
            case "-group":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   371
            case "-linkoffline":
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   372
                return 3;
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   373
            default:
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   374
                return -1;  // indicate we don't know about it
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
     * Perform error checking on the given options.
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
     * @param options  the given options to check.
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
     * @param reporter the reporter used to report errors.
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
    public abstract boolean validOptions(String options[][],
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
        DocErrorReporter reporter);
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
15723
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   387
    private void initProfiles() throws IOException {
19911
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   388
        if (profilespath.isEmpty())
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   389
            return;
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   390
15723
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   391
        profiles = Profiles.read(new File(profilespath));
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   392
19911
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   393
        // Group the packages to be documented by the lowest profile (if any)
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   394
        // in which each appears
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   395
        Map<Profile, List<PackageDoc>> interimResults =
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   396
                new EnumMap<Profile, List<PackageDoc>>(Profile.class);
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   397
        for (Profile p: Profile.values())
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   398
            interimResults.put(p, new ArrayList<PackageDoc>());
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   399
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   400
        for (PackageDoc pkg: packages) {
19937
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   401
            if (nodeprecated && Util.isDeprecated(pkg)) {
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   402
                continue;
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   403
            }
19911
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   404
            // the getProfile method takes a type name, not a package name,
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   405
            // but isn't particularly fussy about the simple name -- so just use *
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   406
            int i = profiles.getProfile(pkg.name().replace(".", "/") + "/*");
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   407
            Profile p = Profile.lookup(i);
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   408
            if (p != null) {
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   409
                List<PackageDoc> pkgs = interimResults.get(p);
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   410
                pkgs.add(pkg);
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   411
            }
15723
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   412
        }
19911
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   413
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   414
        // Build the profilePackages structure used by the doclet
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   415
        profilePackages = new HashMap<String,PackageDoc[]>();
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   416
        List<PackageDoc> prev = Collections.<PackageDoc>emptyList();
19937
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   417
        int size;
19911
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   418
        for (Map.Entry<Profile,List<PackageDoc>> e: interimResults.entrySet()) {
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   419
            Profile p = e.getKey();
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   420
            List<PackageDoc> pkgs =  e.getValue();
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   421
            pkgs.addAll(prev); // each profile contains all lower profiles
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   422
            Collections.sort(pkgs);
19937
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   423
            size = pkgs.size();
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   424
            // For a profile, if there are no packages to be documented, do not add
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   425
            // it to profilePackages map.
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   426
            if (size > 0)
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   427
                profilePackages.put(p.name, pkgs.toArray(new PackageDoc[pkgs.size()]));
19911
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   428
            prev = pkgs;
15723
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   429
        }
19911
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   430
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   431
        // Generate profiles documentation if any profile contains any
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   432
        // of the packages to be documented.
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   433
        showProfiles = !prev.isEmpty();
15723
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   434
    }
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   435
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   436
    private void initPackageArray() {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   437
        Set<PackageDoc> set = new HashSet<PackageDoc>(Arrays.asList(root.specifiedPackages()));
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   438
        for (ClassDoc aClass : root.specifiedClasses()) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   439
            set.add(aClass.containingPackage());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
        }
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   441
        ArrayList<PackageDoc> results = new ArrayList<PackageDoc>(set);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   442
        Collections.sort(results);
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   443
        packages = results.toArray(new PackageDoc[] {});
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   444
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
06bc494ca11e Initial load
duke
parents:
diff changeset
   446
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
     * Set the command line options supported by this configuration.
06bc494ca11e Initial load
duke
parents:
diff changeset
   448
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
     * @param options the two dimensional array of options.
06bc494ca11e Initial load
duke
parents:
diff changeset
   450
     */
16324
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   451
    public void setOptions(String[][] options) throws Fault {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   452
        LinkedHashSet<String[]> customTagStrs = new LinkedHashSet<String[]>();
16324
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   453
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   454
        // Some options, specifically -link and -linkoffline, require that
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   455
        // the output directory has already been created: so do that first.
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   456
        for (String[] os : options) {
22153
f9f06fcca59d 8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents: 19937
diff changeset
   457
            String opt = StringUtils.toLowerCase(os[0]);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
            if (opt.equals("-d")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   459
                destDirName = addTrailingFileSep(os[1]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   460
                docFileDestDirName = destDirName;
16324
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   461
                ensureOutputDirExists();
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   462
                break;
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   463
            }
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   464
        }
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   465
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   466
        for (String[] os : options) {
22153
f9f06fcca59d 8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents: 19937
diff changeset
   467
            String opt = StringUtils.toLowerCase(os[0]);
16324
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   468
            if (opt.equals("-docfilessubdirs")) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   469
                copydocfilesubdirs = true;
13842
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 9606
diff changeset
   470
            } else if (opt.equals("-docencoding")) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   471
                docencoding = os[1];
13842
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 9606
diff changeset
   472
            } else if (opt.equals("-encoding")) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   473
                encoding = os[1];
13842
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 9606
diff changeset
   474
            } else if (opt.equals("-author")) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   475
                showauthor = true;
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
   476
            } else  if (opt.equals("-javafx")) {
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
   477
                javafx = true;
13842
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 9606
diff changeset
   478
            } else if (opt.equals("-nosince")) {
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 9606
diff changeset
   479
                nosince = true;
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 9606
diff changeset
   480
            } else if (opt.equals("-version")) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   481
                showversion = true;
13842
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 9606
diff changeset
   482
            } else if (opt.equals("-nodeprecated")) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   483
                nodeprecated = true;
13842
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 9606
diff changeset
   484
            } else if (opt.equals("-sourcepath")) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   485
                sourcepath = os[1];
18898
0eab5f5e3d1d 8009924: some langtools tools do not accept -cp as an alias for -classpath
vromero
parents: 17570
diff changeset
   486
            } else if ((opt.equals("-classpath") || opt.equals("-cp")) &&
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   487
                       sourcepath.length() == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   488
                sourcepath = os[1];
06bc494ca11e Initial load
duke
parents:
diff changeset
   489
            } else if (opt.equals("-excludedocfilessubdir")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   490
                addToSet(excludedDocFileDirs, os[1]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   491
            } else if (opt.equals("-noqualifier")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   492
                addToSet(excludedQualifiers, os[1]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   493
            } else if (opt.equals("-linksource")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   494
                linksource = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   495
            } else if (opt.equals("-sourcetab")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   496
                linksource = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   497
                try {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
   498
                    setTabWidth(Integer.parseInt(os[1]));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   499
                } catch (NumberFormatException e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   500
                    //Set to -1 so that warning will be printed
06bc494ca11e Initial load
duke
parents:
diff changeset
   501
                    //to indicate what is valid argument.
06bc494ca11e Initial load
duke
parents:
diff changeset
   502
                    sourcetab = -1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   503
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   504
                if (sourcetab <= 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   505
                    message.warning("doclet.sourcetab_warning");
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
   506
                    setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   507
                }
13842
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 9606
diff changeset
   508
            } else if (opt.equals("-notimestamp")) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   509
                notimestamp = true;
13842
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 9606
diff changeset
   510
            } else if (opt.equals("-nocomment")) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   511
                nocomment = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   512
            } else if (opt.equals("-tag") || opt.equals("-taglet")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   513
                customTagStrs.add(os);
06bc494ca11e Initial load
duke
parents:
diff changeset
   514
            } else if (opt.equals("-tagletpath")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   515
                tagletpath = os[1];
15723
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   516
            }  else if (opt.equals("-xprofilespath")) {
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   517
                profilespath = os[1];
13842
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 9606
diff changeset
   518
            } else if (opt.equals("-keywords")) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   519
                keywords = true;
13842
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 9606
diff changeset
   520
            } else if (opt.equals("-serialwarn")) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   521
                serialwarn = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   522
            } else if (opt.equals("-group")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   523
                group.checkPackageGroups(os[1], os[2]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   524
            } else if (opt.equals("-link")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   525
                String url = os[1];
14361
2814fa6977ac 8001219: Clean up use of URLs in javadoc Extern class
jjg
parents: 14263
diff changeset
   526
                extern.link(url, url, root, false);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   527
            } else if (opt.equals("-linkoffline")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   528
                String url = os[1];
06bc494ca11e Initial load
duke
parents:
diff changeset
   529
                String pkglisturl = os[2];
14361
2814fa6977ac 8001219: Clean up use of URLs in javadoc Extern class
jjg
parents: 14263
diff changeset
   530
                extern.link(url, pkglisturl, root, true);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   531
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   532
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   533
        if (sourcepath.length() == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   534
            sourcepath = System.getProperty("env.class.path") == null ? "" :
06bc494ca11e Initial load
duke
parents:
diff changeset
   535
                System.getProperty("env.class.path");
06bc494ca11e Initial load
duke
parents:
diff changeset
   536
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   537
        if (docencoding == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   538
            docencoding = encoding;
06bc494ca11e Initial load
duke
parents:
diff changeset
   539
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   540
9606
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 5520
diff changeset
   541
        classDocCatalog = new ClassDocCatalog(root.specifiedClasses(), this);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   542
        initTagletManager(customTagStrs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   543
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   544
06bc494ca11e Initial load
duke
parents:
diff changeset
   545
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   546
     * Set the command line options supported by this configuration.
06bc494ca11e Initial load
duke
parents:
diff changeset
   547
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   548
     * @throws DocletAbortException
06bc494ca11e Initial load
duke
parents:
diff changeset
   549
     */
16324
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   550
    public void setOptions() throws Fault {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   551
        initPackageArray();
06bc494ca11e Initial load
duke
parents:
diff changeset
   552
        setOptions(root.options());
19911
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   553
        try {
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   554
            initProfiles();
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   555
        } catch (Exception e) {
1cdd11ae40c8 8008367: Sub-packages missing from Profiles javadoc
jjg
parents: 19667
diff changeset
   556
            throw new DocletAbortException(e);
15723
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 14545
diff changeset
   557
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   558
        setSpecificDocletOptions(root.options());
06bc494ca11e Initial load
duke
parents:
diff changeset
   559
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   560
16324
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   561
    private void ensureOutputDirExists() throws Fault {
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   562
        DocFile destDir = DocFile.createFileForDirectory(this, destDirName);
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   563
        if (!destDir.exists()) {
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   564
            //Create the output directory (in case it doesn't exist yet)
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   565
            root.printNotice(getText("doclet.dest_dir_create", destDirName));
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   566
            destDir.mkdirs();
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   567
        } else if (!destDir.isDirectory()) {
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   568
            throw new Fault(getText(
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   569
                "doclet.destination_directory_not_directory_0",
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   570
                destDir.getPath()));
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   571
        } else if (!destDir.canWrite()) {
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   572
            throw new Fault(getText(
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   573
                "doclet.destination_directory_not_writable_0",
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   574
                destDir.getPath()));
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   575
        }
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   576
    }
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   577
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   578
06bc494ca11e Initial load
duke
parents:
diff changeset
   579
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   580
     * Initialize the taglet manager.  The strings to initialize the simple custom tags should
06bc494ca11e Initial load
duke
parents:
diff changeset
   581
     * be in the following format:  "[tag name]:[location str]:[heading]".
14545
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14544
diff changeset
   582
     * @param customTagStrs the set two dimensional arrays of strings.  These arrays contain
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   583
     * either -tag or -taglet arguments.
06bc494ca11e Initial load
duke
parents:
diff changeset
   584
     */
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1475
diff changeset
   585
    private void initTagletManager(Set<String[]> customTagStrs) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   586
        tagletManager = tagletManager == null ?
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
   587
            new TagletManager(nosince, showversion, showauthor, javafx, message) :
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   588
            tagletManager;
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   589
        for (String[] args : customTagStrs) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   590
            if (args[0].equals("-taglet")) {
14545
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14544
diff changeset
   591
                tagletManager.addCustomTag(args[1], getFileManager(), tagletpath);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   592
                continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   593
            }
14368
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   594
            String[] tokens = tokenize(args[1],
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   595
                                       TagletManager.SIMPLE_TAGLET_OPT_SEPARATOR, 3);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   596
            if (tokens.length == 1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   597
                String tagName = args[1];
06bc494ca11e Initial load
duke
parents:
diff changeset
   598
                if (tagletManager.isKnownCustomTag(tagName)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   599
                    //reorder a standard tag
06bc494ca11e Initial load
duke
parents:
diff changeset
   600
                    tagletManager.addNewSimpleCustomTag(tagName, null, "");
06bc494ca11e Initial load
duke
parents:
diff changeset
   601
                } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   602
                    //Create a simple tag with the heading that has the same name as the tag.
14263
473b1eaede64 8000310: Clean up use of StringBuffer in langtools
jjg
parents: 14260
diff changeset
   603
                    StringBuilder heading = new StringBuilder(tagName + ":");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   604
                    heading.setCharAt(0, Character.toUpperCase(tagName.charAt(0)));
06bc494ca11e Initial load
duke
parents:
diff changeset
   605
                    tagletManager.addNewSimpleCustomTag(tagName, heading.toString(), "a");
06bc494ca11e Initial load
duke
parents:
diff changeset
   606
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   607
            } else if (tokens.length == 2) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   608
                //Add simple taglet without heading, probably to excluding it in the output.
06bc494ca11e Initial load
duke
parents:
diff changeset
   609
                tagletManager.addNewSimpleCustomTag(tokens[0], tokens[1], "");
06bc494ca11e Initial load
duke
parents:
diff changeset
   610
            } else if (tokens.length >= 3) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   611
                tagletManager.addNewSimpleCustomTag(tokens[0], tokens[2], tokens[1]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   612
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   613
                message.error("doclet.Error_invalid_custom_tag_argument", args[1]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   614
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   615
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   616
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   617
14368
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   618
    /**
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   619
     * Given a string, return an array of tokens.  The separator can be escaped
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   620
     * with the '\' character.  The '\' character may also be escaped by the
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   621
     * '\' character.
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   622
     *
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   623
     * @param s         the string to tokenize.
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   624
     * @param separator the separator char.
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   625
     * @param maxTokens the maximum number of tokens returned.  If the
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   626
     *                  max is reached, the remaining part of s is appended
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   627
     *                  to the end of the last token.
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   628
     *
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   629
     * @return an array of tokens.
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   630
     */
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   631
    private String[] tokenize(String s, char separator, int maxTokens) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   632
        List<String> tokens = new ArrayList<String>();
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   633
        StringBuilder  token = new StringBuilder ();
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   634
        boolean prevIsEscapeChar = false;
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   635
        for (int i = 0; i < s.length(); i += Character.charCount(i)) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   636
            int currentChar = s.codePointAt(i);
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   637
            if (prevIsEscapeChar) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   638
                // Case 1:  escaped character
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   639
                token.appendCodePoint(currentChar);
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   640
                prevIsEscapeChar = false;
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   641
            } else if (currentChar == separator && tokens.size() < maxTokens-1) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   642
                // Case 2:  separator
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   643
                tokens.add(token.toString());
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   644
                token = new StringBuilder();
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   645
            } else if (currentChar == '\\') {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   646
                // Case 3:  escape character
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   647
                prevIsEscapeChar = true;
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   648
            } else {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   649
                // Case 4:  regular character
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   650
                token.appendCodePoint(currentChar);
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   651
            }
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   652
        }
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   653
        if (token.length() > 0) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   654
            tokens.add(token.toString());
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   655
        }
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   656
        return tokens.toArray(new String[] {});
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   657
    }
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   658
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   659
    private void addToSet(Set<String> s, String str){
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   660
        StringTokenizer st = new StringTokenizer(str, ":");
06bc494ca11e Initial load
duke
parents:
diff changeset
   661
        String current;
06bc494ca11e Initial load
duke
parents:
diff changeset
   662
        while(st.hasMoreTokens()){
06bc494ca11e Initial load
duke
parents:
diff changeset
   663
            current = st.nextToken();
06bc494ca11e Initial load
duke
parents:
diff changeset
   664
            s.add(current);
06bc494ca11e Initial load
duke
parents:
diff changeset
   665
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   666
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   667
06bc494ca11e Initial load
duke
parents:
diff changeset
   668
    /**
14061
9ac68cf0048b 4696488: javadoc doesn't handle UNC paths for destination directory
bpatel
parents: 13842
diff changeset
   669
     * Add a trailing file separator, if not found. Remove superfluous
9ac68cf0048b 4696488: javadoc doesn't handle UNC paths for destination directory
bpatel
parents: 13842
diff changeset
   670
     * file separators if any. Preserve the front double file separator for
9ac68cf0048b 4696488: javadoc doesn't handle UNC paths for destination directory
bpatel
parents: 13842
diff changeset
   671
     * UNC paths.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   672
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   673
     * @param path Path under consideration.
06bc494ca11e Initial load
duke
parents:
diff changeset
   674
     * @return String Properly constructed path string.
06bc494ca11e Initial load
duke
parents:
diff changeset
   675
     */
14061
9ac68cf0048b 4696488: javadoc doesn't handle UNC paths for destination directory
bpatel
parents: 13842
diff changeset
   676
    public static String addTrailingFileSep(String path) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   677
        String fs = System.getProperty("file.separator");
06bc494ca11e Initial load
duke
parents:
diff changeset
   678
        String dblfs = fs + fs;
06bc494ca11e Initial load
duke
parents:
diff changeset
   679
        int indexDblfs;
14061
9ac68cf0048b 4696488: javadoc doesn't handle UNC paths for destination directory
bpatel
parents: 13842
diff changeset
   680
        while ((indexDblfs = path.indexOf(dblfs, 1)) >= 0) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   681
            path = path.substring(0, indexDblfs) +
06bc494ca11e Initial load
duke
parents:
diff changeset
   682
                path.substring(indexDblfs + fs.length());
06bc494ca11e Initial load
duke
parents:
diff changeset
   683
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   684
        if (!path.endsWith(fs))
06bc494ca11e Initial load
duke
parents:
diff changeset
   685
            path += fs;
06bc494ca11e Initial load
duke
parents:
diff changeset
   686
        return path;
06bc494ca11e Initial load
duke
parents:
diff changeset
   687
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   688
06bc494ca11e Initial load
duke
parents:
diff changeset
   689
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   690
     * This checks for the validity of the options used by the user.
06bc494ca11e Initial load
duke
parents:
diff changeset
   691
     * This works exactly like
06bc494ca11e Initial load
duke
parents:
diff changeset
   692
     * {@link com.sun.javadoc.Doclet#validOptions(String[][],
06bc494ca11e Initial load
duke
parents:
diff changeset
   693
     * DocErrorReporter)}. This will validate the options which are shared
06bc494ca11e Initial load
duke
parents:
diff changeset
   694
     * by our doclets. For example, this method will flag an error using
06bc494ca11e Initial load
duke
parents:
diff changeset
   695
     * the DocErrorReporter if user has used "-nohelp" and "-helpfile" option
06bc494ca11e Initial load
duke
parents:
diff changeset
   696
     * together.
06bc494ca11e Initial load
duke
parents:
diff changeset
   697
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   698
     * @param options  options used on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
   699
     * @param reporter used to report errors.
06bc494ca11e Initial load
duke
parents:
diff changeset
   700
     * @return true if all the options are valid.
06bc494ca11e Initial load
duke
parents:
diff changeset
   701
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   702
    public boolean generalValidOptions(String options[][],
06bc494ca11e Initial load
duke
parents:
diff changeset
   703
            DocErrorReporter reporter) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   704
        boolean docencodingfound = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   705
        String encoding = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   706
        for (int oi = 0; oi < options.length; oi++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   707
            String[] os = options[oi];
22153
f9f06fcca59d 8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents: 19937
diff changeset
   708
            String opt = StringUtils.toLowerCase(os[0]);
16324
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 16319
diff changeset
   709
            if (opt.equals("-docencoding")) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   710
                docencodingfound = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   711
                if (!checkOutputFileEncoding(os[1], reporter)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   712
                    return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   713
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   714
            } else if (opt.equals("-encoding")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   715
                encoding = os[1];
06bc494ca11e Initial load
duke
parents:
diff changeset
   716
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   717
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   718
        if (!docencodingfound && encoding.length() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   719
            if (!checkOutputFileEncoding(encoding, reporter)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   720
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   721
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   722
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   723
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   724
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   725
06bc494ca11e Initial load
duke
parents:
diff changeset
   726
    /**
19937
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   727
     * Check the validity of the given profile. Return false if there are no
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   728
     * valid packages to be documented for the profile.
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   729
     *
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   730
     * @param profileName the profile that needs to be validated.
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   731
     * @return true if the profile has valid packages to be documented.
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   732
     */
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   733
    public boolean shouldDocumentProfile(String profileName) {
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   734
        return profilePackages.containsKey(profileName);
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   735
    }
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   736
7dacecdfbad4 8015496: Information that package is deprecated is missing in profiles view
bpatel
parents: 19911
diff changeset
   737
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   738
     * Check the validity of the given Source or Output File encoding on this
06bc494ca11e Initial load
duke
parents:
diff changeset
   739
     * platform.
06bc494ca11e Initial load
duke
parents:
diff changeset
   740
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   741
     * @param docencoding output file encoding.
06bc494ca11e Initial load
duke
parents:
diff changeset
   742
     * @param reporter    used to report errors.
06bc494ca11e Initial load
duke
parents:
diff changeset
   743
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   744
    private boolean checkOutputFileEncoding(String docencoding,
06bc494ca11e Initial load
duke
parents:
diff changeset
   745
            DocErrorReporter reporter) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   746
        OutputStream ost= new ByteArrayOutputStream();
06bc494ca11e Initial load
duke
parents:
diff changeset
   747
        OutputStreamWriter osw = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   748
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   749
            osw = new OutputStreamWriter(ost, docencoding);
06bc494ca11e Initial load
duke
parents:
diff changeset
   750
        } catch (UnsupportedEncodingException exc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   751
            reporter.printError(getText("doclet.Encoding_not_supported",
06bc494ca11e Initial load
duke
parents:
diff changeset
   752
                docencoding));
06bc494ca11e Initial load
duke
parents:
diff changeset
   753
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   754
        } finally {
06bc494ca11e Initial load
duke
parents:
diff changeset
   755
            try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   756
                if (osw != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   757
                    osw.close();
06bc494ca11e Initial load
duke
parents:
diff changeset
   758
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   759
            } catch (IOException exc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   760
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   761
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   762
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   763
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   764
06bc494ca11e Initial load
duke
parents:
diff changeset
   765
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   766
     * Return true if the given doc-file subdirectory should be excluded and
06bc494ca11e Initial load
duke
parents:
diff changeset
   767
     * false otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
   768
     * @param docfilesubdir the doc-files subdirectory to check.
06bc494ca11e Initial load
duke
parents:
diff changeset
   769
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   770
    public boolean shouldExcludeDocFileDir(String docfilesubdir){
06bc494ca11e Initial load
duke
parents:
diff changeset
   771
        if (excludedDocFileDirs.contains(docfilesubdir)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   772
            return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   773
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   774
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   775
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   776
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   777
06bc494ca11e Initial load
duke
parents:
diff changeset
   778
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   779
     * Return true if the given qualifier should be excluded and false otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
   780
     * @param qualifier the qualifier to check.
06bc494ca11e Initial load
duke
parents:
diff changeset
   781
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   782
    public boolean shouldExcludeQualifier(String qualifier){
06bc494ca11e Initial load
duke
parents:
diff changeset
   783
        if (excludedQualifiers.contains("all") ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   784
            excludedQualifiers.contains(qualifier) ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   785
            excludedQualifiers.contains(qualifier + ".*")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   786
            return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   787
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   788
            int index = -1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   789
            while ((index = qualifier.indexOf(".", index + 1)) != -1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   790
                if (excludedQualifiers.contains(qualifier.substring(0, index + 1) + "*")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   791
                    return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   792
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   793
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   794
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   795
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   796
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   797
06bc494ca11e Initial load
duke
parents:
diff changeset
   798
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   799
     * Return the qualified name of the <code>ClassDoc</code> if it's qualifier is not excluded.  Otherwise,
06bc494ca11e Initial load
duke
parents:
diff changeset
   800
     * return the unqualified <code>ClassDoc</code> name.
06bc494ca11e Initial load
duke
parents:
diff changeset
   801
     * @param cd the <code>ClassDoc</code> to check.
06bc494ca11e Initial load
duke
parents:
diff changeset
   802
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   803
    public String getClassName(ClassDoc cd) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   804
        PackageDoc pd = cd.containingPackage();
06bc494ca11e Initial load
duke
parents:
diff changeset
   805
        if (pd != null && shouldExcludeQualifier(cd.containingPackage().name())) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   806
            return cd.name();
06bc494ca11e Initial load
duke
parents:
diff changeset
   807
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   808
            return cd.qualifiedName();
06bc494ca11e Initial load
duke
parents:
diff changeset
   809
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   810
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   811
06bc494ca11e Initial load
duke
parents:
diff changeset
   812
    public String getText(String key) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   813
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   814
            //Check the doclet specific properties file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   815
            return getDocletSpecificMsg().getText(key);
06bc494ca11e Initial load
duke
parents:
diff changeset
   816
        } catch (Exception e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   817
            //Check the shared properties file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   818
            return message.getText(key);
06bc494ca11e Initial load
duke
parents:
diff changeset
   819
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   820
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   821
06bc494ca11e Initial load
duke
parents:
diff changeset
   822
    public String getText(String key, String a1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   823
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   824
            //Check the doclet specific properties file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   825
            return getDocletSpecificMsg().getText(key, a1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   826
        } catch (Exception e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   827
            //Check the shared properties file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   828
            return message.getText(key, a1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   829
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   830
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   831
06bc494ca11e Initial load
duke
parents:
diff changeset
   832
    public String getText(String key, String a1, String a2) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   833
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   834
            //Check the doclet specific properties file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   835
            return getDocletSpecificMsg().getText(key, a1, a2);
06bc494ca11e Initial load
duke
parents:
diff changeset
   836
        } catch (Exception e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   837
            //Check the shared properties file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   838
            return message.getText(key, a1, a2);
06bc494ca11e Initial load
duke
parents:
diff changeset
   839
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   840
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   841
06bc494ca11e Initial load
duke
parents:
diff changeset
   842
    public String getText(String key, String a1, String a2, String a3) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   843
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   844
            //Check the doclet specific properties file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   845
            return getDocletSpecificMsg().getText(key, a1, a2, a3);
06bc494ca11e Initial load
duke
parents:
diff changeset
   846
        } catch (Exception e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   847
            //Check the shared properties file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   848
            return message.getText(key, a1, a2, a3);
06bc494ca11e Initial load
duke
parents:
diff changeset
   849
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   850
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   851
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17563
diff changeset
   852
    public abstract Content newContent();
17563
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   853
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   854
    /**
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   855
     * Get the configuration string as a content.
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   856
     *
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   857
     * @param key the key to look for in the configuration file
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   858
     * @return a content tree for the text
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   859
     */
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   860
    public Content getResource(String key) {
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17563
diff changeset
   861
        Content c = newContent();
17563
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   862
        c.addContent(getText(key));
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   863
        return c;
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   864
    }
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   865
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   866
    /**
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   867
     * Get the configuration string as a content.
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   868
     *
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   869
     * @param key the key to look for in the configuration file
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   870
     * @param o   string or content argument added to configuration text
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   871
     * @return a content tree for the text
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   872
     */
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   873
    public Content getResource(String key, Object o) {
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   874
        return getResource(key, o, null, null);
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   875
    }
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   876
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   877
    /**
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   878
     * Get the configuration string as a content.
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   879
     *
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   880
     * @param key the key to look for in the configuration file
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   881
     * @param o   string or content argument added to configuration text
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   882
     * @return a content tree for the text
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   883
     */
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   884
    public Content getResource(String key, Object o1, Object o2) {
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   885
        return getResource(key, o1, o2, null);
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   886
    }
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   887
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   888
    /**
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   889
     * Get the configuration string as a content.
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   890
     *
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   891
     * @param key the key to look for in the configuration file
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   892
     * @param o1  string or content argument added to configuration text
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   893
     * @param o2  string or content argument added to configuration text
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   894
     * @return a content tree for the text
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   895
     */
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   896
    public Content getResource(String key, Object o0, Object o1, Object o2) {
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17563
diff changeset
   897
        Content c = newContent();
17563
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   898
        Pattern p = Pattern.compile("\\{([012])\\}");
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   899
        String text = getText(key);
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   900
        Matcher m = p.matcher(text);
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   901
        int start = 0;
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   902
        while (m.find(start)) {
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   903
            c.addContent(text.substring(start, m.start()));
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   904
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   905
            Object o = null;
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   906
            switch (m.group(1).charAt(0)) {
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   907
                case '0': o = o0; break;
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   908
                case '1': o = o1; break;
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   909
                case '2': o = o2; break;
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   910
            }
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   911
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   912
            if (o == null) {
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   913
                c.addContent("{" + m.group(1) + "}");
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   914
            } else if (o instanceof String) {
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   915
                c.addContent((String) o);
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   916
            } else if (o instanceof Content) {
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   917
                c.addContent((Content) o);
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   918
            }
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   919
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   920
            start = m.end();
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   921
        }
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   922
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   923
        c.addContent(text.substring(start));
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   924
        return c;
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   925
    }
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   926
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 16560
diff changeset
   927
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   928
    /**
9606
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 5520
diff changeset
   929
     * Return true if the ClassDoc element is getting documented, depending upon
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 5520
diff changeset
   930
     * -nodeprecated option and the deprecation information. Return true if
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 5520
diff changeset
   931
     * -nodeprecated is not used. Return false if -nodeprecated is used and if
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 5520
diff changeset
   932
     * either ClassDoc element is deprecated or the containing package is deprecated.
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 5520
diff changeset
   933
     *
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 5520
diff changeset
   934
     * @param cd the ClassDoc for which the page generation is checked
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   935
     */
9606
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 5520
diff changeset
   936
    public boolean isGeneratedDoc(ClassDoc cd) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   937
        if (!nodeprecated) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   938
            return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   939
        }
9606
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 5520
diff changeset
   940
        return !(Util.isDeprecated(cd) || Util.isDeprecated(cd.containingPackage()));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   941
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   942
06bc494ca11e Initial load
duke
parents:
diff changeset
   943
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   944
     * Return the doclet specific instance of a writer factory.
06bc494ca11e Initial load
duke
parents:
diff changeset
   945
     * @return the {@link WriterFactory} for the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   946
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   947
    public abstract WriterFactory getWriterFactory();
06bc494ca11e Initial load
duke
parents:
diff changeset
   948
06bc494ca11e Initial load
duke
parents:
diff changeset
   949
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   950
     * Return the input stream to the builder XML.
06bc494ca11e Initial load
duke
parents:
diff changeset
   951
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   952
     * @return the input steam to the builder XML.
06bc494ca11e Initial load
duke
parents:
diff changeset
   953
     * @throws FileNotFoundException when the given XML file cannot be found.
06bc494ca11e Initial load
duke
parents:
diff changeset
   954
     */
14544
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14542
diff changeset
   955
    public InputStream getBuilderXML() throws IOException {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   956
        return builderXMLPath == null ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   957
            Configuration.class.getResourceAsStream(DEFAULT_BUILDER_XML) :
14368
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14361
diff changeset
   958
            DocFile.createFileForInput(this, builderXMLPath).openInputStream();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   959
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   960
06bc494ca11e Initial load
duke
parents:
diff changeset
   961
    /**
1863
e5de9abc0eb1 6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents: 1789
diff changeset
   962
     * Return the Locale for this document.
e5de9abc0eb1 6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents: 1789
diff changeset
   963
     */
e5de9abc0eb1 6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents: 1789
diff changeset
   964
    public abstract Locale getLocale();
e5de9abc0eb1 6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents: 1789
diff changeset
   965
e5de9abc0eb1 6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents: 1789
diff changeset
   966
    /**
14544
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14542
diff changeset
   967
     * Return the current file manager.
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14542
diff changeset
   968
     */
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14542
diff changeset
   969
    public abstract JavaFileManager getFileManager();
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14542
diff changeset
   970
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14542
diff changeset
   971
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   972
     * Return the comparator that will be used to sort member documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   973
     * To no do any sorting, return null.
06bc494ca11e Initial load
duke
parents:
diff changeset
   974
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   975
     * @return the {@link java.util.Comparator} used to sort members.
06bc494ca11e Initial load
duke
parents:
diff changeset
   976
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   977
    public abstract Comparator<ProgramElementDoc> getMemberComparator();
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
   978
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
   979
    private void setTabWidth(int n) {
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
   980
        sourcetab = n;
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
   981
        tabSpaces = String.format("%" + n + "s", "");
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
   982
    }
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14545
diff changeset
   983
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14545
diff changeset
   984
    public abstract boolean showMessage(SourcePosition pos, String key);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   985
}