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 / PackageFrameWriter.java < prev    next >
Encoding:
Java Source  |  1999-09-19  |  5.5 KB  |  164 lines

  1. /*
  2.  * @(#)PackageFrameWriter.java    1.14 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.  * Class to generate file for each package contents in the left-hand bottom 
  24.  * frame. This will list all the Class Kinds in the package. A click on any
  25.  * class-kind will update the right-hand frame with the clicked class-kind page.
  26.  *
  27.  * @author Atul M Dambalkar
  28.  */
  29. public class PackageFrameWriter extends AbstractPackageWriter {
  30.  
  31.     /**
  32.      * Constructor to construct PackageFrameWriter object and to generate 
  33.      * "package-frame.html" file in the respective package directory. 
  34.      * For example for package "java.lang" this will generate file 
  35.      * "package-frame.html" file in the "java/lang" directory. It will also 
  36.      * create "java/lang" directory in the current or the destination directory
  37.      * if it doesen't exist.
  38.      *
  39.      * @param path Directories in this path will be created if they are not 
  40.      * already there.
  41.      * @param filename Name of the package summary file to be generated, 
  42.      * "package-frame.html".
  43.      * @param packagedoc PackageDoc under consideration.
  44.      */
  45.     public PackageFrameWriter(String path, String filename, 
  46.                               PackageDoc packagedoc) 
  47.                               throws IOException, DocletAbortException {
  48.         super(path, filename, packagedoc);
  49.     }
  50.  
  51.     /**
  52.      * Generate a package summary page for the left-hand bottom frame. Construct
  53.      * the PackageFrameWriter object and then uses it generate the file.
  54.      *
  55.      * @param pkg The package for which "pacakge-frame.html" is to be generated.
  56.      */
  57.     public static void generate(PackageDoc pkg) throws DocletAbortException {
  58.         PackageFrameWriter packgen;
  59.         String path = DirectoryManager.getDirectoryPath(pkg);
  60.         String filename = "package-frame" + ".html";
  61.         try {
  62.             packgen = new PackageFrameWriter(path, filename, pkg);
  63.             packgen.generatePackageFile();
  64.             packgen.close();
  65.         } catch (IOException exc) {
  66.             Standard.configuration().standardmessage.
  67.                     error("doclet.exception_encountered", 
  68.                            exc.toString(), filename);
  69.             throw new DocletAbortException();
  70.         }
  71.     }
  72.  
  73.     /**
  74.      * Generate class listing for all the classes in this package. Divide class
  75.      * listing as per the class kind and generate separate listing for 
  76.      * Classes, Interfaces, Exceptions and Errors.
  77.      */
  78.     protected void generateClassListing() {
  79.         generateClassKindListing(packagedoc.interfaces(), 
  80.                                  getText("doclet.Interfaces"));
  81.         generateClassKindListing(packagedoc.ordinaryClasses(),
  82.                                  getText("doclet.Classes"));
  83.         generateClassKindListing(packagedoc.exceptions(),
  84.                                  getText("doclet.Exceptions"));
  85.         generateClassKindListing(packagedoc.errors(),
  86.                                  getText("doclet.Errors"));
  87.     }
  88.  
  89.     /** 
  90.      * Generate specific class kind listing. Also add label to the listing.
  91.      *
  92.      * @param arr Array of specific class kinds, namely Class or Interface or
  93.      * Exception or Error.
  94.      * @param label Label for the listing
  95.      */
  96.     protected void generateClassKindListing(ClassDoc[] arr, String label) {
  97.         if(arr.length > 0) {
  98.             Arrays.sort(arr);    
  99.             printPackageTableHeader();
  100.             fontSizeStyle("+1", "FrameHeadingFont");
  101.             print(label);
  102.             fontEnd();
  103.             println(" ");
  104.             fontStyle("FrameItemFont");
  105.             for (int i = 0; i < arr.length; i++) {
  106.                 if (!isCoreClass(arr[i])) {
  107.                     continue;
  108.                 }
  109.                 br();
  110.                 printTargetClassLink(arr[i], "classFrame");
  111.             }
  112.             fontEnd();
  113.             printPackageTableFooter();
  114.             println();
  115.         }
  116.     }
  117.  
  118.     /**
  119.      * Print the package link at the top of the class kind listing. Clicking 
  120.      * this link, package-summary page will appear in the right hand frame.
  121.      *
  122.      * @param heading Top Heading to be used for the class kind listing.
  123.      */
  124.     protected void printPackageHeader(String heading) {
  125.         fontSizeStyle("+1", "FrameTitleFont");
  126.         printTargetPackageLink(packagedoc, "classFrame", heading);
  127.         fontEnd();
  128.     }
  129.    
  130.     /**
  131.      * The table for the class kind listing.
  132.      */
  133.     protected void printPackageTableHeader() {
  134.         table();
  135.         tr();
  136.         tdNowrap();
  137.     }
  138.      
  139.     /**
  140.      * Closing Html tags for table of class kind listing.
  141.      */
  142.     protected void printPackageTableFooter() {
  143.         tdEnd();
  144.         trEnd();
  145.         tableEnd();
  146.     }
  147.      
  148.     /**
  149.      * Do nothing. No footer is generated for this page.
  150.      */
  151.     protected void printPackageFooter() {
  152.         
  153.     }
  154.     
  155.     /**
  156.      * Do nothing. Package Description is not generted in this page.
  157.      */
  158.     protected void printPackageDescription() throws IOException {
  159.     }
  160. }
  161.  
  162.  
  163.  
  164.