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

ClassUseWriter

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

Fields Summary
final ClassDoc
classdoc
final Map
pkgToSubclass
final Map
pkgToSubinterface
final Map
pkgToImplementingClass
final Map
pkgToField
final Map
pkgToMethodReturn
final Map
pkgToMethodArgs
final Map
pkgToMethodThrows
final Map
pkgToConstructorArgs
final Map
pkgToConstructorThrows
final SortedSet
pkgSet
final MethodSubWriter
methodSubWriter
final ConstructorSubWriter
constrSubWriter
final FieldSubWriter
fieldSubWriter
final ClassSubWriter
classSubWriter
Constructors Summary
public ClassUseWriter(ClassUseMapper mapper, String path, String filename, String relpath, ClassDoc classdoc)
Constructor.

param
filename the file to be generated.

        super(path, filename, relpath);
        this.classdoc = classdoc;
        HtmlStandardWriter.currentcd = classdoc;
	this.pkgSet = new TreeSet();
	this.pkgToSubclass = pkgDivide(mapper.classToSubclass);
	this.pkgToSubinterface = pkgDivide(mapper.classToSubinterface);
	this.pkgToImplementingClass = pkgDivide(mapper.classToImplementingClass);
	this.pkgToField = pkgDivide(mapper.classToField);
	this.pkgToMethodReturn = pkgDivide(mapper.classToMethodReturn);
	this.pkgToMethodArgs = pkgDivide(mapper.classToMethodArgs);
	this.pkgToMethodThrows = pkgDivide(mapper.classToMethodThrows);
	this.pkgToConstructorArgs = pkgDivide(mapper.classToConstructorArgs);
	this.pkgToConstructorThrows = pkgDivide(mapper.classToConstructorThrows);
	//tmp test
	if (!pkgSet.equals(mapper.classToPackage.get(classdoc))) {
	    System.err.println("Internal error: package sets don't match: " + pkgSet + " with: " +
			       mapper.classToPackage.get(classdoc));
	}
        methodSubWriter = new MethodSubWriter(this);
        constrSubWriter = new ConstructorSubWriter(this);
        fieldSubWriter = new FieldSubWriter(this);
        classSubWriter = new ClassSubWriter(this);
    
Methods Summary
public static voidgenerate(ClassUseMapper mapper, com.sun.javadoc.ClassDoc classdoc)
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.

            ClassUseWriter clsgen;
            String path = DirectoryManager.getDirectoryPath(classdoc.
                                                    containingPackage());
            if (path.length() > 0) {
                path += File.separator;
            }
            path += "class-use";
            String filename = classdoc.name() + ".html";
            String pkgname = classdoc.containingPackage().name();
            pkgname += (pkgname.length() > 0)? ".class-use": "class-use";
            String relpath = DirectoryManager.getRelativePath(pkgname); 
            try {
                clsgen = new ClassUseWriter(mapper, path, filename, 
                                            relpath, classdoc);
                clsgen.generateClassUseFile();
                clsgen.close();
            } catch (IOException exc) {
                Standard.configuration().standardmessage.
                    error("doclet.exception_encountered",
                           exc.toString(), filename);
                throw new DocletAbortException();
            }
    
protected voidgenerateClassList()

	for (Iterator it = pkgSet.iterator(); it.hasNext();) {
	    PackageDoc pkg = (PackageDoc)it.next();
	    anchor(pkg.name());
	    tableIndexSummary();
	    tableHeaderStart("#CCCCFF");
	    printText("doclet.ClassUse_Uses.of.0.in.1",
		      getClassLink(classdoc), 
		      getPackageLink(pkg));
	    tableHeaderEnd();
	    tableEnd();
            space();
            p();
	    generateClassUse(pkg);
	}
    
protected voidgenerateClassUse()

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

        String classLink = getClassLink(classdoc);
	String pkgLink = getPackageLink(pkg);
        classSubWriter.printUseInfo(pkgToSubclass.get(pkg),
				    getText("doclet.ClassUse_Subclass",
					    classLink, 
					    pkgLink));
        classSubWriter.printUseInfo(pkgToSubinterface.get(pkg),
				    getText("doclet.ClassUse_Subinterface",
					    classLink, 
					    pkgLink));
        classSubWriter.printUseInfo(pkgToImplementingClass.get(pkg),
				    getText("doclet.ClassUse_ImplementingClass",
					    classLink, 
					    pkgLink));
        fieldSubWriter.printUseInfo(pkgToField.get(pkg),
				    getText("doclet.ClassUse_Field",
					    classLink, 
					    pkgLink));
        methodSubWriter.printUseInfo(pkgToMethodReturn.get(pkg),
				    getText("doclet.ClassUse_MethodReturn",
					    classLink, 
					    pkgLink));
        methodSubWriter.printUseInfo(pkgToMethodArgs.get(pkg),
				    getText("doclet.ClassUse_MethodArgs",
					    classLink, 
					    pkgLink));
        methodSubWriter.printUseInfo(pkgToMethodThrows.get(pkg),
				    getText("doclet.ClassUse_MethodThrows",
					    classLink, 
					    pkgLink));
        constrSubWriter.printUseInfo(pkgToConstructorArgs.get(pkg),
				    getText("doclet.ClassUse_ConstructorArgs",
					    classLink, 
					    pkgLink));
        constrSubWriter.printUseInfo(pkgToConstructorThrows.get(pkg),
				    getText("doclet.ClassUse_ConstructorThrows",
					    classLink, 
					    pkgLink));
    
protected voidgenerateClassUseFile()
Print the class use list.


        printClassUseHeader();

	if (pkgSet.size() > 0) {
            generateClassUse();
        } else {
            printText("doclet.ClassUse_No.usage.of.0", 
                     classdoc.qualifiedName());
            p();
        }
        
        printClassUseFooter();
    
protected voidgeneratePackageList()

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

	for (Iterator it = pkgSet.iterator(); it.hasNext();) {
	    PackageDoc pkg = (PackageDoc)it.next();
	    generatePackageUse(pkg);
	}
	tableEnd();
	space();
	p();
    
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 voidnavLinkClass()
Print class page indicator

        navCellStart();
        printClassLink(classdoc, "", getText("doclet.Class"), true, "NavBarFont1");
        navCellEnd();
    
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();
        if (classdoc.containingPackage().isIncluded()) {
            printHyperLink("../package-tree.html", "", getText("doclet.Tree"),
                           true, "NavBarFont1");
        } else {
            printHyperLink(relativepath + "overview-tree.html", "", 
                           getText("doclet.Tree"), true, "NavBarFont1");
        }
        navCellEnd();
    
private java.util.MappkgDivide(java.util.Map classMap)

        Map map = new HashMap();
        List list= (List)classMap.get(classdoc);
        if (list != null) {
            Iterator it = list.iterator();
            while (it.hasNext()) {
                ProgramElementDoc doc = (ProgramElementDoc)it.next();
                PackageDoc pkg = doc.containingPackage();
                pkgSet.add(pkg);
                List inPkg = (List)map.get(pkg);
                if (inPkg == null) {
                    inPkg = new ArrayList();
                    map.put(pkg, inPkg);
                }
                inPkg.add(doc);
            }
        }
        return map;
    
protected voidprintClassUseFooter()
Print the footer for the class use Listing.

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

        String cltype = getText(classdoc.isInterface()? 
                                    "doclet.Interface": 
                                    "doclet.Class");
        String clname = classdoc.qualifiedName();
        printHeader(getText("doclet.Window_ClassUse_Header", 
                            Standard.configuration().windowtitle, 
                            cltype, clname));
        navLinks(true);
        hr();
        center();
        h2();
        boldText("doclet.ClassUse_Title", cltype, clname);
        h2End();
        centerEnd();