langtools/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java
author bpatel
Thu, 08 Jan 2009 16:26:59 -0800
changeset 1787 1aa079321cd2
parent 10 06bc494ca11e
child 2320 5b8c377175f4
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
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2005 Sun Microsystems, Inc.  All Rights Reserved.
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
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import com.sun.tools.doclets.internal.toolkit.util.DeprecatedAPIListBuilder;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.tools.doclets.internal.toolkit.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.io.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * Generate File to list all the deprecated classes and class members with the
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * appropriate links.
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * @see java.util.List
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
public class DeprecatedListWriter extends SubWriterHolderWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
    private static final String[] ANCHORS = new String[] {
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
        "interface", "class", "enum", "exception", "error", "annotation_type",
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
         "field", "method", "constructor", "enum_constant",
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
        "annotation_type_member"
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
    };
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
    private static final String[] HEADING_KEYS = new String[] {
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
        "doclet.Deprecated_Interfaces", "doclet.Deprecated_Classes",
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
        "doclet.Deprecated_Enums", "doclet.Deprecated_Exceptions",
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
        "doclet.Deprecated_Errors",
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
        "doclet.Deprecated_Annotation_Types",
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
        "doclet.Deprecated_Fields",
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
        "doclet.Deprecated_Methods", "doclet.Deprecated_Constructors",
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
        "doclet.Deprecated_Enum_Constants",
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
        "doclet.Deprecated_Annotation_Type_Members"
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    };
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    private AbstractMemberWriter[] writers;
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    private ConfigurationImpl configuration;
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     * Constructor.
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
     * @param filename the file to be generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    public DeprecatedListWriter(ConfigurationImpl configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
                                String filename) throws IOException {
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
        super(configuration, filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
        this.configuration = configuration;
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
        NestedClassWriterImpl classW = new NestedClassWriterImpl(this);
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
        writers = new AbstractMemberWriter[]
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
            {classW, classW, classW, classW, classW, classW,
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
            new FieldWriterImpl(this),
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
            new MethodWriterImpl(this),
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
            new ConstructorWriterImpl(this),
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
            new EnumConstantWriterImpl(this),
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
            new AnnotationTypeOptionalMemberWriterImpl(this, null)};
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     * Get list of all the deprecated classes and members in all the Packages
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
     * specified on the Command Line.
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
     * Then instantiate DeprecatedListWriter and generate File.
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     * @param configuration the current configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    public static void generate(ConfigurationImpl configuration) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
        String filename = "deprecated-list.html";
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
            DeprecatedListWriter depr =
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
                   new DeprecatedListWriter(configuration, filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
            depr.generateDeprecatedListFile(
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
                   new DeprecatedAPIListBuilder(configuration.root));
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
            depr.close();
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
        } catch (IOException exc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
            configuration.standardmessage.error(
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
                        "doclet.exception_encountered",
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
                        exc.toString(), filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
            throw new DocletAbortException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     * Print the deprecated API list. Separately print all class kinds and
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     * member kinds.
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     * @param deprapi list of deprecated API built already.
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
    protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi)
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
             throws IOException {
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
        writeHeader();
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   114
        strong(configuration.getText("doclet.Contents"));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
        ul();
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
        for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
            writeIndexLink(deprapi, i);
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
        ulEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
        println();
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
            if (deprapi.hasDocumentation(i)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
                writeAnchor(deprapi, i);
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
                writers[i].printDeprecatedAPI(deprapi.getList(i),
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
                    HEADING_KEYS[i]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
        printDeprecatedFooter();
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
    private void writeIndexLink(DeprecatedAPIListBuilder builder,
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
            int type) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
        if (builder.hasDocumentation(type)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
            li();
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
            printHyperLink("#" + ANCHORS[type],
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
                configuration.getText(HEADING_KEYS[type]));
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
            println();
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
    private void writeAnchor(DeprecatedAPIListBuilder builder, int type) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        if (builder.hasDocumentation(type)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
            anchor(ANCHORS[type]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
     * Print the navigation bar and header for the deprecated API Listing.
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
    protected void writeHeader() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        printHtmlHeader(configuration.getText("doclet.Window_Deprecated_List"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
            null, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        printTop();
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
        navLinks(true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        hr();
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
        center();
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
        h2();
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   159
        strongText("doclet.Deprecated_API");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
        h2End();
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        centerEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        hr(4, "noshade");
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
     * Print the navigation bar and the footer for the deprecated API Listing.
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
    protected void printDeprecatedFooter() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
        hr();
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
        navLinks(false);
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
        printBottom();
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
        printBodyHtmlEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
     * Highlight the word "Deprecated" in the navigation bar as this is the same
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
     * page.
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
    protected void navLinkDeprecated() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
        navCellRevStart();
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
        fontStyle("NavBarFont1Rev");
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   183
        strongText("doclet.navDeprecated");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
        fontEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
        navCellEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
}