src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.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 1998-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.javadoc.*;
    29 import java.io.*;
    30 import java.util.*;
    32 /**
    33  * Abstract class to generate the overview files in
    34  * Frame and Non-Frame format. This will be sub-classed by to
    35  * generate overview-frame.html as well as overview-summary.html.
    36  *
    37  * @author Atul M Dambalkar
    38  * @author Bhavesh Patel (Modified)
    39  */
    40 public abstract class AbstractPackageIndexWriter extends HtmlDocletWriter {
    42     /**
    43      * Array of Packages to be documented.
    44      */
    45     protected PackageDoc[] packages;
    47     /**
    48      * Constructor. Also initialises the packages variable.
    49      *
    50      * @param filename Name of the package index file to be generated.
    51      */
    52     public AbstractPackageIndexWriter(ConfigurationImpl configuration,
    53                                       String filename) throws IOException {
    54         super(configuration, filename);
    55         this.relativepathNoSlash = ".";
    56         packages = configuration.packages;
    57     }
    59     protected abstract void printNavigationBarHeader();
    61     protected abstract void printNavigationBarFooter();
    63     protected abstract void printOverviewHeader();
    65     protected abstract void printIndexHeader(String text, String tableSummary);
    67     protected abstract void printIndexRow(PackageDoc pkg);
    69     protected abstract void printIndexFooter();
    71     /**
    72      * Generate the contants in the package index file. Call appropriate
    73      * methods from the sub-class in order to generate Frame or Non
    74      * Frame format.
    75      * @param title the title of the window.
    76      * @param includeScript boolean set true if windowtitle script is to be included
    77      */
    78     protected void generatePackageIndexFile(String title, boolean includeScript) throws IOException {
    79         String windowOverview = configuration.getText(title);
    80         printHtmlHeader(windowOverview,
    81             configuration.metakeywords.getOverviewMetaKeywords(title,
    82                 configuration.doctitle),
    83             includeScript);
    84         printNavigationBarHeader();
    85         printOverviewHeader();
    87         generateIndex();
    89         printOverview();
    91         printNavigationBarFooter();
    92         printBodyHtmlEnd();
    93     }
    95     /**
    96      * Default to no overview, overwrite to add overview.
    97      */
    98     protected void printOverview() throws IOException {
    99     }
   101     /**
   102      * Generate the frame or non-frame package index.
   103      */
   104     protected void generateIndex() {
   105         printIndexContents(packages, "doclet.Package_Summary",
   106                 configuration.getText("doclet.Member_Table_Summary",
   107                 configuration.getText("doclet.Package_Summary"),
   108                 configuration.getText("doclet.packages")));
   109     }
   111     /**
   112      * Generate code for package index contents. Call appropriate methods from
   113      * the sub-classes.
   114      *
   115      * @param packages Array of packages to be documented.
   116      * @param text     String which will be used as the heading.
   117      */
   118     protected void printIndexContents(PackageDoc[] packages, String text, String tableSummary) {
   119         if (packages.length > 0) {
   120             Arrays.sort(packages);
   121             printIndexHeader(text, tableSummary);
   122             printAllClassesPackagesLink();
   123             for(int i = 0; i < packages.length; i++) {
   124                 if (packages[i] != null) {
   125                     printIndexRow(packages[i]);
   126                 }
   127             }
   128             printIndexFooter();
   129         }
   130     }
   132     /**
   133      * Print the doctitle, if it is specified on the command line.
   134      */
   135     protected void printConfigurationTitle() {
   136         if (configuration.doctitle.length() > 0) {
   137             center();
   138             h1(configuration.doctitle);
   139             centerEnd();
   140         }
   141     }
   143     /**
   144      * Highlight "Overview" in the strong format, in the navigation bar as this
   145      * is the overview page.
   146      */
   147     protected void navLinkContents() {
   148         navCellRevStart();
   149         fontStyle("NavBarFont1Rev");
   150         strongText("doclet.Overview");
   151         fontEnd();
   152         navCellEnd();
   153     }
   155     /**
   156      * Do nothing. This will be overridden in PackageIndexFrameWriter.
   157      */
   158     protected void printAllClassesPackagesLink() {
   159     }
   160 }

mercurial