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

Sun, 11 Apr 2010 23:24:24 -0700

author
yhuang
date
Sun, 11 Apr 2010 23:24:24 -0700
changeset 539
06e06ec0d6f2
parent 243
edd944553131
child 554
9d9f26857129
permissions
-rw-r--r--

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.*;
    29 import com.sun.tools.doclets.internal.toolkit.util.*;
    31 import com.sun.javadoc.*;
    32 import java.io.*;
    33 import java.util.*;
    35 /**
    36  * Class to generate file for each package contents in the right-hand
    37  * frame. This will list all the Class Kinds in the package. A click on any
    38  * class-kind will update the frame with the clicked class-kind page.
    39  *
    40  * @author Atul M Dambalkar
    41  * @author Bhavesh Patel (Modified)
    42  */
    43 public class PackageWriterImpl extends HtmlDocletWriter
    44     implements PackageSummaryWriter {
    46     /**
    47      * The prev package name in the alpha-order list.
    48      */
    49     protected PackageDoc prev;
    51     /**
    52      * The next package name in the alpha-order list.
    53      */
    54     protected PackageDoc next;
    56     /**
    57      * The package being documented.
    58      */
    59     protected PackageDoc packageDoc;
    61     /**
    62      * The name of the output file.
    63      */
    64     private static final String OUTPUT_FILE_NAME = "package-summary.html";
    66     /**
    67      * Constructor to construct PackageWriter object and to generate
    68      * "package-summary.html" file in the respective package directory.
    69      * For example for package "java.lang" this will generate file
    70      * "package-summary.html" file in the "java/lang" directory. It will also
    71      * create "java/lang" directory in the current or the destination directory
    72      * if it doesen't exist.
    73      *
    74      * @param configuration the configuration of the doclet.
    75      * @param packageDoc    PackageDoc under consideration.
    76      * @param prev          Previous package in the sorted array.
    77      * @param next            Next package in the sorted array.
    78      */
    79     public PackageWriterImpl(ConfigurationImpl configuration,
    80         PackageDoc packageDoc, PackageDoc prev, PackageDoc next)
    81     throws IOException {
    82         super(configuration, DirectoryManager.getDirectoryPath(packageDoc), OUTPUT_FILE_NAME,
    83              DirectoryManager.getRelativePath(packageDoc.name()));
    84         this.prev = prev;
    85         this.next = next;
    86         this.packageDoc = packageDoc;
    87     }
    89     /**
    90      * Return the name of the output file.
    91      *
    92      * @return the name of the output file.
    93      */
    94     public String getOutputFileName() {
    95         return OUTPUT_FILE_NAME;
    96     }
    98     /**
    99      * {@inheritDoc}
   100      */
   101     public void writeSummaryHeader() {}
   103     /**
   104      * {@inheritDoc}
   105      */
   106     public void writeSummaryFooter() {}
   108     /**
   109      * {@inheritDoc}
   110      */
   111     public void writeClassesSummary(ClassDoc[] classes, String label, String tableSummary, String[] tableHeader) {
   112         if(classes.length > 0) {
   113             Arrays.sort(classes);
   114             tableIndexSummary(tableSummary);
   115             boolean printedHeading = false;
   116             for (int i = 0; i < classes.length; i++) {
   117                 if (!printedHeading) {
   118                     printTableCaption(label);
   119                     printFirstRow(tableHeader);
   120                     printedHeading = true;
   121                 }
   122                 if (!Util.isCoreClass(classes[i]) ||
   123                     !configuration.isGeneratedDoc(classes[i])) {
   124                     continue;
   125                 }
   126                 trBgcolorStyle("white", "TableRowColor");
   127                 summaryRow(15);
   128                 strong();
   129                 printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_PACKAGE,
   130                     classes[i], false));
   131                 strongEnd();
   132                 summaryRowEnd();
   133                 summaryRow(0);
   134                 if (Util.isDeprecated(classes[i])) {
   135                     strongText("doclet.Deprecated");
   136                     if (classes[i].tags("deprecated").length > 0) {
   137                         space();
   138                         printSummaryDeprecatedComment(classes[i],
   139                             classes[i].tags("deprecated")[0]);
   140                     }
   141                 } else {
   142                     printSummaryComment(classes[i]);
   143                 }
   144                 summaryRowEnd();
   145                 trEnd();
   146             }
   147             tableEnd();
   148             println("&nbsp;");
   149             p();
   150         }
   151     }
   153     /**
   154      * Print the table caption for the class-listing.
   155      *
   156      * @param label label for the Class kind listing.
   157      */
   158     protected void printTableCaption(String label) {
   159         tableCaptionStart();
   160         print(label);
   161         tableCaptionEnd();
   162     }
   164     /**
   165      * Print the table heading for the class-listing.
   166      *
   167      * @param tableHeader table header string for the Class listing.
   168      */
   169     protected void printFirstRow(String[] tableHeader) {
   170         summaryTableHeader(tableHeader, "col");
   171     }
   173     /**
   174      * {@inheritDoc}
   175      */
   176     public void writePackageDescription() {
   177         if (packageDoc.inlineTags().length > 0) {
   178             anchor("package_description");
   179             h2(configuration.getText("doclet.Package_Description", packageDoc.name()));
   180             p();
   181             printInlineComment(packageDoc);
   182             p();
   183         }
   184     }
   186     /**
   187      * {@inheritDoc}
   188      */
   189     public void writePackageTags() {
   190         printTags(packageDoc);
   191     }
   193     /**
   194      * {@inheritDoc}
   195      */
   196     public void writePackageHeader(String heading) {
   197         String pkgName = packageDoc.name();
   198         printHtmlHeader(pkgName,
   199             configuration.metakeywords.getMetaKeywords(packageDoc), true);
   200         printTop();
   201         navLinks(true);
   202         hr();
   203         writeAnnotationInfo(packageDoc);
   204         h2(configuration.getText("doclet.Package") + " " + heading);
   205         if (packageDoc.inlineTags().length > 0 && ! configuration.nocomment) {
   206             printSummaryComment(packageDoc);
   207             p();
   208             strong(configuration.getText("doclet.See"));
   209             br();
   210             printNbsps();
   211             printHyperLink("", "package_description",
   212                 configuration.getText("doclet.Description"), true);
   213             p();
   214         }
   215     }
   217     /**
   218      * {@inheritDoc}
   219      */
   220     public void writePackageFooter() {
   221         hr();
   222         navLinks(false);
   223         printBottom();
   224         printBodyHtmlEnd();
   225     }
   227     /**
   228      * Print "Use" link for this pacakge in the navigation bar.
   229      */
   230     protected void navLinkClassUse() {
   231         navCellStart();
   232         printHyperLink("package-use.html", "", configuration.getText("doclet.navClassUse"),
   233                        true, "NavBarFont1");
   234         navCellEnd();
   235     }
   237     /**
   238      * Print "PREV PACKAGE" link in the navigation bar.
   239      */
   240     protected void navLinkPrevious() {
   241         if (prev == null) {
   242             printText("doclet.Prev_Package");
   243         } else {
   244             String path = DirectoryManager.getRelativePath(packageDoc.name(),
   245                                                            prev.name());
   246             printHyperLink(path + "package-summary.html", "",
   247                 configuration.getText("doclet.Prev_Package"), true);
   248         }
   249     }
   251     /**
   252      * Print "NEXT PACKAGE" link in the navigation bar.
   253      */
   254     protected void navLinkNext() {
   255         if (next == null) {
   256             printText("doclet.Next_Package");
   257         } else {
   258             String path = DirectoryManager.getRelativePath(packageDoc.name(),
   259                                                            next.name());
   260             printHyperLink(path + "package-summary.html", "",
   261                 configuration.getText("doclet.Next_Package"), true);
   262         }
   263     }
   265     /**
   266      * Print "Tree" link in the navigation bar. This will be link to the package
   267      * tree file.
   268      */
   269     protected void navLinkTree() {
   270         navCellStart();
   271         printHyperLink("package-tree.html", "", configuration.getText("doclet.Tree"),
   272                        true, "NavBarFont1");
   273         navCellEnd();
   274     }
   276     /**
   277      * Highlight "Package" in the navigation bar, as this is the package page.
   278      */
   279     protected void navLinkPackage() {
   280         navCellRevStart();
   281         fontStyle("NavBarFont1Rev");
   282         strongText("doclet.Package");
   283         fontEnd();
   284         navCellEnd();
   285     }
   286 }

mercurial