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

Tue, 09 Oct 2012 19:31:58 -0700

author
jjg
date
Tue, 09 Oct 2012 19:31:58 -0700
changeset 1358
fc123bdeddb8
parent 1357
c75be5bc5283
child 1359
25e14ad23cef
permissions
-rw-r--r--

8000208: fix langtools javadoc comment issues
Reviewed-by: bpatel, mcimadamore

duke@1 1 /*
jjg@1357 2 * Copyright (c) 1997, 2012, 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
bpatel@766 28 import java.io.*;
jjg@1357 29
jjg@1357 30 import com.sun.tools.doclets.formats.html.markup.*;
bpatel@766 31 import com.sun.tools.doclets.internal.toolkit.*;
duke@1 32 import com.sun.tools.doclets.internal.toolkit.util.*;
duke@1 33
duke@1 34 /**
duke@1 35 * Generate File to list all the deprecated classes and class members with the
duke@1 36 * appropriate links.
duke@1 37 *
duke@1 38 * @see java.util.List
duke@1 39 * @author Atul M Dambalkar
bpatel@243 40 * @author Bhavesh Patel (Modified)
duke@1 41 */
duke@1 42 public class DeprecatedListWriter extends SubWriterHolderWriter {
duke@1 43
duke@1 44 private static final String[] ANCHORS = new String[] {
bpatel@995 45 "package", "interface", "class", "enum", "exception", "error",
bpatel@995 46 "annotation_type", "field", "method", "constructor", "enum_constant",
duke@1 47 "annotation_type_member"
duke@1 48 };
duke@1 49
duke@1 50 private static final String[] HEADING_KEYS = new String[] {
bpatel@995 51 "doclet.Deprecated_Packages", "doclet.Deprecated_Interfaces",
bpatel@995 52 "doclet.Deprecated_Classes", "doclet.Deprecated_Enums",
bpatel@995 53 "doclet.Deprecated_Exceptions", "doclet.Deprecated_Errors",
duke@1 54 "doclet.Deprecated_Annotation_Types",
duke@1 55 "doclet.Deprecated_Fields",
duke@1 56 "doclet.Deprecated_Methods", "doclet.Deprecated_Constructors",
duke@1 57 "doclet.Deprecated_Enum_Constants",
duke@1 58 "doclet.Deprecated_Annotation_Type_Members"
duke@1 59 };
duke@1 60
bpatel@243 61 private static final String[] SUMMARY_KEYS = new String[] {
bpatel@995 62 "doclet.deprecated_packages", "doclet.deprecated_interfaces",
bpatel@995 63 "doclet.deprecated_classes", "doclet.deprecated_enums",
bpatel@995 64 "doclet.deprecated_exceptions", "doclet.deprecated_errors",
bpatel@243 65 "doclet.deprecated_annotation_types",
bpatel@243 66 "doclet.deprecated_fields",
bpatel@243 67 "doclet.deprecated_methods", "doclet.deprecated_constructors",
bpatel@243 68 "doclet.deprecated_enum_constants",
bpatel@243 69 "doclet.deprecated_annotation_type_members"
bpatel@243 70 };
bpatel@243 71
bpatel@243 72 private static final String[] HEADER_KEYS = new String[] {
bpatel@995 73 "doclet.Package", "doclet.Interface", "doclet.Class",
bpatel@243 74 "doclet.Enum", "doclet.Exceptions",
bpatel@243 75 "doclet.Errors",
bpatel@243 76 "doclet.AnnotationType",
bpatel@243 77 "doclet.Field",
bpatel@243 78 "doclet.Method", "doclet.Constructor",
bpatel@243 79 "doclet.Enum_Constant",
bpatel@243 80 "doclet.Annotation_Type_Member"
bpatel@243 81 };
bpatel@243 82
duke@1 83 private AbstractMemberWriter[] writers;
duke@1 84
duke@1 85 private ConfigurationImpl configuration;
duke@1 86
duke@1 87 /**
duke@1 88 * Constructor.
duke@1 89 *
duke@1 90 * @param filename the file to be generated.
duke@1 91 */
duke@1 92 public DeprecatedListWriter(ConfigurationImpl configuration,
duke@1 93 String filename) throws IOException {
duke@1 94 super(configuration, filename);
duke@1 95 this.configuration = configuration;
duke@1 96 NestedClassWriterImpl classW = new NestedClassWriterImpl(this);
duke@1 97 writers = new AbstractMemberWriter[]
duke@1 98 {classW, classW, classW, classW, classW, classW,
duke@1 99 new FieldWriterImpl(this),
duke@1 100 new MethodWriterImpl(this),
duke@1 101 new ConstructorWriterImpl(this),
duke@1 102 new EnumConstantWriterImpl(this),
duke@1 103 new AnnotationTypeOptionalMemberWriterImpl(this, null)};
duke@1 104 }
duke@1 105
duke@1 106 /**
duke@1 107 * Get list of all the deprecated classes and members in all the Packages
duke@1 108 * specified on the Command Line.
duke@1 109 * Then instantiate DeprecatedListWriter and generate File.
duke@1 110 *
duke@1 111 * @param configuration the current configuration of the doclet.
duke@1 112 */
duke@1 113 public static void generate(ConfigurationImpl configuration) {
duke@1 114 String filename = "deprecated-list.html";
duke@1 115 try {
duke@1 116 DeprecatedListWriter depr =
duke@1 117 new DeprecatedListWriter(configuration, filename);
duke@1 118 depr.generateDeprecatedListFile(
bpatel@995 119 new DeprecatedAPIListBuilder(configuration));
duke@1 120 depr.close();
duke@1 121 } catch (IOException exc) {
duke@1 122 configuration.standardmessage.error(
duke@1 123 "doclet.exception_encountered",
duke@1 124 exc.toString(), filename);
duke@1 125 throw new DocletAbortException();
duke@1 126 }
duke@1 127 }
duke@1 128
duke@1 129 /**
bpatel@766 130 * Generate the deprecated API list.
duke@1 131 *
duke@1 132 * @param deprapi list of deprecated API built already.
duke@1 133 */
duke@1 134 protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi)
bpatel@766 135 throws IOException {
bpatel@766 136 Content body = getHeader();
bpatel@766 137 body.addContent(getContentsList(deprapi));
bpatel@243 138 String memberTableSummary;
bpatel@243 139 String[] memberTableHeader = new String[1];
bpatel@766 140 HtmlTree div = new HtmlTree(HtmlTag.DIV);
bpatel@766 141 div.addStyle(HtmlStyle.contentContainer);
duke@1 142 for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
duke@1 143 if (deprapi.hasDocumentation(i)) {
bpatel@766 144 addAnchor(deprapi, i, div);
bpatel@243 145 memberTableSummary =
bpatel@243 146 configuration.getText("doclet.Member_Table_Summary",
bpatel@243 147 configuration.getText(HEADING_KEYS[i]),
bpatel@243 148 configuration.getText(SUMMARY_KEYS[i]));
bpatel@243 149 memberTableHeader[0] = configuration.getText("doclet.0_and_1",
bpatel@243 150 configuration.getText(HEADER_KEYS[i]),
bpatel@243 151 configuration.getText("doclet.Description"));
bpatel@995 152 // DeprecatedAPIListBuilder.PACKAGE == 0, so if i == 0, it is
bpatel@995 153 // a PackageDoc.
bpatel@995 154 if (i == DeprecatedAPIListBuilder.PACKAGE)
bpatel@995 155 addPackageDeprecatedAPI(deprapi.getList(i),
bpatel@995 156 HEADING_KEYS[i], memberTableSummary, memberTableHeader, div);
bpatel@995 157 else
bpatel@995 158 writers[i - 1].addDeprecatedAPI(deprapi.getList(i),
bpatel@995 159 HEADING_KEYS[i], memberTableSummary, memberTableHeader, div);
duke@1 160 }
duke@1 161 }
bpatel@766 162 body.addContent(div);
bpatel@766 163 addNavLinks(false, body);
bpatel@766 164 addBottom(body);
bpatel@766 165 printHtmlDocument(null, true, body);
duke@1 166 }
duke@1 167
bpatel@766 168 /**
bpatel@766 169 * Add the index link.
bpatel@766 170 *
bpatel@766 171 * @param builder the deprecated list builder
bpatel@766 172 * @param type the type of list being documented
bpatel@766 173 * @param contentTree the content tree to which the index link will be added
bpatel@766 174 */
bpatel@766 175 private void addIndexLink(DeprecatedAPIListBuilder builder,
bpatel@766 176 int type, Content contentTree) {
duke@1 177 if (builder.hasDocumentation(type)) {
bpatel@766 178 Content li = HtmlTree.LI(getHyperLink("#" + ANCHORS[type],
bpatel@766 179 getResource(HEADING_KEYS[type])));
bpatel@766 180 contentTree.addContent(li);
duke@1 181 }
duke@1 182 }
duke@1 183
duke@1 184 /**
bpatel@766 185 * Get the contents list.
bpatel@766 186 *
bpatel@766 187 * @param deprapi the deprecated list builder
bpatel@766 188 * @return a content tree for the contents list
duke@1 189 */
bpatel@766 190 public Content getContentsList(DeprecatedAPIListBuilder deprapi) {
bpatel@766 191 Content headContent = getResource("doclet.Deprecated_API");
bpatel@766 192 Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
bpatel@766 193 HtmlStyle.title, headContent);
bpatel@766 194 Content div = HtmlTree.DIV(HtmlStyle.header, heading);
bpatel@766 195 Content headingContent = getResource("doclet.Contents");
bpatel@766 196 div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
bpatel@766 197 headingContent));
bpatel@766 198 Content ul = new HtmlTree(HtmlTag.UL);
bpatel@766 199 for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
bpatel@766 200 addIndexLink(deprapi, i, ul);
bpatel@766 201 }
bpatel@766 202 div.addContent(ul);
bpatel@766 203 return div;
duke@1 204 }
duke@1 205
duke@1 206 /**
bpatel@766 207 * Add the anchor.
bpatel@766 208 *
bpatel@766 209 * @param builder the deprecated list builder
bpatel@766 210 * @param type the type of list being documented
jjg@1358 211 * @param htmlTree the content tree to which the anchor will be added
duke@1 212 */
bpatel@766 213 private void addAnchor(DeprecatedAPIListBuilder builder, int type, Content htmlTree) {
bpatel@766 214 if (builder.hasDocumentation(type)) {
bpatel@766 215 htmlTree.addContent(getMarkerAnchor(ANCHORS[type]));
bpatel@766 216 }
duke@1 217 }
duke@1 218
duke@1 219 /**
bpatel@766 220 * Get the header for the deprecated API Listing.
bpatel@766 221 *
bpatel@766 222 * @return a content tree for the header
duke@1 223 */
bpatel@766 224 public Content getHeader() {
bpatel@766 225 String title = configuration.getText("doclet.Window_Deprecated_List");
bpatel@766 226 Content bodyTree = getBody(true, getWindowTitle(title));
bpatel@766 227 addTop(bodyTree);
bpatel@766 228 addNavLinks(true, bodyTree);
bpatel@766 229 return bodyTree;
bpatel@766 230 }
bpatel@766 231
bpatel@766 232 /**
bpatel@766 233 * Get the deprecated label.
bpatel@766 234 *
bpatel@766 235 * @return a content tree for the deprecated label
bpatel@766 236 */
bpatel@766 237 protected Content getNavLinkDeprecated() {
bpatel@766 238 Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, deprecatedLabel);
bpatel@766 239 return li;
duke@1 240 }
duke@1 241 }

mercurial