001: /*
002: * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.tools.doclets.formats.html;
027:
028: import com.sun.tools.doclets.internal.toolkit.util.DeprecatedAPIListBuilder;
029: import com.sun.tools.doclets.internal.toolkit.util.*;
030: import java.io.*;
031:
032: /**
033: * Generate File to list all the deprecated classes and class members with the
034: * appropriate links.
035: *
036: * @see java.util.List
037: * @author Atul M Dambalkar
038: */
039: public class DeprecatedListWriter extends SubWriterHolderWriter {
040:
041: private static final String[] ANCHORS = new String[] { "interface",
042: "class", "enum", "exception", "error", "annotation_type",
043: "field", "method", "constructor", "enum_constant",
044: "annotation_type_member" };
045:
046: private static final String[] HEADING_KEYS = new String[] {
047: "doclet.Deprecated_Interfaces",
048: "doclet.Deprecated_Classes", "doclet.Deprecated_Enums",
049: "doclet.Deprecated_Exceptions", "doclet.Deprecated_Errors",
050: "doclet.Deprecated_Annotation_Types",
051: "doclet.Deprecated_Fields", "doclet.Deprecated_Methods",
052: "doclet.Deprecated_Constructors",
053: "doclet.Deprecated_Enum_Constants",
054: "doclet.Deprecated_Annotation_Type_Members" };
055:
056: private AbstractMemberWriter[] writers;
057:
058: private ConfigurationImpl configuration;
059:
060: /**
061: * Constructor.
062: *
063: * @param filename the file to be generated.
064: */
065: public DeprecatedListWriter(ConfigurationImpl configuration,
066: String filename) throws IOException {
067: super (configuration, filename);
068: this .configuration = configuration;
069: NestedClassWriterImpl classW = new NestedClassWriterImpl(this );
070: writers = new AbstractMemberWriter[] { classW, classW, classW,
071: classW, classW, classW, new FieldWriterImpl(this ),
072: new MethodWriterImpl(this ),
073: new ConstructorWriterImpl(this ),
074: new EnumConstantWriterImpl(this ),
075: new AnnotationTypeOptionalMemberWriterImpl(this , null) };
076: }
077:
078: /**
079: * Get list of all the deprecated classes and members in all the Packages
080: * specified on the Command Line.
081: * Then instantiate DeprecatedListWriter and generate File.
082: *
083: * @param configuration the current configuration of the doclet.
084: */
085: public static void generate(ConfigurationImpl configuration) {
086: String filename = "deprecated-list.html";
087: try {
088: DeprecatedListWriter depr = new DeprecatedListWriter(
089: configuration, filename);
090: depr
091: .generateDeprecatedListFile(new DeprecatedAPIListBuilder(
092: configuration.root));
093: depr.close();
094: } catch (IOException exc) {
095: configuration.standardmessage.error(
096: "doclet.exception_encountered", exc.toString(),
097: filename);
098: throw new DocletAbortException();
099: }
100: }
101:
102: /**
103: * Print the deprecated API list. Separately print all class kinds and
104: * member kinds.
105: *
106: * @param deprapi list of deprecated API built already.
107: */
108: protected void generateDeprecatedListFile(
109: DeprecatedAPIListBuilder deprapi) throws IOException {
110: writeHeader();
111:
112: bold(configuration.getText("doclet.Contents"));
113: ul();
114: for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
115: writeIndexLink(deprapi, i);
116: }
117: ulEnd();
118: println();
119:
120: for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
121: if (deprapi.hasDocumentation(i)) {
122: writeAnchor(deprapi, i);
123: writers[i].printDeprecatedAPI(deprapi.getList(i),
124: HEADING_KEYS[i]);
125: }
126: }
127: printDeprecatedFooter();
128: }
129:
130: private void writeIndexLink(DeprecatedAPIListBuilder builder,
131: int type) {
132: if (builder.hasDocumentation(type)) {
133: li();
134: printHyperLink("#" + ANCHORS[type], configuration
135: .getText(HEADING_KEYS[type]));
136: println();
137: }
138: }
139:
140: private void writeAnchor(DeprecatedAPIListBuilder builder, int type) {
141: if (builder.hasDocumentation(type)) {
142: anchor(ANCHORS[type]);
143: }
144: }
145:
146: /**
147: * Print the navigation bar and header for the deprecated API Listing.
148: */
149: protected void writeHeader() {
150: printHtmlHeader(configuration
151: .getText("doclet.Window_Deprecated_List"), null, true);
152: printTop();
153: navLinks(true);
154: hr();
155: center();
156: h2();
157: boldText("doclet.Deprecated_API");
158: h2End();
159: centerEnd();
160:
161: hr(4, "noshade");
162: }
163:
164: /**
165: * Print the navigation bar and the footer for the deprecated API Listing.
166: */
167: protected void printDeprecatedFooter() {
168: hr();
169: navLinks(false);
170: printBottom();
171: printBodyHtmlEnd();
172: }
173:
174: /**
175: * Highlight the word "Deprecated" in the navigation bar as this is the same
176: * page.
177: */
178: protected void navLinkDeprecated() {
179: navCellRevStart();
180: fontStyle("NavBarFont1Rev");
181: boldText("doclet.navDeprecated");
182: fontEnd();
183: navCellEnd();
184: }
185: }
|