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