0N/A/*
994N/A * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
553N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
553N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.tools.doclets.formats.html;
0N/A
765N/Aimport java.io.*;
765N/Aimport com.sun.tools.doclets.internal.toolkit.*;
0N/Aimport com.sun.tools.doclets.internal.toolkit.util.DeprecatedAPIListBuilder;
0N/Aimport com.sun.tools.doclets.internal.toolkit.util.*;
765N/Aimport com.sun.tools.doclets.formats.html.markup.*;
0N/A
0N/A/**
0N/A * Generate File to list all the deprecated classes and class members with the
0N/A * appropriate links.
0N/A *
0N/A * @see java.util.List
0N/A * @author Atul M Dambalkar
242N/A * @author Bhavesh Patel (Modified)
0N/A */
0N/Apublic class DeprecatedListWriter extends SubWriterHolderWriter {
0N/A
0N/A private static final String[] ANCHORS = new String[] {
994N/A "package", "interface", "class", "enum", "exception", "error",
994N/A "annotation_type", "field", "method", "constructor", "enum_constant",
0N/A "annotation_type_member"
0N/A };
0N/A
0N/A private static final String[] HEADING_KEYS = new String[] {
994N/A "doclet.Deprecated_Packages", "doclet.Deprecated_Interfaces",
994N/A "doclet.Deprecated_Classes", "doclet.Deprecated_Enums",
994N/A "doclet.Deprecated_Exceptions", "doclet.Deprecated_Errors",
0N/A "doclet.Deprecated_Annotation_Types",
0N/A "doclet.Deprecated_Fields",
0N/A "doclet.Deprecated_Methods", "doclet.Deprecated_Constructors",
0N/A "doclet.Deprecated_Enum_Constants",
0N/A "doclet.Deprecated_Annotation_Type_Members"
0N/A };
0N/A
242N/A private static final String[] SUMMARY_KEYS = new String[] {
994N/A "doclet.deprecated_packages", "doclet.deprecated_interfaces",
994N/A "doclet.deprecated_classes", "doclet.deprecated_enums",
994N/A "doclet.deprecated_exceptions", "doclet.deprecated_errors",
242N/A "doclet.deprecated_annotation_types",
242N/A "doclet.deprecated_fields",
242N/A "doclet.deprecated_methods", "doclet.deprecated_constructors",
242N/A "doclet.deprecated_enum_constants",
242N/A "doclet.deprecated_annotation_type_members"
242N/A };
242N/A
242N/A private static final String[] HEADER_KEYS = new String[] {
994N/A "doclet.Package", "doclet.Interface", "doclet.Class",
242N/A "doclet.Enum", "doclet.Exceptions",
242N/A "doclet.Errors",
242N/A "doclet.AnnotationType",
242N/A "doclet.Field",
242N/A "doclet.Method", "doclet.Constructor",
242N/A "doclet.Enum_Constant",
242N/A "doclet.Annotation_Type_Member"
242N/A };
242N/A
0N/A private AbstractMemberWriter[] writers;
0N/A
0N/A private ConfigurationImpl configuration;
0N/A
0N/A /**
0N/A * Constructor.
0N/A *
0N/A * @param filename the file to be generated.
0N/A */
0N/A public DeprecatedListWriter(ConfigurationImpl configuration,
0N/A String filename) throws IOException {
0N/A super(configuration, filename);
0N/A this.configuration = configuration;
0N/A NestedClassWriterImpl classW = new NestedClassWriterImpl(this);
0N/A writers = new AbstractMemberWriter[]
0N/A {classW, classW, classW, classW, classW, classW,
0N/A new FieldWriterImpl(this),
0N/A new MethodWriterImpl(this),
0N/A new ConstructorWriterImpl(this),
0N/A new EnumConstantWriterImpl(this),
0N/A new AnnotationTypeOptionalMemberWriterImpl(this, null)};
0N/A }
0N/A
0N/A /**
0N/A * Get list of all the deprecated classes and members in all the Packages
0N/A * specified on the Command Line.
0N/A * Then instantiate DeprecatedListWriter and generate File.
0N/A *
0N/A * @param configuration the current configuration of the doclet.
0N/A */
0N/A public static void generate(ConfigurationImpl configuration) {
0N/A String filename = "deprecated-list.html";
0N/A try {
0N/A DeprecatedListWriter depr =
0N/A new DeprecatedListWriter(configuration, filename);
0N/A depr.generateDeprecatedListFile(
994N/A new DeprecatedAPIListBuilder(configuration));
0N/A depr.close();
0N/A } catch (IOException exc) {
0N/A configuration.standardmessage.error(
0N/A "doclet.exception_encountered",
0N/A exc.toString(), filename);
0N/A throw new DocletAbortException();
0N/A }
0N/A }
0N/A
0N/A /**
765N/A * Generate the deprecated API list.
0N/A *
0N/A * @param deprapi list of deprecated API built already.
0N/A */
0N/A protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi)
765N/A throws IOException {
765N/A Content body = getHeader();
765N/A body.addContent(getContentsList(deprapi));
242N/A String memberTableSummary;
242N/A String[] memberTableHeader = new String[1];
765N/A HtmlTree div = new HtmlTree(HtmlTag.DIV);
765N/A div.addStyle(HtmlStyle.contentContainer);
0N/A for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
0N/A if (deprapi.hasDocumentation(i)) {
765N/A addAnchor(deprapi, i, div);
242N/A memberTableSummary =
242N/A configuration.getText("doclet.Member_Table_Summary",
242N/A configuration.getText(HEADING_KEYS[i]),
242N/A configuration.getText(SUMMARY_KEYS[i]));
242N/A memberTableHeader[0] = configuration.getText("doclet.0_and_1",
242N/A configuration.getText(HEADER_KEYS[i]),
242N/A configuration.getText("doclet.Description"));
994N/A // DeprecatedAPIListBuilder.PACKAGE == 0, so if i == 0, it is
994N/A // a PackageDoc.
994N/A if (i == DeprecatedAPIListBuilder.PACKAGE)
994N/A addPackageDeprecatedAPI(deprapi.getList(i),
994N/A HEADING_KEYS[i], memberTableSummary, memberTableHeader, div);
994N/A else
994N/A writers[i - 1].addDeprecatedAPI(deprapi.getList(i),
994N/A HEADING_KEYS[i], memberTableSummary, memberTableHeader, div);
0N/A }
0N/A }
765N/A body.addContent(div);
765N/A addNavLinks(false, body);
765N/A addBottom(body);
765N/A printHtmlDocument(null, true, body);
0N/A }
0N/A
765N/A /**
765N/A * Add the index link.
765N/A *
765N/A * @param builder the deprecated list builder
765N/A * @param type the type of list being documented
765N/A * @param contentTree the content tree to which the index link will be added
765N/A */
765N/A private void addIndexLink(DeprecatedAPIListBuilder builder,
765N/A int type, Content contentTree) {
0N/A if (builder.hasDocumentation(type)) {
765N/A Content li = HtmlTree.LI(getHyperLink("#" + ANCHORS[type],
765N/A getResource(HEADING_KEYS[type])));
765N/A contentTree.addContent(li);
0N/A }
0N/A }
0N/A
0N/A /**
765N/A * Get the contents list.
765N/A *
765N/A * @param deprapi the deprecated list builder
765N/A * @return a content tree for the contents list
0N/A */
765N/A public Content getContentsList(DeprecatedAPIListBuilder deprapi) {
765N/A Content headContent = getResource("doclet.Deprecated_API");
765N/A Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
765N/A HtmlStyle.title, headContent);
765N/A Content div = HtmlTree.DIV(HtmlStyle.header, heading);
765N/A Content headingContent = getResource("doclet.Contents");
765N/A div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
765N/A headingContent));
765N/A Content ul = new HtmlTree(HtmlTag.UL);
765N/A for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
765N/A addIndexLink(deprapi, i, ul);
765N/A }
765N/A div.addContent(ul);
765N/A return div;
0N/A }
0N/A
0N/A /**
765N/A * Add the anchor.
765N/A *
765N/A * @param builder the deprecated list builder
765N/A * @param type the type of list being documented
765N/A * @param contentTree the content tree to which the anchor will be added
0N/A */
765N/A private void addAnchor(DeprecatedAPIListBuilder builder, int type, Content htmlTree) {
765N/A if (builder.hasDocumentation(type)) {
765N/A htmlTree.addContent(getMarkerAnchor(ANCHORS[type]));
765N/A }
0N/A }
0N/A
0N/A /**
765N/A * Get the header for the deprecated API Listing.
765N/A *
765N/A * @return a content tree for the header
0N/A */
765N/A public Content getHeader() {
765N/A String title = configuration.getText("doclet.Window_Deprecated_List");
765N/A Content bodyTree = getBody(true, getWindowTitle(title));
765N/A addTop(bodyTree);
765N/A addNavLinks(true, bodyTree);
765N/A return bodyTree;
765N/A }
765N/A
765N/A /**
765N/A * Get the deprecated label.
765N/A *
765N/A * @return a content tree for the deprecated label
765N/A */
765N/A protected Content getNavLinkDeprecated() {
765N/A Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, deprecatedLabel);
765N/A return li;
0N/A }
0N/A}