FileDocCategorySizeDatePackage
PackageUseWriter.javaAPI DocExample7343Wed Apr 19 11:17:14 BST 2000com.sun.tools.doclets.standard

PackageUseWriter

public class PackageUseWriter extends SubWriterHolderWriter
Generate package usage information.
author
Robert G. Field

Fields Summary
final PackageDoc
pkgdoc
final SortedMap
usingPackageToUsedClasses
Constructors Summary
public PackageUseWriter(ClassUseMapper mapper, String filename, PackageDoc pkgdoc)
Constructor.

param
filename the file to be generated.

  

                  
         
                 
        super(DirectoryManager.getDirectoryPath(pkgdoc), 
              filename, 
              DirectoryManager.getRelativePath(pkgdoc.name()));
        this.pkgdoc = pkgdoc;

        // by examining all classes in this package, find what packages
        // use these classes - produce a map between using package and
        // used classes.
        ClassDoc[] content = pkgdoc.allClasses();
        for (int i = 0; i < content.length; ++i) {
            ClassDoc usedClass = content[i];
            Set usingClasses = (Set)mapper.classToClass.get(usedClass);
            if (usingClasses != null) {
                for (Iterator it = usingClasses.iterator(); it.hasNext(); ) {
                    ClassDoc usingClass = (ClassDoc)it.next();
                    PackageDoc usingPackage = usingClass.containingPackage();
                    Set usedClasses = (Set)usingPackageToUsedClasses
                                                     .get(usingPackage);
                    if (usedClasses == null) {
                        usedClasses = new TreeSet();
                        usingPackageToUsedClasses.put(usingPackage, 
                                                      usedClasses);
                    }
                    usedClasses.add(usedClass);
                }
            }
        }
    
Methods Summary
public static voidgenerate(ClassUseMapper mapper, com.sun.javadoc.PackageDoc pkgdoc)
Generate a class page.

param
prev the previous class to generated, or null if no previous.
param
classdoc the class to generate.
param
next the next class to be generated, or null if no next.

            PackageUseWriter pkgusegen;
            String filename = "package-use.html";
            try {
                pkgusegen = new PackageUseWriter(mapper, filename, pkgdoc);
                pkgusegen.generatePackageUseFile();
                pkgusegen.close();
            } catch (IOException exc) {
                Standard.configuration().standardmessage.
                    error("doclet.exception_encountered",
                           exc.toString(), filename);
                throw new DocletAbortException();
            }
    
protected voidgenerateClassList()

	Iterator itp = usingPackageToUsedClasses.keySet().iterator();
        while (itp.hasNext()) {
	    PackageDoc usingPackage = (PackageDoc)itp.next();
	    anchor(usingPackage.name());
	    tableIndexSummary();
	    tableHeaderStart("#CCCCFF");
	    printText("doclet.ClassUse_Classes.in.0.used.by.1",
		      getPackageLink(pkgdoc),
                      getPackageLink(usingPackage));
            Iterator itc = 
                  ((Collection)usingPackageToUsedClasses.get(usingPackage))
                       .iterator();
            while (itc.hasNext()) {
                printClassRow((ClassDoc)itc.next(), usingPackage);
            }
	    tableHeaderEnd();
	    tableEnd();
            space();
            p();
	}
    
protected voidgeneratePackageList()

	tableIndexSummary();
	tableHeaderStart("#CCCCFF");
	printText("doclet.ClassUse_Packages.that.use.0",
		  getPackageLink(pkgdoc));
	tableHeaderEnd();

	Iterator it = usingPackageToUsedClasses.keySet().iterator();
        while (it.hasNext()) {
	    PackageDoc pkg = (PackageDoc)it.next();
	    generatePackageUse(pkg);
	}
	tableEnd();
	space();
	p();
    
protected voidgeneratePackageUse()
Print the class use list.

        if (Standard.configuration().packages.length > 1) {
            generatePackageList();
        }
        generateClassList();
    
protected voidgeneratePackageUse(com.sun.javadoc.PackageDoc pkg)
Print the package use list.

        trBgcolorStyle("white", "TableRowColor");
	summaryRow(0);
	printHyperLink("", pkg.name(), pkg.name(), true);
	summaryRowEnd();
	summaryRow(0);
	printSummaryComment(pkg);
	space();
	summaryRowEnd();
	trEnd();
    
protected voidgeneratePackageUseFile()
Print the class use list.

        printPackageUseHeader();

	if (usingPackageToUsedClasses.isEmpty()) {
            printText("doclet.ClassUse_No.usage.of.0", pkgdoc.name());
            p();
        } else {
            generatePackageUse();
        }
        
        printPackageUseFooter();
    
protected voidnavLinkClassUse()
Print class use link

        navCellRevStart();
        fontStyle("NavBarFont1Rev");
        boldText("doclet.navClassUse");
        fontEnd();
        navCellEnd();
    
protected voidnavLinkPackage()
Print this package link

        navCellStart();
        printHyperLink("package-summary.html", "", getText("doclet.Package"),
                        true, "NavBarFont1");
        navCellEnd();
    
protected voidnavLinkTree()

        navCellStart();
        printHyperLink("package-tree.html", "", getText("doclet.Tree"),
                        true, "NavBarFont1");
        navCellEnd();
    
protected voidprintClassRow(com.sun.javadoc.ClassDoc usedClass, com.sun.javadoc.PackageDoc usingPackage)

        String path = pathString(usedClass, 
                                 "class-use/" + usedClass.name() + ".html");

        trBgcolorStyle("white", "TableRowColor");
        summaryRow(0);
        bold();
        printHyperLink(path, usingPackage.name(), usedClass.name(), true);
        boldEnd();
        println(); br();
        printNbsps();
        printIndexComment(usedClass); 
        summaryRowEnd();
        trEnd(); 
    
protected voidprintPackageUseFooter()
Print the footer for the class use Listing.

        hr();
        navLinks(false);
        printBottom();
        printBodyHtmlEnd();
    
protected voidprintPackageUseHeader()
Print the header for the class use Listing.

        String packageLabel = getText("doclet.Package");
        String name = pkgdoc.name();
        printHeader(getText("doclet.Window_ClassUse_Header", 
                            Standard.configuration().windowtitle, 
                            packageLabel, name));
        navLinks(true);
        hr();
        center();
        h2();
        boldText("doclet.ClassUse_Title", packageLabel, name);
        h2End();
        centerEnd();