aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package com.sun.tools.doclets.formats.html; aoqi@0: aoqi@0: import java.io.*; aoqi@0: aoqi@0: import com.sun.tools.doclets.formats.html.markup.*; aoqi@0: import com.sun.tools.doclets.internal.toolkit.*; aoqi@0: import com.sun.tools.doclets.internal.toolkit.util.*; aoqi@0: aoqi@0: /** aoqi@0: * Generate File to list all the deprecated classes and class members with the aoqi@0: * appropriate links. aoqi@0: * aoqi@0: *

This is NOT part of any supported API. aoqi@0: * If you write code that depends on this, you do so at your own risk. aoqi@0: * This code and its internal interfaces are subject to change or aoqi@0: * deletion without notice. aoqi@0: * aoqi@0: * @see java.util.List aoqi@0: * @author Atul M Dambalkar aoqi@0: * @author Bhavesh Patel (Modified) aoqi@0: */ aoqi@0: public class DeprecatedListWriter extends SubWriterHolderWriter { aoqi@0: aoqi@0: private static final String[] ANCHORS = new String[] { aoqi@0: "package", "interface", "class", "enum", "exception", "error", aoqi@0: "annotation.type", "field", "method", "constructor", "enum.constant", aoqi@0: "annotation.type.member" aoqi@0: }; aoqi@0: aoqi@0: private static final String[] HEADING_KEYS = new String[] { aoqi@0: "doclet.Deprecated_Packages", "doclet.Deprecated_Interfaces", aoqi@0: "doclet.Deprecated_Classes", "doclet.Deprecated_Enums", aoqi@0: "doclet.Deprecated_Exceptions", "doclet.Deprecated_Errors", aoqi@0: "doclet.Deprecated_Annotation_Types", aoqi@0: "doclet.Deprecated_Fields", aoqi@0: "doclet.Deprecated_Methods", "doclet.Deprecated_Constructors", aoqi@0: "doclet.Deprecated_Enum_Constants", aoqi@0: "doclet.Deprecated_Annotation_Type_Members" aoqi@0: }; aoqi@0: aoqi@0: private static final String[] SUMMARY_KEYS = new String[] { aoqi@0: "doclet.deprecated_packages", "doclet.deprecated_interfaces", aoqi@0: "doclet.deprecated_classes", "doclet.deprecated_enums", aoqi@0: "doclet.deprecated_exceptions", "doclet.deprecated_errors", aoqi@0: "doclet.deprecated_annotation_types", aoqi@0: "doclet.deprecated_fields", aoqi@0: "doclet.deprecated_methods", "doclet.deprecated_constructors", aoqi@0: "doclet.deprecated_enum_constants", aoqi@0: "doclet.deprecated_annotation_type_members" aoqi@0: }; aoqi@0: aoqi@0: private static final String[] HEADER_KEYS = new String[] { aoqi@0: "doclet.Package", "doclet.Interface", "doclet.Class", aoqi@0: "doclet.Enum", "doclet.Exceptions", aoqi@0: "doclet.Errors", aoqi@0: "doclet.AnnotationType", aoqi@0: "doclet.Field", aoqi@0: "doclet.Method", "doclet.Constructor", aoqi@0: "doclet.Enum_Constant", aoqi@0: "doclet.Annotation_Type_Member" aoqi@0: }; aoqi@0: aoqi@0: private AbstractMemberWriter[] writers; aoqi@0: aoqi@0: private ConfigurationImpl configuration; aoqi@0: aoqi@0: /** aoqi@0: * Constructor. aoqi@0: * aoqi@0: * @param filename the file to be generated. aoqi@0: */ aoqi@0: public DeprecatedListWriter(ConfigurationImpl configuration, aoqi@0: DocPath filename) throws IOException { aoqi@0: super(configuration, filename); aoqi@0: this.configuration = configuration; aoqi@0: NestedClassWriterImpl classW = new NestedClassWriterImpl(this); aoqi@0: writers = new AbstractMemberWriter[] aoqi@0: {classW, classW, classW, classW, classW, classW, aoqi@0: new FieldWriterImpl(this), aoqi@0: new MethodWriterImpl(this), aoqi@0: new ConstructorWriterImpl(this), aoqi@0: new EnumConstantWriterImpl(this), aoqi@0: new AnnotationTypeOptionalMemberWriterImpl(this, null)}; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Get list of all the deprecated classes and members in all the Packages aoqi@0: * specified on the Command Line. aoqi@0: * Then instantiate DeprecatedListWriter and generate File. aoqi@0: * aoqi@0: * @param configuration the current configuration of the doclet. aoqi@0: */ aoqi@0: public static void generate(ConfigurationImpl configuration) { aoqi@0: DocPath filename = DocPaths.DEPRECATED_LIST; aoqi@0: try { aoqi@0: DeprecatedListWriter depr = aoqi@0: new DeprecatedListWriter(configuration, filename); aoqi@0: depr.generateDeprecatedListFile( aoqi@0: new DeprecatedAPIListBuilder(configuration)); aoqi@0: depr.close(); aoqi@0: } catch (IOException exc) { aoqi@0: configuration.standardmessage.error( aoqi@0: "doclet.exception_encountered", aoqi@0: exc.toString(), filename); aoqi@0: throw new DocletAbortException(exc); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Generate the deprecated API list. aoqi@0: * aoqi@0: * @param deprapi list of deprecated API built already. aoqi@0: */ aoqi@0: protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi) aoqi@0: throws IOException { aoqi@0: Content body = getHeader(); aoqi@0: body.addContent(getContentsList(deprapi)); aoqi@0: String memberTableSummary; aoqi@0: String[] memberTableHeader = new String[1]; aoqi@0: HtmlTree div = new HtmlTree(HtmlTag.DIV); aoqi@0: div.addStyle(HtmlStyle.contentContainer); aoqi@0: for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) { aoqi@0: if (deprapi.hasDocumentation(i)) { aoqi@0: addAnchor(deprapi, i, div); aoqi@0: memberTableSummary = aoqi@0: configuration.getText("doclet.Member_Table_Summary", aoqi@0: configuration.getText(HEADING_KEYS[i]), aoqi@0: configuration.getText(SUMMARY_KEYS[i])); aoqi@0: memberTableHeader[0] = configuration.getText("doclet.0_and_1", aoqi@0: configuration.getText(HEADER_KEYS[i]), aoqi@0: configuration.getText("doclet.Description")); aoqi@0: // DeprecatedAPIListBuilder.PACKAGE == 0, so if i == 0, it is aoqi@0: // a PackageDoc. aoqi@0: if (i == DeprecatedAPIListBuilder.PACKAGE) aoqi@0: addPackageDeprecatedAPI(deprapi.getList(i), aoqi@0: HEADING_KEYS[i], memberTableSummary, memberTableHeader, div); aoqi@0: else aoqi@0: writers[i - 1].addDeprecatedAPI(deprapi.getList(i), aoqi@0: HEADING_KEYS[i], memberTableSummary, memberTableHeader, div); aoqi@0: } aoqi@0: } aoqi@0: body.addContent(div); aoqi@0: addNavLinks(false, body); aoqi@0: addBottom(body); aoqi@0: printHtmlDocument(null, true, body); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Add the index link. aoqi@0: * aoqi@0: * @param builder the deprecated list builder aoqi@0: * @param type the type of list being documented aoqi@0: * @param contentTree the content tree to which the index link will be added aoqi@0: */ aoqi@0: private void addIndexLink(DeprecatedAPIListBuilder builder, aoqi@0: int type, Content contentTree) { aoqi@0: if (builder.hasDocumentation(type)) { aoqi@0: Content li = HtmlTree.LI(getHyperLink(ANCHORS[type], aoqi@0: getResource(HEADING_KEYS[type]))); aoqi@0: contentTree.addContent(li); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Get the contents list. aoqi@0: * aoqi@0: * @param deprapi the deprecated list builder aoqi@0: * @return a content tree for the contents list aoqi@0: */ aoqi@0: public Content getContentsList(DeprecatedAPIListBuilder deprapi) { aoqi@0: Content headContent = getResource("doclet.Deprecated_API"); aoqi@0: Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, aoqi@0: HtmlStyle.title, headContent); aoqi@0: Content div = HtmlTree.DIV(HtmlStyle.header, heading); aoqi@0: Content headingContent = getResource("doclet.Contents"); aoqi@0: div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true, aoqi@0: headingContent)); aoqi@0: Content ul = new HtmlTree(HtmlTag.UL); aoqi@0: for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) { aoqi@0: addIndexLink(deprapi, i, ul); aoqi@0: } aoqi@0: div.addContent(ul); aoqi@0: return div; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Add the anchor. aoqi@0: * aoqi@0: * @param builder the deprecated list builder aoqi@0: * @param type the type of list being documented aoqi@0: * @param htmlTree the content tree to which the anchor will be added aoqi@0: */ aoqi@0: private void addAnchor(DeprecatedAPIListBuilder builder, int type, Content htmlTree) { aoqi@0: if (builder.hasDocumentation(type)) { aoqi@0: htmlTree.addContent(getMarkerAnchor(ANCHORS[type])); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Get the header for the deprecated API Listing. aoqi@0: * aoqi@0: * @return a content tree for the header aoqi@0: */ aoqi@0: public Content getHeader() { aoqi@0: String title = configuration.getText("doclet.Window_Deprecated_List"); aoqi@0: Content bodyTree = getBody(true, getWindowTitle(title)); aoqi@0: addTop(bodyTree); aoqi@0: addNavLinks(true, bodyTree); aoqi@0: return bodyTree; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Get the deprecated label. aoqi@0: * aoqi@0: * @return a content tree for the deprecated label aoqi@0: */ aoqi@0: protected Content getNavLinkDeprecated() { aoqi@0: Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, deprecatedLabel); aoqi@0: return li; aoqi@0: } aoqi@0: }