langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
author bpatel
Thu, 08 Jan 2009 16:26:59 -0800
changeset 1787 1aa079321cd2
parent 1264 076a3cde30d5
child 1789 7ac8c0815000
permissions -rw-r--r--
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
1264
076a3cde30d5 6754988: Update copyright year
xdono
parents: 868
diff changeset
     2
 * Copyright 1998-2008 Sun Microsystems, Inc.  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
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
 * have any questions.
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.doclets.formats.html;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
import com.sun.tools.doclets.formats.html.markup.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.tools.doclets.internal.toolkit.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import com.sun.tools.doclets.internal.toolkit.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import com.sun.tools.doclets.internal.toolkit.taglets.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import com.sun.javadoc.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
import java.io.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
import java.text.SimpleDateFormat;
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
import java.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * Class for the Html Format Code Generation specific to JavaDoc.
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * This Class contains methods related to the Html Code Generation which
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * are used extensively while generating the entire documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * @since 1.2
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * @author Robert Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
public class HtmlDocletWriter extends HtmlDocWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     * Relative path from the file getting generated to the destination
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     * directory. For example, if the file getting generated is
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
     * "java/lang/Object.html", then the relative path string is "../../".
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     * This string can be empty if the file getting generated is in
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     * the destination directory.
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    public String relativePath = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
     * Same as relativepath, but normalized to never be empty or
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     * end with a slash.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    public String relativepathNoSlash = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     * Platform-dependent directory path from the current or the
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     * destination directory to the file getting generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     * Used when creating the file.
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
     * For example, if the file getting generated is
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     * "java/lang/Object.html", then the path string is "java/lang".
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    public String path = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     * Name of the file getting generated. If the file getting generated is
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     * "java/lang/Object.html", then the filename is "Object.html".
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    public String filename = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
     * The display length used for indentation while generating the class page.
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    public int displayLength = 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     * The global configuration information for this run.
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    public ConfigurationImpl configuration;
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     * Constructor to construct the HtmlStandardWriter object.
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     * @param filename File to be generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
    public HtmlDocletWriter(ConfigurationImpl configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
                              String filename) throws IOException {
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
        super(configuration, filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
        this.configuration = configuration;
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
        this.filename = filename;
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     * Constructor to construct the HtmlStandardWriter object.
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     * @param path         Platform-dependent {@link #path} used when
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     *                     creating file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     * @param filename     Name of file to be generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     * @param relativePath Value for the variable {@link #relativePath}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
    public HtmlDocletWriter(ConfigurationImpl configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
                              String path, String filename,
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
                              String relativePath) throws IOException {
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
        super(configuration, path, filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        this.configuration = configuration;
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
        this.path = path;
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
        this.relativePath = relativePath;
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
        this.relativepathNoSlash =
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
            DirectoryManager.getPathNoTrailingSlash(this.relativePath);
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
        this.filename = filename;
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     * Replace {@docRoot} tag used in options that accept HTML text, such
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
     * as -header, -footer, -top and -bottom, and when converting a relative
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
     * HREF where commentTagsToString inserts a {@docRoot} where one was
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
     * missing.  (Also see DocRootTaglet for {@docRoot} tags in doc
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
     * comments.)
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     * Replace {&#064;docRoot} tag in htmlstr with the relative path to the
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     * destination directory from the directory where the file is being
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
     * written, looping to handle all such tags in htmlstr.
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     * For example, for "-d docs" and -header containing {&#064;docRoot}, when
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     * the HTML page for source file p/C1.java is being generated, the
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     * {&#064;docRoot} tag would be inserted into the header as "../",
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     * the relative path from docs/p/ to docs/ (the document root).
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     * Note: This doc comment was written with '&amp;#064;' representing '@'
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     * to prevent the inline tag from being interpreted.
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
    public String replaceDocRootDir(String htmlstr) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
        // Return if no inline tags exist
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        int index = htmlstr.indexOf("{@");
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
        if (index < 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
            return htmlstr;
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
        String lowerHtml = htmlstr.toLowerCase();
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
        // Return index of first occurrence of {@docroot}
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
        // Note: {@docRoot} is not case sensitive when passed in w/command line option
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        index = lowerHtml.indexOf("{@docroot}", index);
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
        if (index < 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
            return htmlstr;
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        StringBuffer buf = new StringBuffer();
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
        int previndex = 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        while (true) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
            // Search for lowercase version of {@docRoot}
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
            index = lowerHtml.indexOf("{@docroot}", previndex);
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
            // If next {@docRoot} tag not found, append rest of htmlstr and exit loop
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
            if (index < 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
                buf.append(htmlstr.substring(previndex));
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
                break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
            // If next {@docroot} tag found, append htmlstr up to start of tag
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
            buf.append(htmlstr.substring(previndex, index));
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
            previndex = index + 10;  // length for {@docroot} string
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
            // Insert relative path where {@docRoot} was located
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
            buf.append(relativepathNoSlash);
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
            // Append slash if next character is not a slash
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
            if (relativepathNoSlash.length() > 0 && previndex < htmlstr.length()
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
                    && htmlstr.charAt(previndex) != '/') {
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
                buf.append(DirectoryManager.URL_FILE_SEPERATOR);
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
        return buf.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
     * Print Html Hyper Link, with target frame.  This
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
     * link will only appear if page is not in a frame.
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
     * @param link String name of the file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
     * @param where Position in the file
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
     * @param target Name of the target frame.
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
     * @param label Tag for the link.
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   186
     * @param strong Whether the label should be strong or not?
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
    public void printNoFramesTargetHyperLink(String link, String where,
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
                                               String target, String label,
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   190
                                               boolean strong) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
        script();
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
        println("  <!--");
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
        println("  if(window==top) {");
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
        println("    document.writeln('"
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   195
            + getHyperLink(link, where, label, strong, "", "", target) + "');");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
        println("  }");
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
        println("  //-->");
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
        scriptEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
        noScript();
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   200
        println("  " + getHyperLink(link, where, label, strong, "", "", target));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
        noScriptEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        println(DocletConstants.NL);
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
    private void printMethodInfo(MethodDoc method) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
        ClassDoc[] intfacs = method.containingClass().interfaces();
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
        MethodDoc overriddenMethod = method.overriddenMethod();
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
        if (intfacs.length > 0 || overriddenMethod != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
            dd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
            printTagsInfoHeader();
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
            MethodWriterImpl.printImplementsInfo(this, method);
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
            if (overriddenMethod != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
                MethodWriterImpl.printOverridden(this,
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
                    method.overriddenType(), overriddenMethod);
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
            printTagsInfoFooter();
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
            ddEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        dd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
    protected void printTags(Doc doc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
        if(configuration.nocomment){
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
        if (doc instanceof MethodDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
            printMethodInfo((MethodDoc) doc);
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
        TagletOutputImpl output = new TagletOutputImpl("");
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
        TagletWriter.genTagOuput(configuration.tagletManager, doc,
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
            configuration.tagletManager.getCustomTags(doc),
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
                getTagletWriterInstance(false), output);
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
        if (output.toString().trim().length() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
            printTagsInfoHeader();
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
            print(output.toString());
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
            printTagsInfoFooter();
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
        } else if (! (doc instanceof ConstructorDoc ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
            doc instanceof RootDoc || doc instanceof ClassDoc)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
            //To be consistent with 1.4.2 output.
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
            //I hate to do this but we have to pass the diff test to prove
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
            //nothing has broken.
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
            printTagsInfoHeader();
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
            printTagsInfoFooter();
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
     * Returns a TagletWriter that knows how to write HTML.
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
     * @return a TagletWriter that knows how to write HTML.
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
    public TagletWriter getTagletWriterInstance(boolean isFirstSentence) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
        return new TagletWriterImpl(this, isFirstSentence);
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
    protected void printTagsInfoHeader() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
        dl();
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
    protected void printTagsInfoFooter() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
        dlEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
     * Print Package link, with target frame.
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
     * @param pd The link will be to the "package-summary.html" page for this
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
     * package.
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
     * @param target Name of the target frame.
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
     * @param label Tag for the link.
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
    public void printTargetPackageLink(PackageDoc pd, String target,
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
        String label) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
        print(getHyperLink(pathString(pd, "package-summary.html"), "", label,
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
            false, "", "", target));
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
     * Print the html file header. Also print Html page title and stylesheet
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
     * default properties.
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
     * @param title         String window title to go in the &lt;TITLE&gt; tag
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
     * @param metakeywords  Array of String keywords for META tag.  Each element
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
     *                      of the array is assigned to a separate META tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
     *                      Pass in null for no array.
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
     * @param includeScript boolean true if printing windowtitle script.
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
     *             False for files that appear in the left-hand frames.
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
    public void printHtmlHeader(String title, String[] metakeywords,
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
            boolean includeScript) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
        println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 " +
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
                    "Transitional//EN\" " +
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
                    "\"http://www.w3.org/TR/html4/loose.dtd\">");
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
        println("<!--NewPage-->");
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
        html();
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
        head();
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
        if (! configuration.notimestamp) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
            print("<!-- Generated by javadoc (build " + ConfigurationImpl.BUILD_DATE + ") on ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
            print(today());
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
            println(" -->");
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
        if (configuration.charset.length() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
            println("<META http-equiv=\"Content-Type\" content=\"text/html; "
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
                        + "charset=" + configuration.charset + "\">");
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
        if ( configuration.windowtitle.length() > 0 ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
            title += " (" + configuration.windowtitle  + ")";
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
        title(title);
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
        println(title);
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
        titleEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
        println("");
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
        if (! configuration.notimestamp) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
                println("<META NAME=\"date\" "
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
                                    + "CONTENT=\"" + dateFormat.format(new Date()) + "\">");
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
        if ( metakeywords != null ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
            for ( int i=0; i < metakeywords.length; i++ ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
                println("<META NAME=\"keywords\" "
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
                            + "CONTENT=\"" + metakeywords[i] + "\">");
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
        println("");
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
        printStyleSheetProperties();
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
        println("");
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
        // Don't print windowtitle script for overview-frame, allclasses-frame
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
        // and package-frame
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
        if (includeScript) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
            printWinTitleScript(title);
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
        println("");
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
        headEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
        println("");
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
        body("white", includeScript);
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
     * Print user specified header and the footer.
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
     * @param header if true print the user provided header else print the
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
     * user provided footer.
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
    public void printUserHeaderFooter(boolean header) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
        em();
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
        if (header) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
            print(replaceDocRootDir(configuration.header));
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
            if (configuration.footer.length() != 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
                print(replaceDocRootDir(configuration.footer));
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
                print(replaceDocRootDir(configuration.header));
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
        emEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
     * Print the user specified top.
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
    public void printTop() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
        print(replaceDocRootDir(configuration.top));
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
        hr();
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
     * Print the user specified bottom.
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
    public void printBottom() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
        hr();
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
        print(replaceDocRootDir(configuration.bottom));
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
     * Print the navigation bar for the Html page at the top and and the bottom.
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
     * @param header If true print navigation bar at the top of the page else
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
     * print the nevigation bar at the bottom.
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
    protected void navLinks(boolean header) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
        println("");
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
        if (!configuration.nonavbar) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
            if (header) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
                println(DocletConstants.NL + "<!-- ========= START OF TOP NAVBAR ======= -->");
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
                anchor("navbar_top");
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
                println();
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
                print(getHyperLink("", "skip-navbar_top", "", false, "",
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
                    configuration.getText("doclet.Skip_navigation_links"), ""));
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
                println(DocletConstants.NL + "<!-- ======= START OF BOTTOM NAVBAR ====== -->");
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
                anchor("navbar_bottom");
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
                println();
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
                print(getHyperLink("", "skip-navbar_bottom", "", false, "",
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
                    configuration.getText("doclet.Skip_navigation_links"), ""));
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
            table(0, "100%", 1, 0);
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
            tr();
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
            tdColspanBgcolorStyle(2, "#EEEEFF", "NavBarCell1");
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
            println("");
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
            if (header) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
                anchor("navbar_top_firstrow");
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
                anchor("navbar_bottom_firstrow");
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
            table(0, 0, 3);
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
            print("  ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
            trAlignVAlign("center", "top");
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
            if (configuration.createoverview) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
                navLinkContents();
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
            if (configuration.packages.length == 1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
                navLinkPackage(configuration.packages[0]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   415
            } else if (configuration.packages.length > 1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   416
                navLinkPackage();
06bc494ca11e Initial load
duke
parents:
diff changeset
   417
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   418
06bc494ca11e Initial load
duke
parents:
diff changeset
   419
            navLinkClass();
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
            if(configuration.classuse) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
                navLinkClassUse();
06bc494ca11e Initial load
duke
parents:
diff changeset
   423
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   424
            if(configuration.createtree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   425
                navLinkTree();
06bc494ca11e Initial load
duke
parents:
diff changeset
   426
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   427
            if(!(configuration.nodeprecated ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   428
                     configuration.nodeprecatedlist)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   429
                navLinkDeprecated();
06bc494ca11e Initial load
duke
parents:
diff changeset
   430
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   431
            if(configuration.createindex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   432
                navLinkIndex();
06bc494ca11e Initial load
duke
parents:
diff changeset
   433
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   434
            if (!configuration.nohelp) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   435
                navLinkHelp();
06bc494ca11e Initial load
duke
parents:
diff changeset
   436
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   437
            print("  ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   438
            trEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   439
            tableEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
            tdEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   441
06bc494ca11e Initial load
duke
parents:
diff changeset
   442
            tdAlignVAlignRowspan("right", "top", 3);
06bc494ca11e Initial load
duke
parents:
diff changeset
   443
06bc494ca11e Initial load
duke
parents:
diff changeset
   444
            printUserHeaderFooter(header);
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
            tdEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   446
            trEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
            println("");
06bc494ca11e Initial load
duke
parents:
diff changeset
   448
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
            tr();
06bc494ca11e Initial load
duke
parents:
diff changeset
   450
            tdBgcolorStyle("white", "NavBarCell2");
06bc494ca11e Initial load
duke
parents:
diff changeset
   451
            font("-2");
06bc494ca11e Initial load
duke
parents:
diff changeset
   452
            space();
06bc494ca11e Initial load
duke
parents:
diff changeset
   453
            navLinkPrevious();
06bc494ca11e Initial load
duke
parents:
diff changeset
   454
            space();
06bc494ca11e Initial load
duke
parents:
diff changeset
   455
            println("");
06bc494ca11e Initial load
duke
parents:
diff changeset
   456
            space();
06bc494ca11e Initial load
duke
parents:
diff changeset
   457
            navLinkNext();
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
            fontEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   459
            tdEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   460
06bc494ca11e Initial load
duke
parents:
diff changeset
   461
            tdBgcolorStyle("white", "NavBarCell2");
06bc494ca11e Initial load
duke
parents:
diff changeset
   462
            font("-2");
06bc494ca11e Initial load
duke
parents:
diff changeset
   463
            print("  ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   464
            navShowLists();
06bc494ca11e Initial load
duke
parents:
diff changeset
   465
            print("  ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   466
            space();
06bc494ca11e Initial load
duke
parents:
diff changeset
   467
            println("");
06bc494ca11e Initial load
duke
parents:
diff changeset
   468
            space();
06bc494ca11e Initial load
duke
parents:
diff changeset
   469
            navHideLists(filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
   470
            print("  ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   471
            space();
06bc494ca11e Initial load
duke
parents:
diff changeset
   472
            println("");
06bc494ca11e Initial load
duke
parents:
diff changeset
   473
            space();
06bc494ca11e Initial load
duke
parents:
diff changeset
   474
            navLinkClassIndex();
06bc494ca11e Initial load
duke
parents:
diff changeset
   475
            fontEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   476
            tdEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   477
06bc494ca11e Initial load
duke
parents:
diff changeset
   478
            trEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   479
06bc494ca11e Initial load
duke
parents:
diff changeset
   480
            printSummaryDetailLinks();
06bc494ca11e Initial load
duke
parents:
diff changeset
   481
06bc494ca11e Initial load
duke
parents:
diff changeset
   482
            tableEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   483
            if (header) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   484
                aName("skip-navbar_top");
06bc494ca11e Initial load
duke
parents:
diff changeset
   485
                aEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   486
                println(DocletConstants.NL + "<!-- ========= END OF TOP NAVBAR ========= -->");
06bc494ca11e Initial load
duke
parents:
diff changeset
   487
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   488
                aName("skip-navbar_bottom");
06bc494ca11e Initial load
duke
parents:
diff changeset
   489
                aEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   490
                println(DocletConstants.NL + "<!-- ======== END OF BOTTOM NAVBAR ======= -->");
06bc494ca11e Initial load
duke
parents:
diff changeset
   491
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   492
            println("");
06bc494ca11e Initial load
duke
parents:
diff changeset
   493
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   494
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   495
06bc494ca11e Initial load
duke
parents:
diff changeset
   496
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   497
     * Print the word "NEXT" to indicate that no link is available.  Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   498
     * this method to customize next link.
06bc494ca11e Initial load
duke
parents:
diff changeset
   499
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   500
    protected void navLinkNext() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   501
        navLinkNext(null);
06bc494ca11e Initial load
duke
parents:
diff changeset
   502
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   503
06bc494ca11e Initial load
duke
parents:
diff changeset
   504
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   505
     * Print the word "PREV" to indicate that no link is available.  Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   506
     * this method to customize prev link.
06bc494ca11e Initial load
duke
parents:
diff changeset
   507
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   508
    protected void navLinkPrevious() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   509
        navLinkPrevious(null);
06bc494ca11e Initial load
duke
parents:
diff changeset
   510
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   511
06bc494ca11e Initial load
duke
parents:
diff changeset
   512
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   513
     * Do nothing. This is the default method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   514
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   515
    protected void printSummaryDetailLinks() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   516
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   517
06bc494ca11e Initial load
duke
parents:
diff changeset
   518
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   519
     * Print link to the "overview-summary.html" page.
06bc494ca11e Initial load
duke
parents:
diff changeset
   520
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   521
    protected void navLinkContents() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   522
        navCellStart();
06bc494ca11e Initial load
duke
parents:
diff changeset
   523
        printHyperLink(relativePath + "overview-summary.html", "",
06bc494ca11e Initial load
duke
parents:
diff changeset
   524
                       configuration.getText("doclet.Overview"), true, "NavBarFont1");
06bc494ca11e Initial load
duke
parents:
diff changeset
   525
        navCellEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   526
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   527
06bc494ca11e Initial load
duke
parents:
diff changeset
   528
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   529
     * Description for a cell in the navigation bar.
06bc494ca11e Initial load
duke
parents:
diff changeset
   530
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   531
    protected void navCellStart() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   532
        print("  ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   533
        tdBgcolorStyle("#EEEEFF", "NavBarCell1");
06bc494ca11e Initial load
duke
parents:
diff changeset
   534
        print("    ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   535
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   536
06bc494ca11e Initial load
duke
parents:
diff changeset
   537
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   538
     * Description for a cell in the navigation bar, but with reverse
06bc494ca11e Initial load
duke
parents:
diff changeset
   539
     * high-light effect.
06bc494ca11e Initial load
duke
parents:
diff changeset
   540
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   541
    protected void navCellRevStart() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   542
        print("  ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   543
        tdBgcolorStyle("#FFFFFF", "NavBarCell1Rev");
06bc494ca11e Initial load
duke
parents:
diff changeset
   544
        print(" ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   545
        space();
06bc494ca11e Initial load
duke
parents:
diff changeset
   546
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   547
06bc494ca11e Initial load
duke
parents:
diff changeset
   548
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   549
     * Closing tag for navigation bar cell.
06bc494ca11e Initial load
duke
parents:
diff changeset
   550
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   551
    protected void navCellEnd() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   552
        space();
06bc494ca11e Initial load
duke
parents:
diff changeset
   553
        tdEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   554
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   555
06bc494ca11e Initial load
duke
parents:
diff changeset
   556
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   557
     * Print link to the "package-summary.html" page for the package passed.
06bc494ca11e Initial load
duke
parents:
diff changeset
   558
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   559
     * @param pkg Package to which link will be generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
   560
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   561
    protected void navLinkPackage(PackageDoc pkg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   562
        navCellStart();
06bc494ca11e Initial load
duke
parents:
diff changeset
   563
        printPackageLink(pkg, configuration.getText("doclet.Package"), true,
06bc494ca11e Initial load
duke
parents:
diff changeset
   564
            "NavBarFont1");
06bc494ca11e Initial load
duke
parents:
diff changeset
   565
        navCellEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   566
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   567
06bc494ca11e Initial load
duke
parents:
diff changeset
   568
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   569
     * Print the word "Package" in the navigation bar cell, to indicate that
06bc494ca11e Initial load
duke
parents:
diff changeset
   570
     * link is not available here.
06bc494ca11e Initial load
duke
parents:
diff changeset
   571
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   572
    protected void navLinkPackage() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   573
        navCellStart();
06bc494ca11e Initial load
duke
parents:
diff changeset
   574
        fontStyle("NavBarFont1");
06bc494ca11e Initial load
duke
parents:
diff changeset
   575
        printText("doclet.Package");
06bc494ca11e Initial load
duke
parents:
diff changeset
   576
        fontEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   577
        navCellEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   578
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   579
06bc494ca11e Initial load
duke
parents:
diff changeset
   580
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   581
     * Print the word "Use" in the navigation bar cell, to indicate that link
06bc494ca11e Initial load
duke
parents:
diff changeset
   582
     * is not available.
06bc494ca11e Initial load
duke
parents:
diff changeset
   583
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   584
    protected void navLinkClassUse() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   585
        navCellStart();
06bc494ca11e Initial load
duke
parents:
diff changeset
   586
        fontStyle("NavBarFont1");
06bc494ca11e Initial load
duke
parents:
diff changeset
   587
        printText("doclet.navClassUse");
06bc494ca11e Initial load
duke
parents:
diff changeset
   588
        fontEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   589
        navCellEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   590
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   591
06bc494ca11e Initial load
duke
parents:
diff changeset
   592
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   593
     * Print link for previous file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   594
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   595
     * @param prev File name for the prev link.
06bc494ca11e Initial load
duke
parents:
diff changeset
   596
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   597
    public void navLinkPrevious(String prev) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   598
        String tag = configuration.getText("doclet.Prev");
06bc494ca11e Initial load
duke
parents:
diff changeset
   599
        if (prev != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   600
            printHyperLink(prev, "", tag, true) ;
06bc494ca11e Initial load
duke
parents:
diff changeset
   601
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   602
            print(tag);
06bc494ca11e Initial load
duke
parents:
diff changeset
   603
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   604
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   605
06bc494ca11e Initial load
duke
parents:
diff changeset
   606
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   607
     * Print link for next file.  If next is null, just print the label
06bc494ca11e Initial load
duke
parents:
diff changeset
   608
     * without linking it anywhere.
06bc494ca11e Initial load
duke
parents:
diff changeset
   609
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   610
     * @param next File name for the next link.
06bc494ca11e Initial load
duke
parents:
diff changeset
   611
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   612
    public void navLinkNext(String next) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   613
        String tag = configuration.getText("doclet.Next");
06bc494ca11e Initial load
duke
parents:
diff changeset
   614
        if (next != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   615
            printHyperLink(next, "", tag, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   616
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   617
            print(tag);
06bc494ca11e Initial load
duke
parents:
diff changeset
   618
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   619
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   620
06bc494ca11e Initial load
duke
parents:
diff changeset
   621
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   622
     * Print "FRAMES" link, to switch to the frame version of the output.
06bc494ca11e Initial load
duke
parents:
diff changeset
   623
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   624
     * @param link File to be linked, "index.html".
06bc494ca11e Initial load
duke
parents:
diff changeset
   625
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   626
    protected void navShowLists(String link) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   627
        print(getHyperLink(link + "?" + path + filename, "",
06bc494ca11e Initial load
duke
parents:
diff changeset
   628
            configuration.getText("doclet.FRAMES"), true, "", "", "_top"));
06bc494ca11e Initial load
duke
parents:
diff changeset
   629
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   630
06bc494ca11e Initial load
duke
parents:
diff changeset
   631
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   632
     * Print "FRAMES" link, to switch to the frame version of the output.
06bc494ca11e Initial load
duke
parents:
diff changeset
   633
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   634
    protected void navShowLists() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   635
        navShowLists(relativePath + "index.html");
06bc494ca11e Initial load
duke
parents:
diff changeset
   636
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   637
06bc494ca11e Initial load
duke
parents:
diff changeset
   638
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   639
     * Print "NO FRAMES" link, to switch to the non-frame version of the output.
06bc494ca11e Initial load
duke
parents:
diff changeset
   640
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   641
     * @param link File to be linked.
06bc494ca11e Initial load
duke
parents:
diff changeset
   642
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   643
    protected void navHideLists(String link) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   644
        print(getHyperLink(link, "", configuration.getText("doclet.NO_FRAMES"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   645
            true, "", "", "_top"));
06bc494ca11e Initial load
duke
parents:
diff changeset
   646
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   647
06bc494ca11e Initial load
duke
parents:
diff changeset
   648
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   649
     * Print "Tree" link in the navigation bar. If there is only one package
06bc494ca11e Initial load
duke
parents:
diff changeset
   650
     * specified on the command line, then the "Tree" link will be to the
06bc494ca11e Initial load
duke
parents:
diff changeset
   651
     * only "package-tree.html" file otherwise it will be to the
06bc494ca11e Initial load
duke
parents:
diff changeset
   652
     * "overview-tree.html" file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   653
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   654
    protected void navLinkTree() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   655
        navCellStart();
06bc494ca11e Initial load
duke
parents:
diff changeset
   656
        PackageDoc[] packages = configuration.root.specifiedPackages();
06bc494ca11e Initial load
duke
parents:
diff changeset
   657
        if (packages.length == 1 && configuration.root.specifiedClasses().length == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   658
            printHyperLink(pathString(packages[0], "package-tree.html"), "",
06bc494ca11e Initial load
duke
parents:
diff changeset
   659
                           configuration.getText("doclet.Tree"), true, "NavBarFont1");
06bc494ca11e Initial load
duke
parents:
diff changeset
   660
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   661
            printHyperLink(relativePath + "overview-tree.html", "",
06bc494ca11e Initial load
duke
parents:
diff changeset
   662
                           configuration.getText("doclet.Tree"), true, "NavBarFont1");
06bc494ca11e Initial load
duke
parents:
diff changeset
   663
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   664
        navCellEnd();
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
     * Print "Tree" link to the "overview-tree.html" file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   669
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   670
    protected void navLinkMainTree(String label) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   671
        printHyperLink(relativePath + "overview-tree.html", label);
06bc494ca11e Initial load
duke
parents:
diff changeset
   672
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   673
06bc494ca11e Initial load
duke
parents:
diff changeset
   674
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   675
     * Print the word "Class" in the navigation bar cell, to indicate that
06bc494ca11e Initial load
duke
parents:
diff changeset
   676
     * class link is not available.
06bc494ca11e Initial load
duke
parents:
diff changeset
   677
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   678
    protected void navLinkClass() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   679
        navCellStart();
06bc494ca11e Initial load
duke
parents:
diff changeset
   680
        fontStyle("NavBarFont1");
06bc494ca11e Initial load
duke
parents:
diff changeset
   681
        printText("doclet.Class");
06bc494ca11e Initial load
duke
parents:
diff changeset
   682
        fontEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   683
        navCellEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   684
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   685
06bc494ca11e Initial load
duke
parents:
diff changeset
   686
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   687
     * Print "Deprecated" API link in the navigation bar.
06bc494ca11e Initial load
duke
parents:
diff changeset
   688
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   689
    protected void navLinkDeprecated() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   690
        navCellStart();
06bc494ca11e Initial load
duke
parents:
diff changeset
   691
        printHyperLink(relativePath + "deprecated-list.html", "",
06bc494ca11e Initial load
duke
parents:
diff changeset
   692
                       configuration.getText("doclet.navDeprecated"), true, "NavBarFont1");
06bc494ca11e Initial load
duke
parents:
diff changeset
   693
        navCellEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   694
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   695
06bc494ca11e Initial load
duke
parents:
diff changeset
   696
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   697
     * Print link for generated index. If the user has used "-splitindex"
06bc494ca11e Initial load
duke
parents:
diff changeset
   698
     * command line option, then link to file "index-files/index-1.html" is
06bc494ca11e Initial load
duke
parents:
diff changeset
   699
     * generated otherwise link to file "index-all.html" is generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
   700
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   701
    protected void navLinkClassIndex() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   702
        printNoFramesTargetHyperLink(relativePath +
06bc494ca11e Initial load
duke
parents:
diff changeset
   703
                AllClassesFrameWriter.OUTPUT_FILE_NAME_NOFRAMES,
06bc494ca11e Initial load
duke
parents:
diff changeset
   704
            "", "", configuration.getText("doclet.All_Classes"), true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   705
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   706
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   707
     * Print link for generated class index.
06bc494ca11e Initial load
duke
parents:
diff changeset
   708
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   709
    protected void navLinkIndex() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   710
        navCellStart();
06bc494ca11e Initial load
duke
parents:
diff changeset
   711
        printHyperLink(relativePath +
06bc494ca11e Initial load
duke
parents:
diff changeset
   712
                           (configuration.splitindex?
06bc494ca11e Initial load
duke
parents:
diff changeset
   713
                                DirectoryManager.getPath("index-files") +
06bc494ca11e Initial load
duke
parents:
diff changeset
   714
                                fileseparator: "") +
06bc494ca11e Initial load
duke
parents:
diff changeset
   715
                           (configuration.splitindex?
06bc494ca11e Initial load
duke
parents:
diff changeset
   716
                                "index-1.html" : "index-all.html"), "",
06bc494ca11e Initial load
duke
parents:
diff changeset
   717
                       configuration.getText("doclet.Index"), true, "NavBarFont1");
06bc494ca11e Initial load
duke
parents:
diff changeset
   718
        navCellEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   719
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   720
06bc494ca11e Initial load
duke
parents:
diff changeset
   721
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   722
     * Print help file link. If user has provided a help file, then generate a
06bc494ca11e Initial load
duke
parents:
diff changeset
   723
     * link to the user given file, which is already copied to current or
06bc494ca11e Initial load
duke
parents:
diff changeset
   724
     * destination directory.
06bc494ca11e Initial load
duke
parents:
diff changeset
   725
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   726
    protected void navLinkHelp() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   727
        String helpfilenm = configuration.helpfile;
06bc494ca11e Initial load
duke
parents:
diff changeset
   728
        if (helpfilenm.equals("")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   729
            helpfilenm = "help-doc.html";
06bc494ca11e Initial load
duke
parents:
diff changeset
   730
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   731
            int lastsep;
06bc494ca11e Initial load
duke
parents:
diff changeset
   732
            if ((lastsep = helpfilenm.lastIndexOf(File.separatorChar)) != -1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   733
                helpfilenm = helpfilenm.substring(lastsep + 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   734
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   735
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   736
        navCellStart();
06bc494ca11e Initial load
duke
parents:
diff changeset
   737
        printHyperLink(relativePath + helpfilenm, "",
06bc494ca11e Initial load
duke
parents:
diff changeset
   738
                       configuration.getText("doclet.Help"), true, "NavBarFont1");
06bc494ca11e Initial load
duke
parents:
diff changeset
   739
        navCellEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   740
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   741
06bc494ca11e Initial load
duke
parents:
diff changeset
   742
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   743
     * Print the word "Detail" in the navigation bar. No link is available.
06bc494ca11e Initial load
duke
parents:
diff changeset
   744
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   745
    protected void navDetail() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   746
        printText("doclet.Detail");
06bc494ca11e Initial load
duke
parents:
diff changeset
   747
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   748
06bc494ca11e Initial load
duke
parents:
diff changeset
   749
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   750
     * Print the word "Summary" in the navigation bar. No link is available.
06bc494ca11e Initial load
duke
parents:
diff changeset
   751
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   752
    protected void navSummary() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   753
        printText("doclet.Summary");
06bc494ca11e Initial load
duke
parents:
diff changeset
   754
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   755
06bc494ca11e Initial load
duke
parents:
diff changeset
   756
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   757
     * Print the Html table tag for the index summary tables. The table tag
06bc494ca11e Initial load
duke
parents:
diff changeset
   758
     * printed is
06bc494ca11e Initial load
duke
parents:
diff changeset
   759
     * &lt;TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
06bc494ca11e Initial load
duke
parents:
diff changeset
   760
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   761
    public void tableIndexSummary() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   762
        table(1, "100%", 3, 0);
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
     * Same as {@link #tableIndexSummary()}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   767
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   768
    public void tableIndexDetail() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   769
        table(1, "100%", 3, 0);
06bc494ca11e Initial load
duke
parents:
diff changeset
   770
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   771
06bc494ca11e Initial load
duke
parents:
diff changeset
   772
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   773
     * Print Html tag for table elements. The tag printed is
06bc494ca11e Initial load
duke
parents:
diff changeset
   774
     * &lt;TD ALIGN="right" VALIGN="top" WIDTH="1%"&gt;.
06bc494ca11e Initial load
duke
parents:
diff changeset
   775
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   776
    public void tdIndex() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   777
        print("<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\">");
06bc494ca11e Initial load
duke
parents:
diff changeset
   778
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   779
06bc494ca11e Initial load
duke
parents:
diff changeset
   780
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   781
     * Prine table header information about color, column span and the font.
06bc494ca11e Initial load
duke
parents:
diff changeset
   782
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   783
     * @param color Background color.
06bc494ca11e Initial load
duke
parents:
diff changeset
   784
     * @param span  Column span.
06bc494ca11e Initial load
duke
parents:
diff changeset
   785
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   786
    public void tableHeaderStart(String color, int span) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   787
        trBgcolorStyle(color, "TableHeadingColor");
06bc494ca11e Initial load
duke
parents:
diff changeset
   788
        thAlignColspan("left", span);
06bc494ca11e Initial load
duke
parents:
diff changeset
   789
        font("+2");
06bc494ca11e Initial load
duke
parents:
diff changeset
   790
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   791
06bc494ca11e Initial load
duke
parents:
diff changeset
   792
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   793
     * Print table header for the inherited members summary tables. Print the
06bc494ca11e Initial load
duke
parents:
diff changeset
   794
     * background color information.
06bc494ca11e Initial load
duke
parents:
diff changeset
   795
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   796
     * @param color Background color.
06bc494ca11e Initial load
duke
parents:
diff changeset
   797
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   798
    public void tableInheritedHeaderStart(String color) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   799
        trBgcolorStyle(color, "TableSubHeadingColor");
06bc494ca11e Initial load
duke
parents:
diff changeset
   800
        thAlign("left");
06bc494ca11e Initial load
duke
parents:
diff changeset
   801
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   802
06bc494ca11e Initial load
duke
parents:
diff changeset
   803
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   804
     * Print "Use" table header. Print the background color and the column span.
06bc494ca11e Initial load
duke
parents:
diff changeset
   805
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   806
     * @param color Background color.
06bc494ca11e Initial load
duke
parents:
diff changeset
   807
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   808
    public void tableUseInfoHeaderStart(String color) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   809
        trBgcolorStyle(color, "TableSubHeadingColor");
06bc494ca11e Initial load
duke
parents:
diff changeset
   810
        thAlignColspan("left", 2);
06bc494ca11e Initial load
duke
parents:
diff changeset
   811
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   812
06bc494ca11e Initial load
duke
parents:
diff changeset
   813
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   814
     * Print table header with the background color with default column span 2.
06bc494ca11e Initial load
duke
parents:
diff changeset
   815
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   816
     * @param color Background color.
06bc494ca11e Initial load
duke
parents:
diff changeset
   817
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   818
    public void tableHeaderStart(String color) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   819
        tableHeaderStart(color, 2);
06bc494ca11e Initial load
duke
parents:
diff changeset
   820
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   821
06bc494ca11e Initial load
duke
parents:
diff changeset
   822
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   823
     * Print table header with the column span, with the default color #CCCCFF.
06bc494ca11e Initial load
duke
parents:
diff changeset
   824
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   825
     * @param span Column span.
06bc494ca11e Initial load
duke
parents:
diff changeset
   826
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   827
    public void tableHeaderStart(int span) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   828
        tableHeaderStart("#CCCCFF", span);
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
     * Print table header with default column span 2 and default color #CCCCFF.
06bc494ca11e Initial load
duke
parents:
diff changeset
   833
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   834
    public void tableHeaderStart() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   835
        tableHeaderStart(2);
06bc494ca11e Initial load
duke
parents:
diff changeset
   836
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   837
06bc494ca11e Initial load
duke
parents:
diff changeset
   838
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   839
     * Print table header end tags for font, column and row.
06bc494ca11e Initial load
duke
parents:
diff changeset
   840
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   841
    public void tableHeaderEnd() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   842
        fontEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   843
        thEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   844
        trEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   845
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   846
06bc494ca11e Initial load
duke
parents:
diff changeset
   847
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   848
     * Print table header end tags in inherited tables for column and row.
06bc494ca11e Initial load
duke
parents:
diff changeset
   849
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   850
    public void tableInheritedHeaderEnd() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   851
        thEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   852
        trEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   853
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   854
06bc494ca11e Initial load
duke
parents:
diff changeset
   855
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   856
     * Print the summary table row cell attribute width.
06bc494ca11e Initial load
duke
parents:
diff changeset
   857
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   858
     * @param width Width of the table cell.
06bc494ca11e Initial load
duke
parents:
diff changeset
   859
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   860
    public void summaryRow(int width) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   861
        if (width != 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   862
            tdWidth(width + "%");
06bc494ca11e Initial load
duke
parents:
diff changeset
   863
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   864
            td();
06bc494ca11e Initial load
duke
parents:
diff changeset
   865
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   866
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   867
06bc494ca11e Initial load
duke
parents:
diff changeset
   868
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   869
     * Print the summary table row cell end tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   870
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   871
    public void summaryRowEnd() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   872
        tdEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   873
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   874
06bc494ca11e Initial load
duke
parents:
diff changeset
   875
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   876
     * Print the heading in Html &lt;H2> format.
06bc494ca11e Initial load
duke
parents:
diff changeset
   877
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   878
     * @param str The Header string.
06bc494ca11e Initial load
duke
parents:
diff changeset
   879
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   880
    public void printIndexHeading(String str) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   881
        h2();
06bc494ca11e Initial load
duke
parents:
diff changeset
   882
        print(str);
06bc494ca11e Initial load
duke
parents:
diff changeset
   883
        h2End();
06bc494ca11e Initial load
duke
parents:
diff changeset
   884
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   885
06bc494ca11e Initial load
duke
parents:
diff changeset
   886
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   887
     * Print Html tag &lt;FRAMESET=arg&gt;.
06bc494ca11e Initial load
duke
parents:
diff changeset
   888
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   889
     * @param arg Argument for the tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   890
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   891
    public void frameSet(String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   892
        println("<FRAMESET " + arg + ">");
06bc494ca11e Initial load
duke
parents:
diff changeset
   893
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   894
06bc494ca11e Initial load
duke
parents:
diff changeset
   895
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   896
     * Print Html closing tag &lt;/FRAMESET&gt;.
06bc494ca11e Initial load
duke
parents:
diff changeset
   897
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   898
    public void frameSetEnd() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   899
        println("</FRAMESET>");
06bc494ca11e Initial load
duke
parents:
diff changeset
   900
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   901
06bc494ca11e Initial load
duke
parents:
diff changeset
   902
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   903
     * Print Html tag &lt;FRAME=arg&gt;.
06bc494ca11e Initial load
duke
parents:
diff changeset
   904
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   905
     * @param arg Argument for the tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   906
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   907
    public void frame(String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   908
        println("<FRAME " + arg + ">");
06bc494ca11e Initial load
duke
parents:
diff changeset
   909
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   910
06bc494ca11e Initial load
duke
parents:
diff changeset
   911
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   912
     * Print Html closing tag &lt;/FRAME&gt;.
06bc494ca11e Initial load
duke
parents:
diff changeset
   913
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   914
    public void frameEnd() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   915
        println("</FRAME>");
06bc494ca11e Initial load
duke
parents:
diff changeset
   916
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   917
06bc494ca11e Initial load
duke
parents:
diff changeset
   918
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   919
     * Return path to the class page for a classdoc. For example, the class
06bc494ca11e Initial load
duke
parents:
diff changeset
   920
     * name is "java.lang.Object" and if the current file getting generated is
06bc494ca11e Initial load
duke
parents:
diff changeset
   921
     * "java/io/File.html", then the path string to the class, returned is
06bc494ca11e Initial load
duke
parents:
diff changeset
   922
     * "../../java/lang.Object.html".
06bc494ca11e Initial load
duke
parents:
diff changeset
   923
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   924
     * @param cd Class to which the path is requested.
06bc494ca11e Initial load
duke
parents:
diff changeset
   925
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   926
    protected String pathToClass(ClassDoc cd) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   927
        return pathString(cd.containingPackage(), cd.name() + ".html");
06bc494ca11e Initial load
duke
parents:
diff changeset
   928
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   929
06bc494ca11e Initial load
duke
parents:
diff changeset
   930
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   931
     * Return the path to the class page for a classdoc. Works same as
06bc494ca11e Initial load
duke
parents:
diff changeset
   932
     * {@link #pathToClass(ClassDoc)}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   933
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   934
     * @param cd   Class to which the path is requested.
06bc494ca11e Initial load
duke
parents:
diff changeset
   935
     * @param name Name of the file(doesn't include path).
06bc494ca11e Initial load
duke
parents:
diff changeset
   936
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   937
    protected String pathString(ClassDoc cd, String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   938
        return pathString(cd.containingPackage(), name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   939
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   940
06bc494ca11e Initial load
duke
parents:
diff changeset
   941
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   942
     * Return path to the given file name in the given package. So if the name
06bc494ca11e Initial load
duke
parents:
diff changeset
   943
     * passed is "Object.html" and the name of the package is "java.lang", and
06bc494ca11e Initial load
duke
parents:
diff changeset
   944
     * if the relative path is "../.." then returned string will be
06bc494ca11e Initial load
duke
parents:
diff changeset
   945
     * "../../java/lang/Object.html"
06bc494ca11e Initial load
duke
parents:
diff changeset
   946
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   947
     * @param pd Package in which the file name is assumed to be.
06bc494ca11e Initial load
duke
parents:
diff changeset
   948
     * @param name File name, to which path string is.
06bc494ca11e Initial load
duke
parents:
diff changeset
   949
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   950
    protected String pathString(PackageDoc pd, String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   951
        StringBuffer buf = new StringBuffer(relativePath);
06bc494ca11e Initial load
duke
parents:
diff changeset
   952
        buf.append(DirectoryManager.getPathToPackage(pd, name));
06bc494ca11e Initial load
duke
parents:
diff changeset
   953
        return buf.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
   954
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   955
06bc494ca11e Initial load
duke
parents:
diff changeset
   956
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   957
     * Print the link to the given package.
06bc494ca11e Initial load
duke
parents:
diff changeset
   958
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   959
     * @param pkg the package to link to.
06bc494ca11e Initial load
duke
parents:
diff changeset
   960
     * @param label the label for the link.
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   961
     * @param isStrong true if the label should be strong.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   962
     */
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   963
    public void printPackageLink(PackageDoc pkg, String label, boolean isStrong) {
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   964
        print(getPackageLink(pkg, label, isStrong));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   965
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   966
06bc494ca11e Initial load
duke
parents:
diff changeset
   967
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   968
     * Print the link to the given package.
06bc494ca11e Initial load
duke
parents:
diff changeset
   969
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   970
     * @param pkg the package to link to.
06bc494ca11e Initial load
duke
parents:
diff changeset
   971
     * @param label the label for the link.
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   972
     * @param isStrong true if the label should be strong.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   973
     * @param style  the font of the package link label.
06bc494ca11e Initial load
duke
parents:
diff changeset
   974
     */
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   975
    public void printPackageLink(PackageDoc pkg, String label, boolean isStrong,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   976
            String style) {
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   977
        print(getPackageLink(pkg, label, isStrong, style));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   978
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   979
06bc494ca11e Initial load
duke
parents:
diff changeset
   980
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   981
     * Return the link to the given package.
06bc494ca11e Initial load
duke
parents:
diff changeset
   982
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   983
     * @param pkg the package to link to.
06bc494ca11e Initial load
duke
parents:
diff changeset
   984
     * @param label the label for the link.
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   985
     * @param isStrong true if the label should be strong.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   986
     * @return the link to the given package.
06bc494ca11e Initial load
duke
parents:
diff changeset
   987
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   988
    public String getPackageLink(PackageDoc pkg, String label,
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   989
                                 boolean isStrong) {
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   990
        return getPackageLink(pkg, label, isStrong, "");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   991
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   992
06bc494ca11e Initial load
duke
parents:
diff changeset
   993
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   994
     * Return the link to the given package.
06bc494ca11e Initial load
duke
parents:
diff changeset
   995
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   996
     * @param pkg the package to link to.
06bc494ca11e Initial load
duke
parents:
diff changeset
   997
     * @param label the label for the link.
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   998
     * @param isStrong true if the label should be strong.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   999
     * @param style  the font of the package link label.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1000
     * @return the link to the given package.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1001
     */
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1002
    public String getPackageLink(PackageDoc pkg, String label, boolean isStrong,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1003
            String style) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1004
        boolean included = pkg != null && pkg.isIncluded();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1005
        if (! included) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1006
            PackageDoc[] packages = configuration.packages;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1007
            for (int i = 0; i < packages.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1008
                if (packages[i].equals(pkg)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1009
                    included = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1010
                    break;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1011
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1012
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1013
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1014
        if (included || pkg == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1015
            return getHyperLink(pathString(pkg, "package-summary.html"),
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1016
                                "", label, isStrong, style);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1017
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1018
            String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1019
            if (crossPkgLink != null) {
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1020
                return getHyperLink(crossPkgLink, "", label, isStrong, style);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1021
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1022
                return label;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1023
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1024
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1025
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1026
06bc494ca11e Initial load
duke
parents:
diff changeset
  1027
    public String italicsClassName(ClassDoc cd, boolean qual) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1028
        String name = (qual)? cd.qualifiedName(): cd.name();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1029
        return (cd.isInterface())?  italicsText(name): name;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1030
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1031
06bc494ca11e Initial load
duke
parents:
diff changeset
  1032
    public void printSrcLink(ProgramElementDoc d, String label) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1033
        if (d == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1034
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1035
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1036
        ClassDoc cd = d.containingClass();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1037
        if (cd == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1038
            //d must be a class doc since in has no containing class.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1039
            cd = (ClassDoc) d;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1040
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1041
        String href = relativePath + DocletConstants.SOURCE_OUTPUT_DIR_NAME
06bc494ca11e Initial load
duke
parents:
diff changeset
  1042
            + DirectoryManager.getDirectoryPath(cd.containingPackage())
06bc494ca11e Initial load
duke
parents:
diff changeset
  1043
            + cd.name() + ".html#" + SourceToHTMLConverter.getAnchorName(d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1044
        printHyperLink(href, "", label, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1045
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1046
06bc494ca11e Initial load
duke
parents:
diff changeset
  1047
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1048
     * Return the link to the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1049
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1050
     * @param linkInfo the information about the link.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1051
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1052
     * @return the link for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1053
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1054
    public String getLink(LinkInfoImpl linkInfo) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1055
        LinkFactoryImpl factory = new LinkFactoryImpl(this);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1056
        String link = ((LinkOutputImpl) factory.getLinkOutput(linkInfo)).toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1057
        displayLength += linkInfo.displayLength;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1058
        return link;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1059
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1060
06bc494ca11e Initial load
duke
parents:
diff changeset
  1061
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1062
     * Return the type parameters for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1063
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1064
     * @param linkInfo the information about the link.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1065
     * @return the type for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1066
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1067
    public String getTypeParameterLinks(LinkInfoImpl linkInfo) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1068
        LinkFactoryImpl factory = new LinkFactoryImpl(this);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1069
        return ((LinkOutputImpl)
06bc494ca11e Initial load
duke
parents:
diff changeset
  1070
            factory.getTypeParameterLinks(linkInfo, false)).toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1071
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1072
06bc494ca11e Initial load
duke
parents:
diff changeset
  1073
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1074
     * Print the link to the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1075
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1076
    public void printLink(LinkInfoImpl linkInfo) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1077
        print(getLink(linkInfo));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1078
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1079
06bc494ca11e Initial load
duke
parents:
diff changeset
  1080
    /*************************************************************
06bc494ca11e Initial load
duke
parents:
diff changeset
  1081
     * Return a class cross link to external class documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1082
     * The name must be fully qualified to determine which package
06bc494ca11e Initial load
duke
parents:
diff changeset
  1083
     * the class is in.  The -link option does not allow users to
06bc494ca11e Initial load
duke
parents:
diff changeset
  1084
     * link to external classes in the "default" package.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1085
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1086
     * @param qualifiedClassName the qualified name of the external class.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1087
     * @param refMemName the name of the member being referenced.  This should
06bc494ca11e Initial load
duke
parents:
diff changeset
  1088
     * be null or empty string if no member is being referenced.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1089
     * @param label the label for the external link.
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1090
     * @param strong true if the link should be strong.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1091
     * @param style the style of the link.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1092
     * @param code true if the label should be code font.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1093
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1094
    public String getCrossClassLink(String qualifiedClassName, String refMemName,
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1095
                                    String label, boolean strong, String style,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1096
                                    boolean code) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1097
        String className = "",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1098
            packageName = qualifiedClassName == null ? "" : qualifiedClassName;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1099
        int periodIndex;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1100
        while((periodIndex = packageName.lastIndexOf('.')) != -1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1101
            className = packageName.substring(periodIndex + 1, packageName.length()) +
06bc494ca11e Initial load
duke
parents:
diff changeset
  1102
                (className.length() > 0 ? "." + className : "");
06bc494ca11e Initial load
duke
parents:
diff changeset
  1103
            String defaultLabel = code ? getCode() + className + getCodeEnd() : className;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1104
            packageName = packageName.substring(0, periodIndex);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1105
            if (getCrossPackageLink(packageName) != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1106
                //The package exists in external documentation, so link to the external
06bc494ca11e Initial load
duke
parents:
diff changeset
  1107
                //class (assuming that it exists).  This is definitely a limitation of
06bc494ca11e Initial load
duke
parents:
diff changeset
  1108
                //the -link option.  There are ways to determine if an external package
06bc494ca11e Initial load
duke
parents:
diff changeset
  1109
                //exists, but no way to determine if the external class exists.  We just
06bc494ca11e Initial load
duke
parents:
diff changeset
  1110
                //have to assume that it does.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1111
                return getHyperLink(
06bc494ca11e Initial load
duke
parents:
diff changeset
  1112
                    configuration.extern.getExternalLink(packageName, relativePath,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1113
                                className + ".html?is-external=true"),
06bc494ca11e Initial load
duke
parents:
diff changeset
  1114
                    refMemName == null ? "" : refMemName,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1115
                    label == null || label.length() == 0 ? defaultLabel : label,
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1116
                    strong, style,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1117
                    configuration.getText("doclet.Href_Class_Or_Interface_Title", packageName),
06bc494ca11e Initial load
duke
parents:
diff changeset
  1118
                    "");
06bc494ca11e Initial load
duke
parents:
diff changeset
  1119
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1120
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1121
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1122
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1123
06bc494ca11e Initial load
duke
parents:
diff changeset
  1124
    public boolean isClassLinkable(ClassDoc cd) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1125
        if (cd.isIncluded()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1126
            return configuration.isGeneratedDoc(cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1127
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1128
        return configuration.extern.isExternal(cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1129
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1130
06bc494ca11e Initial load
duke
parents:
diff changeset
  1131
    public String getCrossPackageLink(String pkgName) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1132
        return configuration.extern.getExternalLink(pkgName, relativePath,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1133
            "package-summary.html?is-external=true");
06bc494ca11e Initial load
duke
parents:
diff changeset
  1134
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1135
06bc494ca11e Initial load
duke
parents:
diff changeset
  1136
    public void printQualifiedClassLink(int context, ClassDoc cd) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1137
        printLink(new LinkInfoImpl(context, cd,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1138
            configuration.getClassName(cd), ""));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1139
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1140
06bc494ca11e Initial load
duke
parents:
diff changeset
  1141
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1142
     * Print Class link, with only class name as the link and prefixing
06bc494ca11e Initial load
duke
parents:
diff changeset
  1143
     * plain package name.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1144
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1145
    public void printPreQualifiedClassLink(int context, ClassDoc cd) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1146
        print(getPreQualifiedClassLink(context, cd, false));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1147
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1148
06bc494ca11e Initial load
duke
parents:
diff changeset
  1149
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1150
     * Retrieve the class link with the package portion of the label in
06bc494ca11e Initial load
duke
parents:
diff changeset
  1151
     * plain text.  If the qualifier is excluded, it willnot be included in the
06bc494ca11e Initial load
duke
parents:
diff changeset
  1152
     * link label.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1153
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1154
     * @param cd the class to link to.
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1155
     * @param isStrong true if the link should be strong.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1156
     * @return the link with the package portion of the label in plain text.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1157
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1158
    public String getPreQualifiedClassLink(int context,
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1159
            ClassDoc cd, boolean isStrong) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1160
        String classlink = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
  1161
        PackageDoc pd = cd.containingPackage();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1162
        if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1163
            classlink = getPkgName(cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1164
        }
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1165
        classlink += getLink(new LinkInfoImpl(context, cd, cd.name(), isStrong));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1166
        return classlink;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1167
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1168
06bc494ca11e Initial load
duke
parents:
diff changeset
  1169
06bc494ca11e Initial load
duke
parents:
diff changeset
  1170
    /**
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1171
     * Print Class link, with only class name as the strong link and prefixing
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1172
     * plain package name.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1173
     */
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1174
    public void printPreQualifiedStrongClassLink(int context, ClassDoc cd) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1175
        print(getPreQualifiedClassLink(context, cd, true));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1176
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1177
06bc494ca11e Initial load
duke
parents:
diff changeset
  1178
    public void printText(String key) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1179
        print(configuration.getText(key));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1180
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1181
06bc494ca11e Initial load
duke
parents:
diff changeset
  1182
    public void printText(String key, String a1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1183
        print(configuration.getText(key, a1));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1184
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1185
06bc494ca11e Initial load
duke
parents:
diff changeset
  1186
    public void printText(String key, String a1, String a2) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1187
        print(configuration.getText(key, a1, a2));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1188
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1189
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1190
    public void strongText(String key) {
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1191
        strong(configuration.getText(key));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1192
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1193
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1194
    public void strongText(String key, String a1) {
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1195
        strong(configuration.getText(key, a1));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1196
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1197
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1198
    public void strongText(String key, String a1, String a2) {
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1199
        strong(configuration.getText(key, a1, a2));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1200
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1201
06bc494ca11e Initial load
duke
parents:
diff changeset
  1202
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1203
     * Print the link for the given member.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1204
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1205
     * @param context the id of the context where the link will be printed.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1206
     * @param doc the member being linked to.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1207
     * @param label the label for the link.
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1208
     * @param strong true if the link should be strong.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1209
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1210
    public void printDocLink(int context, MemberDoc doc, String label,
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1211
            boolean strong) {
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1212
        print(getDocLink(context, doc, label, strong));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1213
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1214
06bc494ca11e Initial load
duke
parents:
diff changeset
  1215
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1216
     * Print the link for the given member.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1217
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1218
     * @param context the id of the context where the link will be printed.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1219
     * @param classDoc the classDoc that we should link to.  This is not
06bc494ca11e Initial load
duke
parents:
diff changeset
  1220
     *                 necessarily equal to doc.containingClass().  We may be
06bc494ca11e Initial load
duke
parents:
diff changeset
  1221
     *                 inheriting comments.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1222
     * @param doc the member being linked to.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1223
     * @param label the label for the link.
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1224
     * @param strong true if the link should be strong.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1225
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1226
    public void printDocLink(int context, ClassDoc classDoc, MemberDoc doc,
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1227
            String label, boolean strong) {
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1228
        print(getDocLink(context, classDoc, doc, label, strong));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1229
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1230
06bc494ca11e Initial load
duke
parents:
diff changeset
  1231
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1232
     * Return the link for the given member.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1233
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1234
     * @param context the id of the context where the link will be printed.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1235
     * @param doc the member being linked to.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1236
     * @param label the label for the link.
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1237
     * @param strong true if the link should be strong.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1238
     * @return the link for the given member.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1239
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1240
    public String getDocLink(int context, MemberDoc doc, String label,
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1241
                boolean strong) {
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1242
        return getDocLink(context, doc.containingClass(), doc, label, strong);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1243
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1244
06bc494ca11e Initial load
duke
parents:
diff changeset
  1245
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1246
     * Return the link for the given member.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1247
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1248
     * @param context the id of the context where the link will be printed.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1249
     * @param classDoc the classDoc that we should link to.  This is not
06bc494ca11e Initial load
duke
parents:
diff changeset
  1250
     *                 necessarily equal to doc.containingClass().  We may be
06bc494ca11e Initial load
duke
parents:
diff changeset
  1251
     *                 inheriting comments.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1252
     * @param doc the member being linked to.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1253
     * @param label the label for the link.
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1254
     * @param strong true if the link should be strong.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1255
     * @return the link for the given member.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1256
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1257
    public String getDocLink(int context, ClassDoc classDoc, MemberDoc doc,
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1258
        String label, boolean strong) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1259
        if (! (doc.isIncluded() ||
06bc494ca11e Initial load
duke
parents:
diff changeset
  1260
            Util.isLinkable(classDoc, configuration()))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1261
            return label;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1262
        } else if (doc instanceof ExecutableMemberDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1263
            ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1264
            return getLink(new LinkInfoImpl(context, classDoc,
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1265
                getAnchor(emd), label, strong));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1266
        } else if (doc instanceof MemberDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1267
            return getLink(new LinkInfoImpl(context, classDoc,
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
  1268
                doc.name(), label, strong));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1269
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1270
            return label;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1271
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1272
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1273
06bc494ca11e Initial load
duke
parents:
diff changeset
  1274
    public void anchor(ExecutableMemberDoc emd) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1275
        anchor(getAnchor(emd));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1276
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1277
06bc494ca11e Initial load
duke
parents:
diff changeset
  1278
    public String getAnchor(ExecutableMemberDoc emd) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1279
        StringBuilder signature = new StringBuilder(emd.signature());
06bc494ca11e Initial load
duke
parents:
diff changeset
  1280
        StringBuilder signatureParsed = new StringBuilder();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1281
        int counter = 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1282
        for (int i = 0; i < signature.length(); i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1283
            char c = signature.charAt(i);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1284
            if (c == '<') {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1285
                counter++;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1286
            } else if (c == '>') {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1287
                counter--;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1288
            } else if (counter == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1289
                signatureParsed.append(c);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1290
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1291
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1292
        return emd.name() + signatureParsed.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1293
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1294
06bc494ca11e Initial load
duke
parents:
diff changeset
  1295
    public String seeTagToString(SeeTag see) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1296
        String tagName = see.name();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1297
        if (! (tagName.startsWith("@link") || tagName.equals("@see"))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1298
            return "";
06bc494ca11e Initial load
duke
parents:
diff changeset
  1299
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1300
        StringBuffer result = new StringBuffer();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1301
        boolean isplaintext = tagName.toLowerCase().equals("@linkplain");
06bc494ca11e Initial load
duke
parents:
diff changeset
  1302
        String label = see.label();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1303
        label = (label.length() > 0)?
06bc494ca11e Initial load
duke
parents:
diff changeset
  1304
            ((isplaintext) ? label :
06bc494ca11e Initial load
duke
parents:
diff changeset
  1305
                 getCode() + label + getCodeEnd()):"";
06bc494ca11e Initial load
duke
parents:
diff changeset
  1306
        String seetext = replaceDocRootDir(see.text());
06bc494ca11e Initial load
duke
parents:
diff changeset
  1307
06bc494ca11e Initial load
duke
parents:
diff changeset
  1308
        //Check if @see is an href or "string"
06bc494ca11e Initial load
duke
parents:
diff changeset
  1309
        if (seetext.startsWith("<") || seetext.startsWith("\"")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1310
            result.append(seetext);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1311
            return result.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1312
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1313
06bc494ca11e Initial load
duke
parents:
diff changeset
  1314
        //The text from the @see tag.  We will output this text when a label is not specified.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1315
        String text = (isplaintext) ? seetext : getCode() + seetext + getCodeEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1316
06bc494ca11e Initial load
duke
parents:
diff changeset
  1317
        ClassDoc refClass = see.referencedClass();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1318
        String refClassName = see.referencedClassName();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1319
        MemberDoc refMem = see.referencedMember();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1320
        String refMemName = see.referencedMemberName();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1321
        if (refClass == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1322
            //@see is not referencing an included class
06bc494ca11e Initial load
duke
parents:
diff changeset
  1323
            PackageDoc refPackage = see.referencedPackage();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1324
            if (refPackage != null && refPackage.isIncluded()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1325
                //@see is referencing an included package
06bc494ca11e Initial load
duke
parents:
diff changeset
  1326
                String packageName = isplaintext ? refPackage.name() :
06bc494ca11e Initial load
duke
parents:
diff changeset
  1327
                    getCode() + refPackage.name() + getCodeEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1328
                result.append(getPackageLink(refPackage,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1329
                    label.length() == 0 ? packageName : label, false));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1330
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1331
                //@see is not referencing an included class or package.  Check for cross links.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1332
                String classCrossLink, packageCrossLink = getCrossPackageLink(refClassName);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1333
                if (packageCrossLink != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1334
                    //Package cross link found
06bc494ca11e Initial load
duke
parents:
diff changeset
  1335
                    result.append(getHyperLink(packageCrossLink, "",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1336
                        (label.length() == 0)? text : label, false));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1337
                } else if ((classCrossLink = getCrossClassLink(refClassName,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1338
                        refMemName, label, false, "", ! isplaintext)) != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1339
                    //Class cross link found (possiblly to a member in the class)
06bc494ca11e Initial load
duke
parents:
diff changeset
  1340
                    result.append(classCrossLink);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1341
                } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1342
                    //No cross link found so print warning
06bc494ca11e Initial load
duke
parents:
diff changeset
  1343
                    configuration.getDocletSpecificMsg().warning(see.position(), "doclet.see.class_or_package_not_found",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1344
                            tagName, seetext);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1345
                    result.append((label.length() == 0)? text: label);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1346
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1347
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1348
        } else if (refMemName == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1349
            // Must be a class reference since refClass is not null and refMemName is null.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1350
            if (label.length() == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1351
                label = (isplaintext) ? refClass.name() : getCode() + refClass.name() + getCodeEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1352
                result.append(getLink(new LinkInfoImpl(refClass, label)));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1353
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1354
                result.append(getLink(new LinkInfoImpl(refClass, label)));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1355
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1356
        } else if (refMem == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1357
            // Must be a member reference since refClass is not null and refMemName is not null.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1358
            // However, refMem is null, so this referenced member does not exist.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1359
            result.append((label.length() == 0)? text: label);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1360
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1361
            // Must be a member reference since refClass is not null and refMemName is not null.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1362
            // refMem is not null, so this @see tag must be referencing a valid member.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1363
            ClassDoc containing = refMem.containingClass();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1364
            if (see.text().trim().startsWith("#") &&
06bc494ca11e Initial load
duke
parents:
diff changeset
  1365
                ! (containing.isPublic() ||
06bc494ca11e Initial load
duke
parents:
diff changeset
  1366
                Util.isLinkable(containing, configuration()))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1367
                // Since the link is relative and the holder is not even being
06bc494ca11e Initial load
duke
parents:
diff changeset
  1368
                // documented, this must be an inherited link.  Redirect it.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1369
                // The current class either overrides the referenced member or
06bc494ca11e Initial load
duke
parents:
diff changeset
  1370
                // inherits it automatically.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1371
                containing = ((ClassWriterImpl) this).getClassDoc();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1372
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1373
            if (configuration.currentcd != containing) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1374
                refMemName = containing.name() + "." + refMemName;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1375
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1376
            if (refMem instanceof ExecutableMemberDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1377
                if (refMemName.indexOf('(') < 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1378
                    refMemName += ((ExecutableMemberDoc)refMem).signature();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1379
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1380
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1381
            text = (isplaintext) ?
06bc494ca11e Initial load
duke
parents:
diff changeset
  1382
                refMemName : getCode() + refMemName + getCodeEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1383
06bc494ca11e Initial load
duke
parents:
diff changeset
  1384
            result.append(getDocLink(LinkInfoImpl.CONTEXT_SEE_TAG, containing,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1385
                refMem, (label.length() == 0)? text: label, false));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1386
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1387
        return result.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1388
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1389
06bc494ca11e Initial load
duke
parents:
diff changeset
  1390
    public void printInlineComment(Doc doc, Tag tag) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1391
        printCommentTags(doc, tag.inlineTags(), false, false);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1392
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1393
06bc494ca11e Initial load
duke
parents:
diff changeset
  1394
    public void printInlineDeprecatedComment(Doc doc, Tag tag) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1395
        printCommentTags(doc, tag.inlineTags(), true, false);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1396
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1397
06bc494ca11e Initial load
duke
parents:
diff changeset
  1398
    public void printSummaryComment(Doc doc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1399
        printSummaryComment(doc, doc.firstSentenceTags());
06bc494ca11e Initial load
duke
parents:
diff changeset
  1400
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1401
06bc494ca11e Initial load
duke
parents:
diff changeset
  1402
    public void printSummaryComment(Doc doc, Tag[] firstSentenceTags) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1403
        printCommentTags(doc, firstSentenceTags, false, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1404
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1405
06bc494ca11e Initial load
duke
parents:
diff changeset
  1406
    public void printSummaryDeprecatedComment(Doc doc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1407
        printCommentTags(doc, doc.firstSentenceTags(), true, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1408
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1409
06bc494ca11e Initial load
duke
parents:
diff changeset
  1410
    public void printSummaryDeprecatedComment(Doc doc, Tag tag) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1411
        printCommentTags(doc, tag.firstSentenceTags(), true, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1412
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1413
06bc494ca11e Initial load
duke
parents:
diff changeset
  1414
    public void printInlineComment(Doc doc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1415
        printCommentTags(doc, doc.inlineTags(), false, false);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1416
        p();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1417
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1418
06bc494ca11e Initial load
duke
parents:
diff changeset
  1419
    public void printInlineDeprecatedComment(Doc doc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1420
        printCommentTags(doc, doc.inlineTags(), true, false);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1421
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1422
06bc494ca11e Initial load
duke
parents:
diff changeset
  1423
    private void printCommentTags(Doc doc, Tag[] tags, boolean depr, boolean first) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1424
        if(configuration.nocomment){
06bc494ca11e Initial load
duke
parents:
diff changeset
  1425
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1426
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1427
        if (depr) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1428
            italic();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1429
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1430
        String result = commentTagsToString(null, doc, tags, first);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1431
        print(result);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1432
        if (depr) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1433
            italicEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1434
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1435
        if (tags.length == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1436
            space();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1437
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1438
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1439
06bc494ca11e Initial load
duke
parents:
diff changeset
  1440
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1441
     * Converts inline tags and text to text strings, expanding the
06bc494ca11e Initial load
duke
parents:
diff changeset
  1442
     * inline tags along the way.  Called wherever text can contain
06bc494ca11e Initial load
duke
parents:
diff changeset
  1443
     * an inline tag, such as in comments or in free-form text arguments
06bc494ca11e Initial load
duke
parents:
diff changeset
  1444
     * to non-inline tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1445
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1446
     * @param holderTag    specific tag where comment resides
06bc494ca11e Initial load
duke
parents:
diff changeset
  1447
     * @param doc    specific doc where comment resides
06bc494ca11e Initial load
duke
parents:
diff changeset
  1448
     * @param tags   array of text tags and inline tags (often alternating)
06bc494ca11e Initial load
duke
parents:
diff changeset
  1449
     *               present in the text of interest for this doc
06bc494ca11e Initial load
duke
parents:
diff changeset
  1450
     * @param isFirstSentence  true if text is first sentence
06bc494ca11e Initial load
duke
parents:
diff changeset
  1451
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1452
    public String commentTagsToString(Tag holderTag, Doc doc, Tag[] tags,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1453
            boolean isFirstSentence) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1454
        StringBuffer result = new StringBuffer();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1455
        // Array of all possible inline tags for this javadoc run
06bc494ca11e Initial load
duke
parents:
diff changeset
  1456
        configuration.tagletManager.checkTags(doc, tags, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1457
        for (int i = 0; i < tags.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1458
            Tag tagelem = tags[i];
06bc494ca11e Initial load
duke
parents:
diff changeset
  1459
            String tagName = tagelem.name();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1460
            if (tagelem instanceof SeeTag) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1461
                result.append(seeTagToString((SeeTag)tagelem));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1462
            } else if (! tagName.equals("Text")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1463
                int originalLength = result.length();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1464
                TagletOutput output = TagletWriter.getInlineTagOuput(
06bc494ca11e Initial load
duke
parents:
diff changeset
  1465
                    configuration.tagletManager, holderTag,
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
  1466
                    tagelem, getTagletWriterInstance(isFirstSentence));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1467
                result.append(output == null ? "" : output.toString());
06bc494ca11e Initial load
duke
parents:
diff changeset
  1468
                if (originalLength == 0 && isFirstSentence && tagelem.name().equals("@inheritDoc") && result.length() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1469
                    break;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1470
                } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1471
                        continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1472
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1473
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1474
                //This is just a regular text tag.  The text may contain html links (<a>)
06bc494ca11e Initial load
duke
parents:
diff changeset
  1475
                //or inline tag {@docRoot}, which will be handled as special cases.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1476
                String text = redirectRelativeLinks(tagelem.holder(), tagelem.text());
06bc494ca11e Initial load
duke
parents:
diff changeset
  1477
06bc494ca11e Initial load
duke
parents:
diff changeset
  1478
                // Replace @docRoot only if not represented by an instance of DocRootTaglet,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1479
                // that is, only if it was not present in a source file doc comment.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1480
                // This happens when inserted by the doclet (a few lines
06bc494ca11e Initial load
duke
parents:
diff changeset
  1481
                // above in this method).  [It might also happen when passed in on the command
06bc494ca11e Initial load
duke
parents:
diff changeset
  1482
                // line as a text argument to an option (like -header).]
06bc494ca11e Initial load
duke
parents:
diff changeset
  1483
                text = replaceDocRootDir(text);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1484
                if (isFirstSentence) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1485
                    text = removeNonInlineHtmlTags(text);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1486
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1487
                StringTokenizer lines = new StringTokenizer(text, "\r\n", true);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1488
                StringBuffer textBuff = new StringBuffer();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1489
                while (lines.hasMoreTokens()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1490
                    StringBuffer line = new StringBuffer(lines.nextToken());
06bc494ca11e Initial load
duke
parents:
diff changeset
  1491
                    Util.replaceTabs(configuration.sourcetab, line);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1492
                    textBuff.append(line.toString());
06bc494ca11e Initial load
duke
parents:
diff changeset
  1493
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1494
                result.append(textBuff);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1495
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1496
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1497
        return result.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1498
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1499
06bc494ca11e Initial load
duke
parents:
diff changeset
  1500
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1501
     * Return true if relative links should not be redirected.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1502
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1503
     * @return Return true if a relative link should not be redirected.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1504
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1505
    private boolean shouldNotRedirectRelativeLinks() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1506
        return  this instanceof AnnotationTypeWriter ||
06bc494ca11e Initial load
duke
parents:
diff changeset
  1507
                this instanceof ClassWriter ||
06bc494ca11e Initial load
duke
parents:
diff changeset
  1508
                this instanceof PackageSummaryWriter;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1509
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1510
06bc494ca11e Initial load
duke
parents:
diff changeset
  1511
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1512
     * Suppose a piece of documentation has a relative link.  When you copy
06bc494ca11e Initial load
duke
parents:
diff changeset
  1513
     * that documetation to another place such as the index or class-use page,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1514
     * that relative link will no longer work.  We should redirect those links
06bc494ca11e Initial load
duke
parents:
diff changeset
  1515
     * so that they will work again.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1516
     * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
  1517
     * Here is the algorithm used to fix the link:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1518
     * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
  1519
     * &lt;relative link&gt; => docRoot + &lt;relative path to file&gt; + &lt;relative link&gt;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1520
     * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
  1521
     * For example, suppose com.sun.javadoc.RootDoc has this link:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1522
     * &lt;a href="package-summary.html"&gt;The package Page&lt;/a&gt;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1523
     * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
  1524
     * If this link appeared in the index, we would redirect
06bc494ca11e Initial load
duke
parents:
diff changeset
  1525
     * the link like this:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1526
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1527
     * &lt;a href="./com/sun/javadoc/package-summary.html"&gt;The package Page&lt;/a&gt;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1528
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1529
     * @param doc the Doc object whose documentation is being written.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1530
     * @param text the text being written.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1531
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1532
     * @return the text, with all the relative links redirected to work.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1533
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1534
    private String redirectRelativeLinks(Doc doc, String text) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1535
        if (doc == null || shouldNotRedirectRelativeLinks()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1536
            return text;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1537
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1538
06bc494ca11e Initial load
duke
parents:
diff changeset
  1539
        String redirectPathFromRoot;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1540
        if (doc instanceof ClassDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1541
            redirectPathFromRoot = DirectoryManager.getDirectoryPath(((ClassDoc) doc).containingPackage());
06bc494ca11e Initial load
duke
parents:
diff changeset
  1542
        } else if (doc instanceof MemberDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1543
            redirectPathFromRoot = DirectoryManager.getDirectoryPath(((MemberDoc) doc).containingPackage());
06bc494ca11e Initial load
duke
parents:
diff changeset
  1544
        } else if (doc instanceof PackageDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1545
            redirectPathFromRoot = DirectoryManager.getDirectoryPath((PackageDoc) doc);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1546
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1547
            return text;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1548
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1549
06bc494ca11e Initial load
duke
parents:
diff changeset
  1550
        if (! redirectPathFromRoot.endsWith(DirectoryManager.URL_FILE_SEPERATOR)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1551
            redirectPathFromRoot += DirectoryManager.URL_FILE_SEPERATOR;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1552
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1553
06bc494ca11e Initial load
duke
parents:
diff changeset
  1554
        //Redirect all relative links.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1555
        int end, begin = text.toLowerCase().indexOf("<a");
06bc494ca11e Initial load
duke
parents:
diff changeset
  1556
        if(begin >= 0){
06bc494ca11e Initial load
duke
parents:
diff changeset
  1557
            StringBuffer textBuff = new StringBuffer(text);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1558
06bc494ca11e Initial load
duke
parents:
diff changeset
  1559
            while(begin >=0){
06bc494ca11e Initial load
duke
parents:
diff changeset
  1560
                if (textBuff.length() > begin + 2 && ! Character.isWhitespace(textBuff.charAt(begin+2))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1561
                    begin = textBuff.toString().toLowerCase().indexOf("<a", begin + 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1562
                    continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1563
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1564
06bc494ca11e Initial load
duke
parents:
diff changeset
  1565
                begin = textBuff.indexOf("=", begin) + 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1566
                end = textBuff.indexOf(">", begin +1);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1567
                if(begin == 0){
06bc494ca11e Initial load
duke
parents:
diff changeset
  1568
                    //Link has no equal symbol.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1569
                    configuration.root.printWarning(
06bc494ca11e Initial load
duke
parents:
diff changeset
  1570
                        doc.position(),
06bc494ca11e Initial load
duke
parents:
diff changeset
  1571
                        configuration.getText("doclet.malformed_html_link_tag", text));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1572
                    break;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1573
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1574
                if (end == -1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1575
                    //Break without warning.  This <a> tag is not necessarily malformed.  The text
06bc494ca11e Initial load
duke
parents:
diff changeset
  1576
                    //might be missing '>' character because the href has an inline tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1577
                    break;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1578
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1579
                if(textBuff.substring(begin, end).indexOf("\"") != -1){
06bc494ca11e Initial load
duke
parents:
diff changeset
  1580
                    begin = textBuff.indexOf("\"", begin) + 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1581
                    end = textBuff.indexOf("\"", begin +1);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1582
                    if(begin == 0 || end == -1){
06bc494ca11e Initial load
duke
parents:
diff changeset
  1583
                        //Link is missing a quote.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1584
                        break;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1585
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1586
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1587
                String relativeLink = textBuff.substring(begin, end);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1588
                if(!(relativeLink.toLowerCase().startsWith("mailto:") ||
06bc494ca11e Initial load
duke
parents:
diff changeset
  1589
                     relativeLink.toLowerCase().startsWith("http:") ||
06bc494ca11e Initial load
duke
parents:
diff changeset
  1590
                     relativeLink.toLowerCase().startsWith("https:") ||
06bc494ca11e Initial load
duke
parents:
diff changeset
  1591
                     relativeLink.toLowerCase().startsWith("file:"))){
06bc494ca11e Initial load
duke
parents:
diff changeset
  1592
                     relativeLink = "{@"+(new DocRootTaglet()).getName() + "}"
06bc494ca11e Initial load
duke
parents:
diff changeset
  1593
                        + redirectPathFromRoot
06bc494ca11e Initial load
duke
parents:
diff changeset
  1594
                        + relativeLink;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1595
                    textBuff.replace(begin, end, relativeLink);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1596
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1597
                begin = textBuff.toString().toLowerCase().indexOf("<a", begin + 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1598
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1599
            return textBuff.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1600
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1601
        return text;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1602
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1603
06bc494ca11e Initial load
duke
parents:
diff changeset
  1604
    public String removeNonInlineHtmlTags(String text) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1605
        if (text.indexOf('<') < 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1606
            return text;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1607
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1608
        String noninlinetags[] = { "<ul>", "</ul>", "<ol>", "</ol>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1609
                "<dl>", "</dl>", "<table>", "</table>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1610
                "<tr>", "</tr>", "<td>", "</td>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1611
                "<th>", "</th>", "<p>", "</p>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1612
                "<li>", "</li>", "<dd>", "</dd>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1613
                "<dir>", "</dir>", "<dt>", "</dt>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1614
                "<h1>", "</h1>", "<h2>", "</h2>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1615
                "<h3>", "</h3>", "<h4>", "</h4>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1616
                "<h5>", "</h5>", "<h6>", "</h6>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1617
                "<pre>", "</pre>", "<menu>", "</menu>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1618
                "<listing>", "</listing>", "<hr>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1619
                "<blockquote>", "</blockquote>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1620
                "<center>", "</center>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1621
                "<UL>", "</UL>", "<OL>", "</OL>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1622
                "<DL>", "</DL>", "<TABLE>", "</TABLE>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1623
                "<TR>", "</TR>", "<TD>", "</TD>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1624
                "<TH>", "</TH>", "<P>", "</P>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1625
                "<LI>", "</LI>", "<DD>", "</DD>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1626
                "<DIR>", "</DIR>", "<DT>", "</DT>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1627
                "<H1>", "</H1>", "<H2>", "</H2>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1628
                "<H3>", "</H3>", "<H4>", "</H4>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1629
                "<H5>", "</H5>", "<H6>", "</H6>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1630
                "<PRE>", "</PRE>", "<MENU>", "</MENU>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1631
                "<LISTING>", "</LISTING>", "<HR>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1632
                "<BLOCKQUOTE>", "</BLOCKQUOTE>",
06bc494ca11e Initial load
duke
parents:
diff changeset
  1633
                "<CENTER>", "</CENTER>"
06bc494ca11e Initial load
duke
parents:
diff changeset
  1634
        };
06bc494ca11e Initial load
duke
parents:
diff changeset
  1635
        for (int i = 0; i < noninlinetags.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1636
            text = replace(text, noninlinetags[i], "");
06bc494ca11e Initial load
duke
parents:
diff changeset
  1637
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1638
        return text;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1639
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1640
06bc494ca11e Initial load
duke
parents:
diff changeset
  1641
    public String replace(String text, String tobe, String by) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1642
        while (true) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1643
            int startindex = text.indexOf(tobe);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1644
            if (startindex < 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1645
                return text;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1646
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1647
            int endindex = startindex + tobe.length();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1648
            StringBuffer replaced = new StringBuffer();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1649
            if (startindex > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1650
                replaced.append(text.substring(0, startindex));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1651
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1652
            replaced.append(by);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1653
            if (text.length() > endindex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1654
                replaced.append(text.substring(endindex));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1655
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1656
            text = replaced.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1657
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1658
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1659
06bc494ca11e Initial load
duke
parents:
diff changeset
  1660
    public void printStyleSheetProperties() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1661
        String filename = configuration.stylesheetfile;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1662
        if (filename.length() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1663
            File stylefile = new File(filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1664
            String parent = stylefile.getParent();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1665
            filename = (parent == null)?
06bc494ca11e Initial load
duke
parents:
diff changeset
  1666
                filename:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1667
                filename.substring(parent.length() + 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1668
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1669
            filename = "stylesheet.css";
06bc494ca11e Initial load
duke
parents:
diff changeset
  1670
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1671
        filename = relativePath + filename;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1672
        link("REL =\"stylesheet\" TYPE=\"text/css\" HREF=\"" +
06bc494ca11e Initial load
duke
parents:
diff changeset
  1673
                 filename + "\" " + "TITLE=\"Style\"");
06bc494ca11e Initial load
duke
parents:
diff changeset
  1674
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1675
06bc494ca11e Initial load
duke
parents:
diff changeset
  1676
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1677
     * According to the Java Language Specifications, all the outer classes
06bc494ca11e Initial load
duke
parents:
diff changeset
  1678
     * and static nested classes are core classes.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1679
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1680
    public boolean isCoreClass(ClassDoc cd) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1681
        return cd.containingClass() == null || cd.isStatic();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1682
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1683
06bc494ca11e Initial load
duke
parents:
diff changeset
  1684
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1685
     * Write the annotatation types for the given packageDoc.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1686
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1687
     * @param packageDoc the package to write annotations for.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1688
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1689
    public void writeAnnotationInfo(PackageDoc packageDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1690
        writeAnnotationInfo(packageDoc, packageDoc.annotations());
06bc494ca11e Initial load
duke
parents:
diff changeset
  1691
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1692
06bc494ca11e Initial load
duke
parents:
diff changeset
  1693
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1694
     * Write the annotatation types for the given doc.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1695
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1696
     * @param doc the doc to write annotations for.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1697
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1698
    public void writeAnnotationInfo(ProgramElementDoc doc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1699
        writeAnnotationInfo(doc, doc.annotations());
06bc494ca11e Initial load
duke
parents:
diff changeset
  1700
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1701
06bc494ca11e Initial load
duke
parents:
diff changeset
  1702
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1703
     * Write the annotatation types for the given doc and parameter.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1704
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1705
     * @param indent the number of spaced to indent the parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1706
     * @param doc the doc to write annotations for.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1707
     * @param param the parameter to write annotations for.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1708
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1709
    public boolean writeAnnotationInfo(int indent, Doc doc, Parameter param) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1710
        return writeAnnotationInfo(indent, doc, param.annotations(), false);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1711
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1712
06bc494ca11e Initial load
duke
parents:
diff changeset
  1713
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1714
     * Write the annotatation types for the given doc.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1715
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1716
     * @param doc the doc to write annotations for.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1717
     * @param descList the array of {@link AnnotationDesc}.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1718
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1719
    private void writeAnnotationInfo(Doc doc, AnnotationDesc[] descList) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1720
        writeAnnotationInfo(0, doc, descList, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1721
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1722
06bc494ca11e Initial load
duke
parents:
diff changeset
  1723
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1724
     * Write the annotatation types for the given doc.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1725
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1726
     * @param indent the number of extra spaces to indent the annotations.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1727
     * @param doc the doc to write annotations for.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1728
     * @param descList the array of {@link AnnotationDesc}.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1729
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1730
    private boolean writeAnnotationInfo(int indent, Doc doc, AnnotationDesc[] descList, boolean lineBreak) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1731
        List annotations = getAnnotations(indent, descList, lineBreak);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1732
        if (annotations.size() == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1733
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1734
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1735
        fontNoNewLine("-1");
06bc494ca11e Initial load
duke
parents:
diff changeset
  1736
        for (Iterator iter = annotations.iterator(); iter.hasNext();) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1737
            print((String) iter.next());
06bc494ca11e Initial load
duke
parents:
diff changeset
  1738
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1739
        fontEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1740
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1741
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1742
06bc494ca11e Initial load
duke
parents:
diff changeset
  1743
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1744
     * Return the string representations of the annotation types for
06bc494ca11e Initial load
duke
parents:
diff changeset
  1745
     * the given doc.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1746
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1747
     * @param indent the number of extra spaces to indent the annotations.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1748
     * @param descList the array of {@link AnnotationDesc}.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1749
     * @param linkBreak if true, add new line between each member value.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1750
     * @return an array of strings representing the annotations being
06bc494ca11e Initial load
duke
parents:
diff changeset
  1751
     *         documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1752
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
  1753
    private List<String> getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
  1754
        List<String> results = new ArrayList<String>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1755
        StringBuffer annotation;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1756
        for (int i = 0; i < descList.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1757
            AnnotationTypeDoc annotationDoc = descList[i].annotationType();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1758
            if (! Util.isDocumentedAnnotation(annotationDoc)){
06bc494ca11e Initial load
duke
parents:
diff changeset
  1759
                continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1760
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1761
            annotation = new StringBuffer();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1762
            LinkInfoImpl linkInfo = new LinkInfoImpl(
06bc494ca11e Initial load
duke
parents:
diff changeset
  1763
                LinkInfoImpl.CONTEXT_ANNOTATION, annotationDoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1764
            linkInfo.label = "@" + annotationDoc.name();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1765
            annotation.append(getLink(linkInfo));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1766
            AnnotationDesc.ElementValuePair[] pairs = descList[i].elementValues();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1767
            if (pairs.length > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1768
                annotation.append('(');
06bc494ca11e Initial load
duke
parents:
diff changeset
  1769
                for (int j = 0; j < pairs.length; j++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1770
                    if (j > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1771
                        annotation.append(",");
06bc494ca11e Initial load
duke
parents:
diff changeset
  1772
                        if (linkBreak) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1773
                            annotation.append(DocletConstants.NL);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1774
                            int spaces = annotationDoc.name().length() + 2;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1775
                            for (int k = 0; k < (spaces + indent); k++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1776
                                annotation.append(' ');
06bc494ca11e Initial load
duke
parents:
diff changeset
  1777
                            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1778
                        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1779
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1780
                    annotation.append(getDocLink(LinkInfoImpl.CONTEXT_ANNOTATION,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1781
                        pairs[j].element(), pairs[j].element().name(), false));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1782
                    annotation.append('=');
06bc494ca11e Initial load
duke
parents:
diff changeset
  1783
                    AnnotationValue annotationValue = pairs[j].value();
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
  1784
                    List<AnnotationValue> annotationTypeValues = new ArrayList<AnnotationValue>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1785
                    if (annotationValue.value() instanceof AnnotationValue[]) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1786
                        AnnotationValue[] annotationArray =
06bc494ca11e Initial load
duke
parents:
diff changeset
  1787
                            (AnnotationValue[]) annotationValue.value();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1788
                        for (int k = 0; k < annotationArray.length; k++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1789
                            annotationTypeValues.add(annotationArray[k]);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1790
                        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1791
                    } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1792
                        annotationTypeValues.add(annotationValue);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1793
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1794
                    annotation.append(annotationTypeValues.size() == 1 ? "" : "{");
06bc494ca11e Initial load
duke
parents:
diff changeset
  1795
                    for (Iterator iter = annotationTypeValues.iterator(); iter.hasNext(); ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1796
                        annotation.append(annotationValueToString((AnnotationValue) iter.next()));
06bc494ca11e Initial load
duke
parents:
diff changeset
  1797
                        annotation.append(iter.hasNext() ? "," : "");
06bc494ca11e Initial load
duke
parents:
diff changeset
  1798
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1799
                    annotation.append(annotationTypeValues.size() == 1 ? "" : "}");
06bc494ca11e Initial load
duke
parents:
diff changeset
  1800
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1801
                annotation.append(")");
06bc494ca11e Initial load
duke
parents:
diff changeset
  1802
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1803
            annotation.append(linkBreak ? DocletConstants.NL : "");
06bc494ca11e Initial load
duke
parents:
diff changeset
  1804
            results.add(annotation.toString());
06bc494ca11e Initial load
duke
parents:
diff changeset
  1805
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1806
        return results;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1807
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1808
06bc494ca11e Initial load
duke
parents:
diff changeset
  1809
    private String annotationValueToString(AnnotationValue annotationValue) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1810
        if (annotationValue.value() instanceof Type) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1811
            Type type = (Type) annotationValue.value();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1812
            if (type.asClassDoc() != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1813
                LinkInfoImpl linkInfo = new LinkInfoImpl(
06bc494ca11e Initial load
duke
parents:
diff changeset
  1814
                    LinkInfoImpl.CONTEXT_ANNOTATION, type);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1815
                    linkInfo.label = (type.asClassDoc().isIncluded() ?
06bc494ca11e Initial load
duke
parents:
diff changeset
  1816
                        type.typeName() :
06bc494ca11e Initial load
duke
parents:
diff changeset
  1817
                        type.qualifiedTypeName()) + type.dimension() + ".class";
06bc494ca11e Initial load
duke
parents:
diff changeset
  1818
                return getLink(linkInfo);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1819
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1820
                return type.typeName() + type.dimension() + ".class";
06bc494ca11e Initial load
duke
parents:
diff changeset
  1821
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1822
        } else if (annotationValue.value() instanceof AnnotationDesc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1823
            List list = getAnnotations(0,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1824
                new AnnotationDesc[]{(AnnotationDesc) annotationValue.value()},
06bc494ca11e Initial load
duke
parents:
diff changeset
  1825
                    false);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1826
            StringBuffer buf = new StringBuffer();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1827
            for (Iterator iter = list.iterator(); iter.hasNext(); ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1828
                buf.append(iter.next());
06bc494ca11e Initial load
duke
parents:
diff changeset
  1829
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1830
            return buf.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1831
        } else if (annotationValue.value() instanceof MemberDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1832
            return getDocLink(LinkInfoImpl.CONTEXT_ANNOTATION,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1833
                (MemberDoc) annotationValue.value(),
06bc494ca11e Initial load
duke
parents:
diff changeset
  1834
                ((MemberDoc) annotationValue.value()).name(), false);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1835
         } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1836
            return annotationValue.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
  1837
         }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1838
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1839
06bc494ca11e Initial load
duke
parents:
diff changeset
  1840
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1841
     * Return the configuation for this doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1842
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1843
     * @return the configuration for this doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1844
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1845
    public Configuration configuration() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1846
        return configuration;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1847
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1848
}