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