duke@1: /* ohair@554: * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as ohair@554: * published by the Free Software Foundation. Oracle designates this duke@1: * particular file as subject to the "Classpath" exception as provided ohair@554: * by Oracle in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. duke@1: */ duke@1: duke@1: package com.sun.tools.doclets.formats.html; duke@1: duke@1: import com.sun.tools.doclets.internal.toolkit.util.DeprecatedAPIListBuilder; duke@1: import com.sun.tools.doclets.internal.toolkit.util.*; duke@1: import java.io.*; duke@1: duke@1: /** duke@1: * Generate File to list all the deprecated classes and class members with the duke@1: * appropriate links. duke@1: * duke@1: * @see java.util.List duke@1: * @author Atul M Dambalkar bpatel@243: * @author Bhavesh Patel (Modified) duke@1: */ duke@1: public class DeprecatedListWriter extends SubWriterHolderWriter { duke@1: duke@1: private static final String[] ANCHORS = new String[] { duke@1: "interface", "class", "enum", "exception", "error", "annotation_type", duke@1: "field", "method", "constructor", "enum_constant", duke@1: "annotation_type_member" duke@1: }; duke@1: duke@1: private static final String[] HEADING_KEYS = new String[] { duke@1: "doclet.Deprecated_Interfaces", "doclet.Deprecated_Classes", duke@1: "doclet.Deprecated_Enums", "doclet.Deprecated_Exceptions", duke@1: "doclet.Deprecated_Errors", duke@1: "doclet.Deprecated_Annotation_Types", duke@1: "doclet.Deprecated_Fields", duke@1: "doclet.Deprecated_Methods", "doclet.Deprecated_Constructors", duke@1: "doclet.Deprecated_Enum_Constants", duke@1: "doclet.Deprecated_Annotation_Type_Members" duke@1: }; duke@1: bpatel@243: private static final String[] SUMMARY_KEYS = new String[] { bpatel@243: "doclet.deprecated_interfaces", "doclet.deprecated_classes", bpatel@243: "doclet.deprecated_enums", "doclet.deprecated_exceptions", bpatel@243: "doclet.deprecated_errors", bpatel@243: "doclet.deprecated_annotation_types", bpatel@243: "doclet.deprecated_fields", bpatel@243: "doclet.deprecated_methods", "doclet.deprecated_constructors", bpatel@243: "doclet.deprecated_enum_constants", bpatel@243: "doclet.deprecated_annotation_type_members" bpatel@243: }; bpatel@243: bpatel@243: private static final String[] HEADER_KEYS = new String[] { bpatel@243: "doclet.Interface", "doclet.Class", bpatel@243: "doclet.Enum", "doclet.Exceptions", bpatel@243: "doclet.Errors", bpatel@243: "doclet.AnnotationType", bpatel@243: "doclet.Field", bpatel@243: "doclet.Method", "doclet.Constructor", bpatel@243: "doclet.Enum_Constant", bpatel@243: "doclet.Annotation_Type_Member" bpatel@243: }; bpatel@243: duke@1: private AbstractMemberWriter[] writers; duke@1: duke@1: private ConfigurationImpl configuration; duke@1: duke@1: /** duke@1: * Constructor. duke@1: * duke@1: * @param filename the file to be generated. duke@1: */ duke@1: public DeprecatedListWriter(ConfigurationImpl configuration, duke@1: String filename) throws IOException { duke@1: super(configuration, filename); duke@1: this.configuration = configuration; duke@1: NestedClassWriterImpl classW = new NestedClassWriterImpl(this); duke@1: writers = new AbstractMemberWriter[] duke@1: {classW, classW, classW, classW, classW, classW, duke@1: new FieldWriterImpl(this), duke@1: new MethodWriterImpl(this), duke@1: new ConstructorWriterImpl(this), duke@1: new EnumConstantWriterImpl(this), duke@1: new AnnotationTypeOptionalMemberWriterImpl(this, null)}; duke@1: } duke@1: duke@1: /** duke@1: * Get list of all the deprecated classes and members in all the Packages duke@1: * specified on the Command Line. duke@1: * Then instantiate DeprecatedListWriter and generate File. duke@1: * duke@1: * @param configuration the current configuration of the doclet. duke@1: */ duke@1: public static void generate(ConfigurationImpl configuration) { duke@1: String filename = "deprecated-list.html"; duke@1: try { duke@1: DeprecatedListWriter depr = duke@1: new DeprecatedListWriter(configuration, filename); duke@1: depr.generateDeprecatedListFile( duke@1: new DeprecatedAPIListBuilder(configuration.root)); duke@1: depr.close(); duke@1: } catch (IOException exc) { duke@1: configuration.standardmessage.error( duke@1: "doclet.exception_encountered", duke@1: exc.toString(), filename); duke@1: throw new DocletAbortException(); duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * Print the deprecated API list. Separately print all class kinds and duke@1: * member kinds. duke@1: * duke@1: * @param deprapi list of deprecated API built already. duke@1: */ duke@1: protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi) duke@1: throws IOException { duke@1: writeHeader(); duke@1: bpatel@182: strong(configuration.getText("doclet.Contents")); duke@1: ul(); duke@1: for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) { duke@1: writeIndexLink(deprapi, i); duke@1: } duke@1: ulEnd(); duke@1: println(); duke@1: bpatel@243: String memberTableSummary; bpatel@243: String[] memberTableHeader = new String[1]; duke@1: for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) { duke@1: if (deprapi.hasDocumentation(i)) { duke@1: writeAnchor(deprapi, i); bpatel@243: memberTableSummary = bpatel@243: configuration.getText("doclet.Member_Table_Summary", bpatel@243: configuration.getText(HEADING_KEYS[i]), bpatel@243: configuration.getText(SUMMARY_KEYS[i])); bpatel@243: memberTableHeader[0] = configuration.getText("doclet.0_and_1", bpatel@243: configuration.getText(HEADER_KEYS[i]), bpatel@243: configuration.getText("doclet.Description")); duke@1: writers[i].printDeprecatedAPI(deprapi.getList(i), bpatel@243: HEADING_KEYS[i], memberTableSummary, memberTableHeader); duke@1: } duke@1: } duke@1: printDeprecatedFooter(); duke@1: } duke@1: duke@1: private void writeIndexLink(DeprecatedAPIListBuilder builder, duke@1: int type) { duke@1: if (builder.hasDocumentation(type)) { duke@1: li(); duke@1: printHyperLink("#" + ANCHORS[type], duke@1: configuration.getText(HEADING_KEYS[type])); duke@1: println(); duke@1: } duke@1: } duke@1: duke@1: private void writeAnchor(DeprecatedAPIListBuilder builder, int type) { duke@1: if (builder.hasDocumentation(type)) { duke@1: anchor(ANCHORS[type]); duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * Print the navigation bar and header for the deprecated API Listing. duke@1: */ duke@1: protected void writeHeader() { duke@1: printHtmlHeader(configuration.getText("doclet.Window_Deprecated_List"), duke@1: null, true); duke@1: printTop(); duke@1: navLinks(true); duke@1: hr(); duke@1: center(); duke@1: h2(); bpatel@182: strongText("doclet.Deprecated_API"); duke@1: h2End(); duke@1: centerEnd(); duke@1: duke@1: hr(4, "noshade"); duke@1: } duke@1: duke@1: /** duke@1: * Print the navigation bar and the footer for the deprecated API Listing. duke@1: */ duke@1: protected void printDeprecatedFooter() { duke@1: hr(); duke@1: navLinks(false); duke@1: printBottom(); duke@1: printBodyHtmlEnd(); duke@1: } duke@1: duke@1: /** duke@1: * Highlight the word "Deprecated" in the navigation bar as this is the same duke@1: * page. duke@1: */ duke@1: protected void navLinkDeprecated() { duke@1: navCellRevStart(); duke@1: fontStyle("NavBarFont1Rev"); bpatel@182: strongText("doclet.navDeprecated"); duke@1: fontEnd(); duke@1: navCellEnd(); duke@1: } duke@1: }