home *** CD-ROM | disk | FTP | other *** search
/ Internet News 1999 October / INEWS_10_CD.ISO / pc / jdk / jdk1.2.2 / docs / tooldocs / javadoc / source / standard / AbstractPackageIndexWriter.java < prev    next >
Encoding:
Java Source  |  1999-09-19  |  4.0 KB  |  145 lines

  1. /*
  2.  * @(#)AbstractPackageIndexWriter.java    1.15 98/08/18
  3.  *
  4.  * Copyright 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package com.sun.tools.doclets.standard;
  16.  
  17. import com.sun.tools.doclets.*;
  18. import com.sun.javadoc.*;
  19. import java.io.*;
  20. import java.lang.*;
  21. import java.util.*;
  22.  
  23. /**
  24.  * Abstract class to generate the package index. The package index needs to be
  25.  * generated in Frame and Non-Frame format. This will be sub-classed by to 
  26.  * generate frame-index as well as overview-index.
  27.  *
  28.  * @author Atul M Dambalkar 
  29.  */
  30. public abstract class AbstractPackageIndexWriter extends HtmlStandardWriter {
  31.  
  32.     /**
  33.      * Array of Packages to be documented.
  34.      */
  35.     protected PackageDoc[] packages;
  36.  
  37.     /**
  38.      * Constructor. Also initialises the packages variable.
  39.      *
  40.      * @param filename Name of the package index file to be generated.
  41.      */
  42.     public AbstractPackageIndexWriter(String filename) throws IOException {
  43.         super(filename);
  44.         packages = Standard.configuration().packages;
  45.     }
  46.  
  47.     protected abstract void printNavigationBarHeader();
  48.  
  49.     protected abstract void printNavigationBarFooter();
  50.  
  51.     protected abstract void printOverviewHeader();
  52.  
  53.     protected abstract void printIndexHeader(String text);
  54.  
  55.     protected abstract void printIndexRow(PackageDoc pkg);
  56.  
  57.     protected abstract void printIndexFooter();
  58.  
  59.     /**
  60.      * Generate the contants in the package index file. Call appropriate
  61.      * methods from the sub-class in order to generate Frame or Non
  62.      * Frame format.
  63.      */ 
  64.     protected void generatePackageIndexFile() throws IOException {
  65.         printHeader(getText("doclet.Window_Overview", 
  66.                              Standard.configuration().windowtitle)); 
  67.         printNavigationBarHeader();
  68.         printOverviewHeader();
  69.  
  70.         generateIndex();
  71.  
  72.         printOverview();
  73.  
  74.         printNavigationBarFooter();
  75.         printBodyHtmlEnd();
  76.     }
  77.     
  78.     /**
  79.      * Default to no overview, overwrite to add overview.
  80.      */
  81.     protected void printOverview() throws IOException {
  82.     }
  83.  
  84.     /**
  85.      * Generate the frame or non-frame package index.
  86.      */
  87.     protected void generateIndex() {
  88.         printIndexContents(packages, "doclet.Package_Summary");
  89.     }
  90.  
  91.     /**
  92.      * Generate code for package index contents. Call appropriate methods from
  93.      * the sub-classes.
  94.      * 
  95.      * @param pacakges Array of packages to be documented.
  96.      * @param text     String which will be used as the heading.
  97.      */
  98.     protected void printIndexContents(PackageDoc[] packages, String text) {
  99.         if (packages.length > 0) {
  100.             Arrays.sort(packages);
  101.             printIndexHeader(text);
  102.             printAllClassesPackagesLink();
  103.             for(int i = 0; i < packages.length; i++) {
  104.                 PackageDoc packagedoc = packages[i];
  105.                 printIndexRow(packagedoc);
  106.             }
  107.             printIndexFooter();
  108.         }
  109.     }
  110.  
  111.     /**
  112.      * Print the doctitle, if it is specified on the command line. 
  113.      */
  114.     protected void printConfigurationTitle() {
  115.         if (Standard.configuration().doctitle.length() > 0) {
  116.             center();
  117.             h2();
  118.             print(Standard.configuration().doctitle);
  119.             h2End();
  120.             centerEnd();
  121.         }
  122.     }
  123.  
  124.     /**
  125.      * Highlight "Overview" in the bold format, in the navigation bar as this 
  126.      * is the overview page.
  127.      */
  128.     protected void navLinkContents() {
  129.         navCellRevStart();
  130.         fontStyle("NavBarFont1Rev");
  131.         boldText("doclet.Overview");
  132.         fontEnd();
  133.         navCellEnd();
  134.     }
  135.  
  136.     /**
  137.      * Do nothing. This will be overridden in PackageIndexFrameWriter.
  138.      */
  139.     protected void printAllClassesPackagesLink() {
  140.     }
  141. }
  142.  
  143.  
  144.  
  145.