1.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java Tue Nov 30 09:38:48 2010 -0800 1.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java Wed Dec 01 11:02:38 2010 -0800 1.3 @@ -25,10 +25,10 @@ 1.4 1.5 package com.sun.tools.doclets.internal.toolkit.builders; 1.6 1.7 +import java.util.*; 1.8 import com.sun.tools.doclets.internal.toolkit.util.*; 1.9 import com.sun.tools.doclets.internal.toolkit.*; 1.10 import com.sun.javadoc.*; 1.11 -import java.util.*; 1.12 1.13 /** 1.14 * Builds documentation for a enum constants. 1.15 @@ -38,200 +38,195 @@ 1.16 * Do not use it as an API 1.17 * 1.18 * @author Jamie Ho 1.19 + * @author Bhavesh Patel (Modified) 1.20 * @since 1.5 1.21 */ 1.22 public class EnumConstantBuilder extends AbstractMemberBuilder { 1.23 1.24 - /** 1.25 - * The class whose enum constants are being documented. 1.26 - */ 1.27 - private ClassDoc classDoc; 1.28 + /** 1.29 + * The class whose enum constants are being documented. 1.30 + */ 1.31 + private ClassDoc classDoc; 1.32 1.33 - /** 1.34 - * The visible enum constantss for the given class. 1.35 - */ 1.36 - private VisibleMemberMap visibleMemberMap; 1.37 + /** 1.38 + * The visible enum constantss for the given class. 1.39 + */ 1.40 + private VisibleMemberMap visibleMemberMap; 1.41 1.42 - /** 1.43 - * The writer to output the enum constants documentation. 1.44 - */ 1.45 - private EnumConstantWriter writer; 1.46 + /** 1.47 + * The writer to output the enum constants documentation. 1.48 + */ 1.49 + private EnumConstantWriter writer; 1.50 1.51 - /** 1.52 - * The list of enum constants being documented. 1.53 - */ 1.54 - private List<ProgramElementDoc> enumConstants; 1.55 + /** 1.56 + * The list of enum constants being documented. 1.57 + */ 1.58 + private List<ProgramElementDoc> enumConstants; 1.59 1.60 - /** 1.61 - * The index of the current enum constant that is being documented at this point 1.62 - * in time. 1.63 - */ 1.64 - private int currentEnumConstantsIndex; 1.65 + /** 1.66 + * The index of the current enum constant that is being documented at this point 1.67 + * in time. 1.68 + */ 1.69 + private int currentEnumConstantsIndex; 1.70 1.71 - /** 1.72 - * Construct a new EnumConstantsBuilder. 1.73 - * 1.74 - * @param configuration the current configuration of the 1.75 - * doclet. 1.76 - */ 1.77 - private EnumConstantBuilder(Configuration configuration) { 1.78 - super(configuration); 1.79 + /** 1.80 + * Construct a new EnumConstantsBuilder. 1.81 + * 1.82 + * @param configuration the current configuration of the 1.83 + * doclet. 1.84 + */ 1.85 + private EnumConstantBuilder(Configuration configuration) { 1.86 + super(configuration); 1.87 + } 1.88 + 1.89 + /** 1.90 + * Construct a new EnumConstantsBuilder. 1.91 + * 1.92 + * @param configuration the current configuration of the doclet. 1.93 + * @param classDoc the class whoses members are being documented. 1.94 + * @param writer the doclet specific writer. 1.95 + */ 1.96 + public static EnumConstantBuilder getInstance( 1.97 + Configuration configuration, 1.98 + ClassDoc classDoc, 1.99 + EnumConstantWriter writer) { 1.100 + EnumConstantBuilder builder = new EnumConstantBuilder(configuration); 1.101 + builder.classDoc = classDoc; 1.102 + builder.writer = writer; 1.103 + builder.visibleMemberMap = 1.104 + new VisibleMemberMap( 1.105 + classDoc, 1.106 + VisibleMemberMap.ENUM_CONSTANTS, 1.107 + configuration.nodeprecated); 1.108 + builder.enumConstants = 1.109 + new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getMembersFor(classDoc)); 1.110 + if (configuration.getMemberComparator() != null) { 1.111 + Collections.sort( 1.112 + builder.enumConstants, 1.113 + configuration.getMemberComparator()); 1.114 } 1.115 + return builder; 1.116 + } 1.117 1.118 - /** 1.119 - * Construct a new EnumConstantsBuilder. 1.120 - * 1.121 - * @param configuration the current configuration of the doclet. 1.122 - * @param classDoc the class whoses members are being documented. 1.123 - * @param writer the doclet specific writer. 1.124 - */ 1.125 - public static EnumConstantBuilder getInstance( 1.126 - Configuration configuration, 1.127 - ClassDoc classDoc, 1.128 - EnumConstantWriter writer) { 1.129 - EnumConstantBuilder builder = new EnumConstantBuilder(configuration); 1.130 - builder.classDoc = classDoc; 1.131 - builder.writer = writer; 1.132 - builder.visibleMemberMap = 1.133 - new VisibleMemberMap( 1.134 - classDoc, 1.135 - VisibleMemberMap.ENUM_CONSTANTS, 1.136 - configuration.nodeprecated); 1.137 - builder.enumConstants = 1.138 - new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getMembersFor(classDoc)); 1.139 - if (configuration.getMemberComparator() != null) { 1.140 - Collections.sort( 1.141 - builder.enumConstants, 1.142 - configuration.getMemberComparator()); 1.143 - } 1.144 - return builder; 1.145 + /** 1.146 + * {@inheritDoc} 1.147 + */ 1.148 + public String getName() { 1.149 + return "EnumConstantDetails"; 1.150 + } 1.151 + 1.152 + /** 1.153 + * Returns a list of enum constants that will be documented for the given class. 1.154 + * This information can be used for doclet specific documentation 1.155 + * generation. 1.156 + * 1.157 + * @param classDoc the {@link ClassDoc} we want to check. 1.158 + * @return a list of enum constants that will be documented. 1.159 + */ 1.160 + public List<ProgramElementDoc> members(ClassDoc classDoc) { 1.161 + return visibleMemberMap.getMembersFor(classDoc); 1.162 + } 1.163 + 1.164 + /** 1.165 + * Returns the visible member map for the enum constants of this class. 1.166 + * 1.167 + * @return the visible member map for the enum constants of this class. 1.168 + */ 1.169 + public VisibleMemberMap getVisibleMemberMap() { 1.170 + return visibleMemberMap; 1.171 + } 1.172 + 1.173 + /** 1.174 + * summaryOrder.size() 1.175 + */ 1.176 + public boolean hasMembersToDocument() { 1.177 + return enumConstants.size() > 0; 1.178 + } 1.179 + 1.180 + /** 1.181 + * Build the enum constant documentation. 1.182 + * 1.183 + * @param node the XML element that specifies which components to document 1.184 + * @param memberDetailsTree the content tree to which the documentation will be added 1.185 + */ 1.186 + public void buildEnumConstant(XMLNode node, Content memberDetailsTree) { 1.187 + if (writer == null) { 1.188 + return; 1.189 } 1.190 + int size = enumConstants.size(); 1.191 + if (size > 0) { 1.192 + Content enumConstantsDetailsTree = writer.getEnumConstantsDetailsTreeHeader( 1.193 + classDoc, memberDetailsTree); 1.194 + for (currentEnumConstantsIndex = 0; currentEnumConstantsIndex < size; 1.195 + currentEnumConstantsIndex++) { 1.196 + Content enumConstantsTree = writer.getEnumConstantsTreeHeader( 1.197 + (FieldDoc) enumConstants.get(currentEnumConstantsIndex), 1.198 + enumConstantsDetailsTree); 1.199 + buildChildren(node, enumConstantsTree); 1.200 + enumConstantsDetailsTree.addContent(writer.getEnumConstants( 1.201 + enumConstantsTree, (currentEnumConstantsIndex == size - 1))); 1.202 + } 1.203 + memberDetailsTree.addContent( 1.204 + writer.getEnumConstantsDetails(enumConstantsDetailsTree)); 1.205 + } 1.206 + } 1.207 1.208 - /** 1.209 - * {@inheritDoc} 1.210 - */ 1.211 - public String getName() { 1.212 - return "EnumConstantDetails"; 1.213 + /** 1.214 + * Build the signature. 1.215 + * 1.216 + * @param node the XML element that specifies which components to document 1.217 + * @param enumConstantsTree the content tree to which the documentation will be added 1.218 + */ 1.219 + public void buildSignature(XMLNode node, Content enumConstantsTree) { 1.220 + enumConstantsTree.addContent(writer.getSignature( 1.221 + (FieldDoc) enumConstants.get(currentEnumConstantsIndex))); 1.222 + } 1.223 + 1.224 + /** 1.225 + * Build the deprecation information. 1.226 + * 1.227 + * @param node the XML element that specifies which components to document 1.228 + * @param enumConstantsTree the content tree to which the documentation will be added 1.229 + */ 1.230 + public void buildDeprecationInfo(XMLNode node, Content enumConstantsTree) { 1.231 + writer.addDeprecated( 1.232 + (FieldDoc) enumConstants.get(currentEnumConstantsIndex), 1.233 + enumConstantsTree); 1.234 + } 1.235 + 1.236 + /** 1.237 + * Build the comments for the enum constant. Do nothing if 1.238 + * {@link Configuration#nocomment} is set to true. 1.239 + * 1.240 + * @param node the XML element that specifies which components to document 1.241 + * @param enumConstantsTree the content tree to which the documentation will be added 1.242 + */ 1.243 + public void buildEnumConstantComments(XMLNode node, Content enumConstantsTree) { 1.244 + if (!configuration.nocomment) { 1.245 + writer.addComments( 1.246 + (FieldDoc) enumConstants.get(currentEnumConstantsIndex), 1.247 + enumConstantsTree); 1.248 } 1.249 + } 1.250 1.251 - /** 1.252 - * Returns a list of enum constants that will be documented for the given class. 1.253 - * This information can be used for doclet specific documentation 1.254 - * generation. 1.255 - * 1.256 - * @param classDoc the {@link ClassDoc} we want to check. 1.257 - * @return a list of enum constants that will be documented. 1.258 - */ 1.259 - public List<ProgramElementDoc> members(ClassDoc classDoc) { 1.260 - return visibleMemberMap.getMembersFor(classDoc); 1.261 - } 1.262 + /** 1.263 + * Build the tag information. 1.264 + * 1.265 + * @param node the XML element that specifies which components to document 1.266 + * @param enumConstantsTree the content tree to which the documentation will be added 1.267 + */ 1.268 + public void buildTagInfo(XMLNode node, Content enumConstantsTree) { 1.269 + writer.addTags( 1.270 + (FieldDoc) enumConstants.get(currentEnumConstantsIndex), 1.271 + enumConstantsTree); 1.272 + } 1.273 1.274 - /** 1.275 - * Returns the visible member map for the enum constants of this class. 1.276 - * 1.277 - * @return the visible member map for the enum constants of this class. 1.278 - */ 1.279 - public VisibleMemberMap getVisibleMemberMap() { 1.280 - return visibleMemberMap; 1.281 - } 1.282 - 1.283 - /** 1.284 - * summaryOrder.size() 1.285 - */ 1.286 - public boolean hasMembersToDocument() { 1.287 - return enumConstants.size() > 0; 1.288 - } 1.289 - 1.290 - /** 1.291 - * Build the enum constant documentation. 1.292 - * 1.293 - * @param elements the XML elements that specify how to construct this 1.294 - * documentation. 1.295 - */ 1.296 - public void buildEnumConstant(XMLNode node) { 1.297 - if (writer == null) { 1.298 - return; 1.299 - } 1.300 - for (currentEnumConstantsIndex = 0; 1.301 - currentEnumConstantsIndex < enumConstants.size(); 1.302 - currentEnumConstantsIndex++) { 1.303 - buildChildren(node); 1.304 - } 1.305 - } 1.306 - 1.307 - /** 1.308 - * Build the overall header. 1.309 - */ 1.310 - public void buildHeader(XMLNode node) { 1.311 - writer.writeHeader( 1.312 - classDoc, 1.313 - configuration.getText("doclet.Enum_Constant_Detail")); 1.314 - } 1.315 - 1.316 - /** 1.317 - * Build the header for the individual enum constants. 1.318 - */ 1.319 - public void buildEnumConstantHeader(XMLNode node) { 1.320 - writer.writeEnumConstantHeader( 1.321 - (FieldDoc) enumConstants.get(currentEnumConstantsIndex), 1.322 - currentEnumConstantsIndex == 0); 1.323 - } 1.324 - 1.325 - /** 1.326 - * Build the signature. 1.327 - */ 1.328 - public void buildSignature(XMLNode node) { 1.329 - writer.writeSignature( 1.330 - (FieldDoc) enumConstants.get(currentEnumConstantsIndex)); 1.331 - } 1.332 - 1.333 - /** 1.334 - * Build the deprecation information. 1.335 - */ 1.336 - public void buildDeprecationInfo(XMLNode node) { 1.337 - writer.writeDeprecated( 1.338 - (FieldDoc) enumConstants.get(currentEnumConstantsIndex)); 1.339 - } 1.340 - 1.341 - /** 1.342 - * Build the comments for the enum constant. Do nothing if 1.343 - * {@link Configuration#nocomment} is set to true. 1.344 - */ 1.345 - public void buildEnumConstantComments(XMLNode node) { 1.346 - if (!configuration.nocomment) { 1.347 - writer.writeComments( 1.348 - (FieldDoc) enumConstants.get(currentEnumConstantsIndex)); 1.349 - } 1.350 - } 1.351 - 1.352 - /** 1.353 - * Build the tag information. 1.354 - */ 1.355 - public void buildTagInfo(XMLNode node) { 1.356 - writer.writeTags( 1.357 - (FieldDoc) enumConstants.get(currentEnumConstantsIndex)); 1.358 - } 1.359 - 1.360 - /** 1.361 - * Build the footer for the individual enum constants. 1.362 - */ 1.363 - public void buildEnumConstantFooter(XMLNode node) { 1.364 - writer.writeEnumConstantFooter(); 1.365 - } 1.366 - 1.367 - /** 1.368 - * Build the overall footer. 1.369 - */ 1.370 - public void buildFooter(XMLNode node) { 1.371 - writer.writeFooter(classDoc); 1.372 - } 1.373 - 1.374 - /** 1.375 - * Return the enum constant writer for this builder. 1.376 - * 1.377 - * @return the enum constant writer for this builder. 1.378 - */ 1.379 - public EnumConstantWriter getWriter() { 1.380 - return writer; 1.381 - } 1.382 + /** 1.383 + * Return the enum constant writer for this builder. 1.384 + * 1.385 + * @return the enum constant writer for this builder. 1.386 + */ 1.387 + public EnumConstantWriter getWriter() { 1.388 + return writer; 1.389 + } 1.390 }