1.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java Tue Nov 30 09:38:48 2010 -0800 1.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java Wed Dec 01 11:02:38 2010 -0800 1.3 @@ -25,11 +25,11 @@ 1.4 1.5 package com.sun.tools.doclets.internal.toolkit.builders; 1.6 1.7 +import java.io.*; 1.8 +import java.util.*; 1.9 +import com.sun.javadoc.*; 1.10 import com.sun.tools.doclets.internal.toolkit.util.*; 1.11 import com.sun.tools.doclets.internal.toolkit.*; 1.12 -import com.sun.javadoc.*; 1.13 -import java.io.*; 1.14 -import java.util.*; 1.15 1.16 /** 1.17 * Builds the Constants Summary Page. 1.18 @@ -39,6 +39,7 @@ 1.19 * Do not use it as an API 1.20 * 1.21 * @author Jamie Ho 1.22 + * @author Bhavesh Patel (Modified) 1.23 * @since 1.5 1.24 */ 1.25 public class ConstantsSummaryBuilder extends AbstractBuilder { 1.26 @@ -80,6 +81,11 @@ 1.27 private ClassDoc currentClass; 1.28 1.29 /** 1.30 + * The content tree for the constant summary documentation. 1.31 + */ 1.32 + private Content contentTree; 1.33 + 1.34 + /** 1.35 * Construct a new ConstantsSummaryBuilder. 1.36 * 1.37 * @param configuration the current configuration of the 1.38 @@ -113,7 +119,7 @@ 1.39 //Doclet does not support this output. 1.40 return; 1.41 } 1.42 - build(LayoutParser.getInstance(configuration).parseXML(ROOT)); 1.43 + build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree); 1.44 } 1.45 1.46 /** 1.47 @@ -126,85 +132,85 @@ 1.48 /** 1.49 * Build the constant summary. 1.50 * 1.51 - * @param elements the list of elements describing constant summary 1.52 - * documentation. 1.53 + * @param node the XML element that specifies which components to document 1.54 + * @param contentTree the content tree to which the documentation will be added 1.55 */ 1.56 - public void buildConstantSummary(XMLNode node) throws Exception { 1.57 - buildChildren(node); 1.58 + public void buildConstantSummary(XMLNode node, Content contentTree) throws Exception { 1.59 + contentTree = writer.getHeader(); 1.60 + buildChildren(node, contentTree); 1.61 + writer.addFooter(contentTree); 1.62 + writer.printDocument(contentTree); 1.63 writer.close(); 1.64 } 1.65 1.66 /** 1.67 - * Build the header. 1.68 + * Build the list of packages. 1.69 + * 1.70 + * @param node the XML element that specifies which components to document 1.71 + * @param contentTree the content tree to which the content list will be added 1.72 */ 1.73 - public void buildHeader(XMLNode node) { 1.74 - writer.writeHeader(); 1.75 - } 1.76 - 1.77 - /** 1.78 - * Build the footer. 1.79 - */ 1.80 - public void buildFooter(XMLNode node) { 1.81 - writer.writeFooter(); 1.82 - } 1.83 - 1.84 - /** 1.85 - * Build the table of contents. 1.86 - */ 1.87 - public void buildContents(XMLNode node) { 1.88 - writer.writeContentsHeader(); 1.89 + public void buildContents(XMLNode node, Content contentTree) { 1.90 + Content contentListTree = writer.getContentsHeader(); 1.91 PackageDoc[] packages = configuration.packages; 1.92 printedPackageHeaders = new HashSet<String>(); 1.93 for (int i = 0; i < packages.length; i++) { 1.94 if (hasConstantField(packages[i]) && ! hasPrintedPackageIndex(packages[i].name())) { 1.95 - writer.writeLinkToPackageContent(packages[i], 1.96 + writer.addLinkToPackageContent(packages[i], 1.97 parsePackageName(packages[i].name()), 1.98 - printedPackageHeaders); 1.99 + printedPackageHeaders, contentListTree); 1.100 } 1.101 } 1.102 - writer.writeContentsFooter(); 1.103 + contentTree.addContent(writer.getContentsList(contentListTree)); 1.104 } 1.105 1.106 /** 1.107 * Build the summary for each documented package. 1.108 * 1.109 - * @param elements the XML elements that represent the components 1.110 - * of documentation for each package. 1.111 + * @param node the XML element that specifies which components to document 1.112 + * @param contentTree the tree to which the summaries will be added 1.113 */ 1.114 - public void buildConstantSummaries(XMLNode node) { 1.115 + public void buildConstantSummaries(XMLNode node, Content contentTree) { 1.116 PackageDoc[] packages = configuration.packages; 1.117 printedPackageHeaders = new HashSet<String>(); 1.118 + Content summariesTree = writer.getConstantSummaries(); 1.119 for (int i = 0; i < packages.length; i++) { 1.120 if (hasConstantField(packages[i])) { 1.121 currentPackage = packages[i]; 1.122 //Build the documentation for the current package. 1.123 - buildChildren(node); 1.124 + buildChildren(node, summariesTree); 1.125 } 1.126 } 1.127 + contentTree.addContent(summariesTree); 1.128 } 1.129 1.130 /** 1.131 - * Build the summary for the current package. 1.132 + * Build the header for the given package. 1.133 * 1.134 - * @param elements the list of XML elements that make up package 1.135 - * documentation. 1.136 + * @param node the XML element that specifies which components to document 1.137 + * @param summariesTree the tree to which the package header will be added 1.138 */ 1.139 - public void buildPackageConstantSummary(XMLNode node) { 1.140 - buildChildren(node); 1.141 + public void buildPackageHeader(XMLNode node, Content summariesTree) { 1.142 + String parsedPackageName = parsePackageName(currentPackage.name()); 1.143 + if (! printedPackageHeaders.contains(parsedPackageName)) { 1.144 + writer.addPackageName(currentPackage, 1.145 + parsePackageName(currentPackage.name()), summariesTree); 1.146 + printedPackageHeaders.add(parsedPackageName); 1.147 + } 1.148 } 1.149 1.150 /** 1.151 * Build the summary for the current class. 1.152 * 1.153 - * @param elements the list of XML elements that make up the class 1.154 - * constant summary. 1.155 + * @param node the XML element that specifies which components to document 1.156 + * @param summariesTree the tree to which the class constant summary will be added 1.157 */ 1.158 - public void buildClassConstantSummary(XMLNode node) { 1.159 + public void buildClassConstantSummary(XMLNode node, Content summariesTree) { 1.160 ClassDoc[] classes = currentPackage.name().length() > 0 ? 1.161 currentPackage.allClasses() : 1.162 configuration.classDocCatalog.allClasses( 1.163 DocletConstants.DEFAULT_PACKAGE_NAME); 1.164 Arrays.sort(classes); 1.165 + Content classConstantTree = writer.getClassConstantHeader(); 1.166 for (int i = 0; i < classes.length; i++) { 1.167 if (! classDocsWithConstFields.contains(classes[i]) || 1.168 ! classes[i].isIncluded()) { 1.169 @@ -212,42 +218,20 @@ 1.170 } 1.171 currentClass = classes[i]; 1.172 //Build the documentation for the current class. 1.173 - buildChildren(node); 1.174 + buildChildren(node, classConstantTree); 1.175 } 1.176 + summariesTree.addContent(classConstantTree); 1.177 } 1.178 1.179 /** 1.180 - * Build the header for the given class. 1.181 + * Build the summary of constant members in the class. 1.182 + * 1.183 + * @param node the XML element that specifies which components to document 1.184 + * @param classConstantTree the tree to which the constant members table 1.185 + * will be added 1.186 */ 1.187 - public void buildPackageHeader(XMLNode node) { 1.188 - String parsedPackageName = parsePackageName(currentPackage.name()); 1.189 - if (! printedPackageHeaders.contains(parsedPackageName)) { 1.190 - writer.writePackageName(currentPackage, 1.191 - parsePackageName(currentPackage.name())); 1.192 - printedPackageHeaders.add(parsedPackageName); 1.193 - } 1.194 - } 1.195 - 1.196 - /** 1.197 - * Build the header for the given class. 1.198 - */ 1.199 - public void buildClassHeader(XMLNode node) { 1.200 - writer.writeConstantMembersHeader(currentClass); 1.201 - } 1.202 - 1.203 - /** 1.204 - * Print summary of constant members in the 1.205 - * class. 1.206 - */ 1.207 - public void buildConstantMembers(XMLNode node) { 1.208 - new ConstantFieldBuilder(currentClass).buildMembersSummary(node); 1.209 - } 1.210 - 1.211 - /** 1.212 - * Build the footer for the given class. 1.213 - */ 1.214 - public void buildClassFooter(XMLNode node) { 1.215 - writer.writeConstantMembersFooter(currentClass); 1.216 + public void buildConstantMembers(XMLNode node, Content classConstantTree) { 1.217 + new ConstantFieldBuilder(currentClass).buildMembersSummary(node, classConstantTree); 1.218 } 1.219 1.220 /** 1.221 @@ -346,12 +330,16 @@ 1.222 1.223 /** 1.224 * Builds the table of constants for a given class. 1.225 + * 1.226 + * @param node the XML element that specifies which components to document 1.227 + * @param classConstantTree the tree to which the class constants table 1.228 + * will be added 1.229 */ 1.230 - protected void buildMembersSummary(XMLNode node) { 1.231 + protected void buildMembersSummary(XMLNode node, Content classConstantTree) { 1.232 List<FieldDoc> members = new ArrayList<FieldDoc>(members()); 1.233 if (members.size() > 0) { 1.234 Collections.sort(members); 1.235 - writer.writeConstantMembers(classdoc, members); 1.236 + writer.addConstantMembers(classdoc, members, classConstantTree); 1.237 } 1.238 } 1.239