DeprecatedListWriter.java revision 0
0N/A/*
0N/A * Copyright 1997-2005 Sun Microsystems, Inc. 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
0N/A * published by the Free Software Foundation. Sun designates this
0N/A * particular file as subject to the "Classpath" exception as provided
0N/A * by Sun 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 *
0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0N/A * CA 95054 USA or visit www.sun.com if you need additional information or
0N/A * have any 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
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
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
0N/A bold(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
0N/A for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
0N/A if (deprapi.hasDocumentation(i)) {
0N/A writeAnchor(deprapi, i);
0N/A writers[i].printDeprecatedAPI(deprapi.getList(i),
0N/A HEADING_KEYS[i]);
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();
0N/A boldText("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");
0N/A boldText("doclet.navDeprecated");
0N/A fontEnd();
0N/A navCellEnd();
0N/A }
0N/A}