diff -r bcbc86cc5b31 -r 90af8d87741f src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java Tue Nov 30 09:38:48 2010 -0800 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java Wed Dec 01 11:02:38 2010 -0800 @@ -25,11 +25,11 @@ package com.sun.tools.doclets.internal.toolkit.builders; +import java.io.*; +import java.util.*; +import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; -import com.sun.javadoc.*; -import java.io.*; -import java.util.*; /** * Builds the Constants Summary Page. @@ -39,6 +39,7 @@ * Do not use it as an API * * @author Jamie Ho + * @author Bhavesh Patel (Modified) * @since 1.5 */ public class ConstantsSummaryBuilder extends AbstractBuilder { @@ -80,6 +81,11 @@ private ClassDoc currentClass; /** + * The content tree for the constant summary documentation. + */ + private Content contentTree; + + /** * Construct a new ConstantsSummaryBuilder. * * @param configuration the current configuration of the @@ -113,7 +119,7 @@ //Doclet does not support this output. return; } - build(LayoutParser.getInstance(configuration).parseXML(ROOT)); + build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree); } /** @@ -126,85 +132,85 @@ /** * Build the constant summary. * - * @param elements the list of elements describing constant summary - * documentation. + * @param node the XML element that specifies which components to document + * @param contentTree the content tree to which the documentation will be added */ - public void buildConstantSummary(XMLNode node) throws Exception { - buildChildren(node); + public void buildConstantSummary(XMLNode node, Content contentTree) throws Exception { + contentTree = writer.getHeader(); + buildChildren(node, contentTree); + writer.addFooter(contentTree); + writer.printDocument(contentTree); writer.close(); } /** - * Build the header. + * Build the list of packages. + * + * @param node the XML element that specifies which components to document + * @param contentTree the content tree to which the content list will be added */ - public void buildHeader(XMLNode node) { - writer.writeHeader(); - } - - /** - * Build the footer. - */ - public void buildFooter(XMLNode node) { - writer.writeFooter(); - } - - /** - * Build the table of contents. - */ - public void buildContents(XMLNode node) { - writer.writeContentsHeader(); + public void buildContents(XMLNode node, Content contentTree) { + Content contentListTree = writer.getContentsHeader(); PackageDoc[] packages = configuration.packages; printedPackageHeaders = new HashSet(); for (int i = 0; i < packages.length; i++) { if (hasConstantField(packages[i]) && ! hasPrintedPackageIndex(packages[i].name())) { - writer.writeLinkToPackageContent(packages[i], + writer.addLinkToPackageContent(packages[i], parsePackageName(packages[i].name()), - printedPackageHeaders); + printedPackageHeaders, contentListTree); } } - writer.writeContentsFooter(); + contentTree.addContent(writer.getContentsList(contentListTree)); } /** * Build the summary for each documented package. * - * @param elements the XML elements that represent the components - * of documentation for each package. + * @param node the XML element that specifies which components to document + * @param contentTree the tree to which the summaries will be added */ - public void buildConstantSummaries(XMLNode node) { + public void buildConstantSummaries(XMLNode node, Content contentTree) { PackageDoc[] packages = configuration.packages; printedPackageHeaders = new HashSet(); + Content summariesTree = writer.getConstantSummaries(); for (int i = 0; i < packages.length; i++) { if (hasConstantField(packages[i])) { currentPackage = packages[i]; //Build the documentation for the current package. - buildChildren(node); + buildChildren(node, summariesTree); } } + contentTree.addContent(summariesTree); } /** - * Build the summary for the current package. + * Build the header for the given package. * - * @param elements the list of XML elements that make up package - * documentation. + * @param node the XML element that specifies which components to document + * @param summariesTree the tree to which the package header will be added */ - public void buildPackageConstantSummary(XMLNode node) { - buildChildren(node); + public void buildPackageHeader(XMLNode node, Content summariesTree) { + String parsedPackageName = parsePackageName(currentPackage.name()); + if (! printedPackageHeaders.contains(parsedPackageName)) { + writer.addPackageName(currentPackage, + parsePackageName(currentPackage.name()), summariesTree); + printedPackageHeaders.add(parsedPackageName); + } } /** * Build the summary for the current class. * - * @param elements the list of XML elements that make up the class - * constant summary. + * @param node the XML element that specifies which components to document + * @param summariesTree the tree to which the class constant summary will be added */ - public void buildClassConstantSummary(XMLNode node) { + public void buildClassConstantSummary(XMLNode node, Content summariesTree) { ClassDoc[] classes = currentPackage.name().length() > 0 ? currentPackage.allClasses() : configuration.classDocCatalog.allClasses( DocletConstants.DEFAULT_PACKAGE_NAME); Arrays.sort(classes); + Content classConstantTree = writer.getClassConstantHeader(); for (int i = 0; i < classes.length; i++) { if (! classDocsWithConstFields.contains(classes[i]) || ! classes[i].isIncluded()) { @@ -212,42 +218,20 @@ } currentClass = classes[i]; //Build the documentation for the current class. - buildChildren(node); + buildChildren(node, classConstantTree); } + summariesTree.addContent(classConstantTree); } /** - * Build the header for the given class. + * Build the summary of constant members in the class. + * + * @param node the XML element that specifies which components to document + * @param classConstantTree the tree to which the constant members table + * will be added */ - public void buildPackageHeader(XMLNode node) { - String parsedPackageName = parsePackageName(currentPackage.name()); - if (! printedPackageHeaders.contains(parsedPackageName)) { - writer.writePackageName(currentPackage, - parsePackageName(currentPackage.name())); - printedPackageHeaders.add(parsedPackageName); - } - } - - /** - * Build the header for the given class. - */ - public void buildClassHeader(XMLNode node) { - writer.writeConstantMembersHeader(currentClass); - } - - /** - * Print summary of constant members in the - * class. - */ - public void buildConstantMembers(XMLNode node) { - new ConstantFieldBuilder(currentClass).buildMembersSummary(node); - } - - /** - * Build the footer for the given class. - */ - public void buildClassFooter(XMLNode node) { - writer.writeConstantMembersFooter(currentClass); + public void buildConstantMembers(XMLNode node, Content classConstantTree) { + new ConstantFieldBuilder(currentClass).buildMembersSummary(node, classConstantTree); } /** @@ -346,12 +330,16 @@ /** * Builds the table of constants for a given class. + * + * @param node the XML element that specifies which components to document + * @param classConstantTree the tree to which the class constants table + * will be added */ - protected void buildMembersSummary(XMLNode node) { + protected void buildMembersSummary(XMLNode node, Content classConstantTree) { List members = new ArrayList(members()); if (members.size() > 0) { Collections.sort(members); - writer.writeConstantMembers(classdoc, members); + writer.addConstantMembers(classdoc, members, classConstantTree); } }