Thu, 10 Jun 2010 17:09:56 -0700
6960407: Potential rebranding issues in openjdk/langtools repository sources
Reviewed-by: darcy
duke@1 | 1 | /* |
ohair@554 | 2 | * Copyright (c) 1997, 2005, Oracle and/or its affiliates. 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 |
ohair@554 | 7 | * published by the Free Software Foundation. Oracle designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@554 | 9 | * by Oracle 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 | * |
ohair@554 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 23 | * 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 |
bpatel@243 | 38 | * @author Bhavesh Patel (Modified) |
duke@1 | 39 | */ |
duke@1 | 40 | public class DeprecatedListWriter extends SubWriterHolderWriter { |
duke@1 | 41 | |
duke@1 | 42 | private static final String[] ANCHORS = new String[] { |
duke@1 | 43 | "interface", "class", "enum", "exception", "error", "annotation_type", |
duke@1 | 44 | "field", "method", "constructor", "enum_constant", |
duke@1 | 45 | "annotation_type_member" |
duke@1 | 46 | }; |
duke@1 | 47 | |
duke@1 | 48 | private static final String[] HEADING_KEYS = new String[] { |
duke@1 | 49 | "doclet.Deprecated_Interfaces", "doclet.Deprecated_Classes", |
duke@1 | 50 | "doclet.Deprecated_Enums", "doclet.Deprecated_Exceptions", |
duke@1 | 51 | "doclet.Deprecated_Errors", |
duke@1 | 52 | "doclet.Deprecated_Annotation_Types", |
duke@1 | 53 | "doclet.Deprecated_Fields", |
duke@1 | 54 | "doclet.Deprecated_Methods", "doclet.Deprecated_Constructors", |
duke@1 | 55 | "doclet.Deprecated_Enum_Constants", |
duke@1 | 56 | "doclet.Deprecated_Annotation_Type_Members" |
duke@1 | 57 | }; |
duke@1 | 58 | |
bpatel@243 | 59 | private static final String[] SUMMARY_KEYS = new String[] { |
bpatel@243 | 60 | "doclet.deprecated_interfaces", "doclet.deprecated_classes", |
bpatel@243 | 61 | "doclet.deprecated_enums", "doclet.deprecated_exceptions", |
bpatel@243 | 62 | "doclet.deprecated_errors", |
bpatel@243 | 63 | "doclet.deprecated_annotation_types", |
bpatel@243 | 64 | "doclet.deprecated_fields", |
bpatel@243 | 65 | "doclet.deprecated_methods", "doclet.deprecated_constructors", |
bpatel@243 | 66 | "doclet.deprecated_enum_constants", |
bpatel@243 | 67 | "doclet.deprecated_annotation_type_members" |
bpatel@243 | 68 | }; |
bpatel@243 | 69 | |
bpatel@243 | 70 | private static final String[] HEADER_KEYS = new String[] { |
bpatel@243 | 71 | "doclet.Interface", "doclet.Class", |
bpatel@243 | 72 | "doclet.Enum", "doclet.Exceptions", |
bpatel@243 | 73 | "doclet.Errors", |
bpatel@243 | 74 | "doclet.AnnotationType", |
bpatel@243 | 75 | "doclet.Field", |
bpatel@243 | 76 | "doclet.Method", "doclet.Constructor", |
bpatel@243 | 77 | "doclet.Enum_Constant", |
bpatel@243 | 78 | "doclet.Annotation_Type_Member" |
bpatel@243 | 79 | }; |
bpatel@243 | 80 | |
duke@1 | 81 | private AbstractMemberWriter[] writers; |
duke@1 | 82 | |
duke@1 | 83 | private ConfigurationImpl configuration; |
duke@1 | 84 | |
duke@1 | 85 | /** |
duke@1 | 86 | * Constructor. |
duke@1 | 87 | * |
duke@1 | 88 | * @param filename the file to be generated. |
duke@1 | 89 | */ |
duke@1 | 90 | public DeprecatedListWriter(ConfigurationImpl configuration, |
duke@1 | 91 | String filename) throws IOException { |
duke@1 | 92 | super(configuration, filename); |
duke@1 | 93 | this.configuration = configuration; |
duke@1 | 94 | NestedClassWriterImpl classW = new NestedClassWriterImpl(this); |
duke@1 | 95 | writers = new AbstractMemberWriter[] |
duke@1 | 96 | {classW, classW, classW, classW, classW, classW, |
duke@1 | 97 | new FieldWriterImpl(this), |
duke@1 | 98 | new MethodWriterImpl(this), |
duke@1 | 99 | new ConstructorWriterImpl(this), |
duke@1 | 100 | new EnumConstantWriterImpl(this), |
duke@1 | 101 | new AnnotationTypeOptionalMemberWriterImpl(this, null)}; |
duke@1 | 102 | } |
duke@1 | 103 | |
duke@1 | 104 | /** |
duke@1 | 105 | * Get list of all the deprecated classes and members in all the Packages |
duke@1 | 106 | * specified on the Command Line. |
duke@1 | 107 | * Then instantiate DeprecatedListWriter and generate File. |
duke@1 | 108 | * |
duke@1 | 109 | * @param configuration the current configuration of the doclet. |
duke@1 | 110 | */ |
duke@1 | 111 | public static void generate(ConfigurationImpl configuration) { |
duke@1 | 112 | String filename = "deprecated-list.html"; |
duke@1 | 113 | try { |
duke@1 | 114 | DeprecatedListWriter depr = |
duke@1 | 115 | new DeprecatedListWriter(configuration, filename); |
duke@1 | 116 | depr.generateDeprecatedListFile( |
duke@1 | 117 | new DeprecatedAPIListBuilder(configuration.root)); |
duke@1 | 118 | depr.close(); |
duke@1 | 119 | } catch (IOException exc) { |
duke@1 | 120 | configuration.standardmessage.error( |
duke@1 | 121 | "doclet.exception_encountered", |
duke@1 | 122 | exc.toString(), filename); |
duke@1 | 123 | throw new DocletAbortException(); |
duke@1 | 124 | } |
duke@1 | 125 | } |
duke@1 | 126 | |
duke@1 | 127 | /** |
duke@1 | 128 | * Print the deprecated API list. Separately print all class kinds and |
duke@1 | 129 | * member kinds. |
duke@1 | 130 | * |
duke@1 | 131 | * @param deprapi list of deprecated API built already. |
duke@1 | 132 | */ |
duke@1 | 133 | protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi) |
duke@1 | 134 | throws IOException { |
duke@1 | 135 | writeHeader(); |
duke@1 | 136 | |
bpatel@182 | 137 | strong(configuration.getText("doclet.Contents")); |
duke@1 | 138 | ul(); |
duke@1 | 139 | for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) { |
duke@1 | 140 | writeIndexLink(deprapi, i); |
duke@1 | 141 | } |
duke@1 | 142 | ulEnd(); |
duke@1 | 143 | println(); |
duke@1 | 144 | |
bpatel@243 | 145 | String memberTableSummary; |
bpatel@243 | 146 | String[] memberTableHeader = new String[1]; |
duke@1 | 147 | for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) { |
duke@1 | 148 | if (deprapi.hasDocumentation(i)) { |
duke@1 | 149 | writeAnchor(deprapi, i); |
bpatel@243 | 150 | memberTableSummary = |
bpatel@243 | 151 | configuration.getText("doclet.Member_Table_Summary", |
bpatel@243 | 152 | configuration.getText(HEADING_KEYS[i]), |
bpatel@243 | 153 | configuration.getText(SUMMARY_KEYS[i])); |
bpatel@243 | 154 | memberTableHeader[0] = configuration.getText("doclet.0_and_1", |
bpatel@243 | 155 | configuration.getText(HEADER_KEYS[i]), |
bpatel@243 | 156 | configuration.getText("doclet.Description")); |
duke@1 | 157 | writers[i].printDeprecatedAPI(deprapi.getList(i), |
bpatel@243 | 158 | HEADING_KEYS[i], memberTableSummary, memberTableHeader); |
duke@1 | 159 | } |
duke@1 | 160 | } |
duke@1 | 161 | printDeprecatedFooter(); |
duke@1 | 162 | } |
duke@1 | 163 | |
duke@1 | 164 | private void writeIndexLink(DeprecatedAPIListBuilder builder, |
duke@1 | 165 | int type) { |
duke@1 | 166 | if (builder.hasDocumentation(type)) { |
duke@1 | 167 | li(); |
duke@1 | 168 | printHyperLink("#" + ANCHORS[type], |
duke@1 | 169 | configuration.getText(HEADING_KEYS[type])); |
duke@1 | 170 | println(); |
duke@1 | 171 | } |
duke@1 | 172 | } |
duke@1 | 173 | |
duke@1 | 174 | private void writeAnchor(DeprecatedAPIListBuilder builder, int type) { |
duke@1 | 175 | if (builder.hasDocumentation(type)) { |
duke@1 | 176 | anchor(ANCHORS[type]); |
duke@1 | 177 | } |
duke@1 | 178 | } |
duke@1 | 179 | |
duke@1 | 180 | /** |
duke@1 | 181 | * Print the navigation bar and header for the deprecated API Listing. |
duke@1 | 182 | */ |
duke@1 | 183 | protected void writeHeader() { |
duke@1 | 184 | printHtmlHeader(configuration.getText("doclet.Window_Deprecated_List"), |
duke@1 | 185 | null, true); |
duke@1 | 186 | printTop(); |
duke@1 | 187 | navLinks(true); |
duke@1 | 188 | hr(); |
duke@1 | 189 | center(); |
duke@1 | 190 | h2(); |
bpatel@182 | 191 | strongText("doclet.Deprecated_API"); |
duke@1 | 192 | h2End(); |
duke@1 | 193 | centerEnd(); |
duke@1 | 194 | |
duke@1 | 195 | hr(4, "noshade"); |
duke@1 | 196 | } |
duke@1 | 197 | |
duke@1 | 198 | /** |
duke@1 | 199 | * Print the navigation bar and the footer for the deprecated API Listing. |
duke@1 | 200 | */ |
duke@1 | 201 | protected void printDeprecatedFooter() { |
duke@1 | 202 | hr(); |
duke@1 | 203 | navLinks(false); |
duke@1 | 204 | printBottom(); |
duke@1 | 205 | printBodyHtmlEnd(); |
duke@1 | 206 | } |
duke@1 | 207 | |
duke@1 | 208 | /** |
duke@1 | 209 | * Highlight the word "Deprecated" in the navigation bar as this is the same |
duke@1 | 210 | * page. |
duke@1 | 211 | */ |
duke@1 | 212 | protected void navLinkDeprecated() { |
duke@1 | 213 | navCellRevStart(); |
duke@1 | 214 | fontStyle("NavBarFont1Rev"); |
bpatel@182 | 215 | strongText("doclet.navDeprecated"); |
duke@1 | 216 | fontEnd(); |
duke@1 | 217 | navCellEnd(); |
duke@1 | 218 | } |
duke@1 | 219 | } |