src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java

Mon, 09 Mar 2009 23:53:41 -0700

author
tbell
date
Mon, 09 Mar 2009 23:53:41 -0700
changeset 240
8c55d5b0ed71
parent 182
47a62d8d98b4
child 243
edd944553131
permissions
-rw-r--r--

Merge

duke@1 1 /*
duke@1 2 * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
duke@1 7 * published by the Free Software Foundation. Sun designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
duke@1 9 * by Sun in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
duke@1 21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@1 22 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@1 23 * have any questions.
duke@1 24 */
duke@1 25
duke@1 26 package com.sun.tools.doclets.formats.html;
duke@1 27
duke@1 28 import com.sun.tools.doclets.internal.toolkit.util.DeprecatedAPIListBuilder;
duke@1 29 import com.sun.tools.doclets.internal.toolkit.util.*;
duke@1 30 import java.io.*;
duke@1 31
duke@1 32 /**
duke@1 33 * Generate File to list all the deprecated classes and class members with the
duke@1 34 * appropriate links.
duke@1 35 *
duke@1 36 * @see java.util.List
duke@1 37 * @author Atul M Dambalkar
duke@1 38 */
duke@1 39 public class DeprecatedListWriter extends SubWriterHolderWriter {
duke@1 40
duke@1 41 private static final String[] ANCHORS = new String[] {
duke@1 42 "interface", "class", "enum", "exception", "error", "annotation_type",
duke@1 43 "field", "method", "constructor", "enum_constant",
duke@1 44 "annotation_type_member"
duke@1 45 };
duke@1 46
duke@1 47 private static final String[] HEADING_KEYS = new String[] {
duke@1 48 "doclet.Deprecated_Interfaces", "doclet.Deprecated_Classes",
duke@1 49 "doclet.Deprecated_Enums", "doclet.Deprecated_Exceptions",
duke@1 50 "doclet.Deprecated_Errors",
duke@1 51 "doclet.Deprecated_Annotation_Types",
duke@1 52 "doclet.Deprecated_Fields",
duke@1 53 "doclet.Deprecated_Methods", "doclet.Deprecated_Constructors",
duke@1 54 "doclet.Deprecated_Enum_Constants",
duke@1 55 "doclet.Deprecated_Annotation_Type_Members"
duke@1 56 };
duke@1 57
duke@1 58 private AbstractMemberWriter[] writers;
duke@1 59
duke@1 60 private ConfigurationImpl configuration;
duke@1 61
duke@1 62 /**
duke@1 63 * Constructor.
duke@1 64 *
duke@1 65 * @param filename the file to be generated.
duke@1 66 */
duke@1 67 public DeprecatedListWriter(ConfigurationImpl configuration,
duke@1 68 String filename) throws IOException {
duke@1 69 super(configuration, filename);
duke@1 70 this.configuration = configuration;
duke@1 71 NestedClassWriterImpl classW = new NestedClassWriterImpl(this);
duke@1 72 writers = new AbstractMemberWriter[]
duke@1 73 {classW, classW, classW, classW, classW, classW,
duke@1 74 new FieldWriterImpl(this),
duke@1 75 new MethodWriterImpl(this),
duke@1 76 new ConstructorWriterImpl(this),
duke@1 77 new EnumConstantWriterImpl(this),
duke@1 78 new AnnotationTypeOptionalMemberWriterImpl(this, null)};
duke@1 79 }
duke@1 80
duke@1 81 /**
duke@1 82 * Get list of all the deprecated classes and members in all the Packages
duke@1 83 * specified on the Command Line.
duke@1 84 * Then instantiate DeprecatedListWriter and generate File.
duke@1 85 *
duke@1 86 * @param configuration the current configuration of the doclet.
duke@1 87 */
duke@1 88 public static void generate(ConfigurationImpl configuration) {
duke@1 89 String filename = "deprecated-list.html";
duke@1 90 try {
duke@1 91 DeprecatedListWriter depr =
duke@1 92 new DeprecatedListWriter(configuration, filename);
duke@1 93 depr.generateDeprecatedListFile(
duke@1 94 new DeprecatedAPIListBuilder(configuration.root));
duke@1 95 depr.close();
duke@1 96 } catch (IOException exc) {
duke@1 97 configuration.standardmessage.error(
duke@1 98 "doclet.exception_encountered",
duke@1 99 exc.toString(), filename);
duke@1 100 throw new DocletAbortException();
duke@1 101 }
duke@1 102 }
duke@1 103
duke@1 104 /**
duke@1 105 * Print the deprecated API list. Separately print all class kinds and
duke@1 106 * member kinds.
duke@1 107 *
duke@1 108 * @param deprapi list of deprecated API built already.
duke@1 109 */
duke@1 110 protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi)
duke@1 111 throws IOException {
duke@1 112 writeHeader();
duke@1 113
bpatel@182 114 strong(configuration.getText("doclet.Contents"));
duke@1 115 ul();
duke@1 116 for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
duke@1 117 writeIndexLink(deprapi, i);
duke@1 118 }
duke@1 119 ulEnd();
duke@1 120 println();
duke@1 121
duke@1 122 for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
duke@1 123 if (deprapi.hasDocumentation(i)) {
duke@1 124 writeAnchor(deprapi, i);
duke@1 125 writers[i].printDeprecatedAPI(deprapi.getList(i),
duke@1 126 HEADING_KEYS[i]);
duke@1 127 }
duke@1 128 }
duke@1 129 printDeprecatedFooter();
duke@1 130 }
duke@1 131
duke@1 132 private void writeIndexLink(DeprecatedAPIListBuilder builder,
duke@1 133 int type) {
duke@1 134 if (builder.hasDocumentation(type)) {
duke@1 135 li();
duke@1 136 printHyperLink("#" + ANCHORS[type],
duke@1 137 configuration.getText(HEADING_KEYS[type]));
duke@1 138 println();
duke@1 139 }
duke@1 140 }
duke@1 141
duke@1 142 private void writeAnchor(DeprecatedAPIListBuilder builder, int type) {
duke@1 143 if (builder.hasDocumentation(type)) {
duke@1 144 anchor(ANCHORS[type]);
duke@1 145 }
duke@1 146 }
duke@1 147
duke@1 148 /**
duke@1 149 * Print the navigation bar and header for the deprecated API Listing.
duke@1 150 */
duke@1 151 protected void writeHeader() {
duke@1 152 printHtmlHeader(configuration.getText("doclet.Window_Deprecated_List"),
duke@1 153 null, true);
duke@1 154 printTop();
duke@1 155 navLinks(true);
duke@1 156 hr();
duke@1 157 center();
duke@1 158 h2();
bpatel@182 159 strongText("doclet.Deprecated_API");
duke@1 160 h2End();
duke@1 161 centerEnd();
duke@1 162
duke@1 163 hr(4, "noshade");
duke@1 164 }
duke@1 165
duke@1 166 /**
duke@1 167 * Print the navigation bar and the footer for the deprecated API Listing.
duke@1 168 */
duke@1 169 protected void printDeprecatedFooter() {
duke@1 170 hr();
duke@1 171 navLinks(false);
duke@1 172 printBottom();
duke@1 173 printBodyHtmlEnd();
duke@1 174 }
duke@1 175
duke@1 176 /**
duke@1 177 * Highlight the word "Deprecated" in the navigation bar as this is the same
duke@1 178 * page.
duke@1 179 */
duke@1 180 protected void navLinkDeprecated() {
duke@1 181 navCellRevStart();
duke@1 182 fontStyle("NavBarFont1Rev");
bpatel@182 183 strongText("doclet.navDeprecated");
duke@1 184 fontEnd();
duke@1 185 navCellEnd();
duke@1 186 }
duke@1 187 }

mercurial