langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java
changeset 40587 1c355ea550ed
parent 40303 96a1226aca18
child 42000 8b7412f7eecd
equal deleted inserted replaced
40519:e17429a7e843 40587:1c355ea550ed
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package jdk.javadoc.internal.doclets.toolkit.builders;
    26 package jdk.javadoc.internal.doclets.toolkit.builders;
    27 
    27 
    28 import java.io.*;
       
    29 import java.util.*;
    28 import java.util.*;
    30 
    29 
    31 import javax.lang.model.element.Element;
    30 import javax.lang.model.element.Element;
    32 import javax.lang.model.element.PackageElement;
    31 import javax.lang.model.element.PackageElement;
    33 import javax.lang.model.element.TypeElement;
    32 import javax.lang.model.element.TypeElement;
    34 import javax.lang.model.element.VariableElement;
    33 import javax.lang.model.element.VariableElement;
    35 
    34 
    36 import jdk.javadoc.internal.doclets.toolkit.ConstantsSummaryWriter;
    35 import jdk.javadoc.internal.doclets.toolkit.ConstantsSummaryWriter;
    37 import jdk.javadoc.internal.doclets.toolkit.Content;
    36 import jdk.javadoc.internal.doclets.toolkit.Content;
       
    37 import jdk.javadoc.internal.doclets.toolkit.DocletException;
    38 import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
    38 import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
    39 
    39 
    40 
    40 
    41 /**
    41 /**
    42  * Builds the Constants Summary Page.
    42  * Builds the Constants Summary Page.
   114     /**
   114     /**
   115      * Construct a ConstantsSummaryBuilder.
   115      * Construct a ConstantsSummaryBuilder.
   116      *
   116      *
   117      * @param context       the build context.
   117      * @param context       the build context.
   118      * @param writer        the writer for the summary.
   118      * @param writer        the writer for the summary.
       
   119      * @return the new ConstantsSummaryBuilder
   119      */
   120      */
   120     public static ConstantsSummaryBuilder getInstance(Context context,
   121     public static ConstantsSummaryBuilder getInstance(Context context,
   121             ConstantsSummaryWriter writer) {
   122             ConstantsSummaryWriter writer) {
   122         return new ConstantsSummaryBuilder(context, writer);
   123         return new ConstantsSummaryBuilder(context, writer);
   123     }
   124     }
   124 
   125 
   125     /**
   126     /**
   126      * {@inheritDoc}
   127      * {@inheritDoc}
       
   128      * @throws DocletException if there is a problem while building the documentation
   127      */
   129      */
   128     @Override
   130     @Override
   129     public void build() throws IOException {
   131     public void build() throws DocletException {
   130         if (writer == null) {
   132         if (writer == null) {
   131             //Doclet does not support this output.
   133             //Doclet does not support this output.
   132             return;
   134             return;
   133         }
   135         }
   134         build(layoutParser.parseXML(ROOT), contentTree);
   136         build(layoutParser.parseXML(ROOT), contentTree);
   145     /**
   147     /**
   146      * Build the constant summary.
   148      * Build the constant summary.
   147      *
   149      *
   148      * @param node the XML element that specifies which components to document
   150      * @param node the XML element that specifies which components to document
   149      * @param contentTree the content tree to which the documentation will be added
   151      * @param contentTree the content tree to which the documentation will be added
   150      */
   152      * @throws DocletException if there is a problem while building the documentation
   151     public void buildConstantSummary(XMLNode node, Content contentTree) throws Exception {
   153      */
       
   154     public void buildConstantSummary(XMLNode node, Content contentTree) throws DocletException {
   152         contentTree = writer.getHeader();
   155         contentTree = writer.getHeader();
   153         buildChildren(node, contentTree);
   156         buildChildren(node, contentTree);
   154         writer.addFooter(contentTree);
   157         writer.addFooter(contentTree);
   155         writer.printDocument(contentTree);
   158         writer.printDocument(contentTree);
   156     }
   159     }
   175     /**
   178     /**
   176      * Build the summary for each documented package.
   179      * Build the summary for each documented package.
   177      *
   180      *
   178      * @param node the XML element that specifies which components to document
   181      * @param node the XML element that specifies which components to document
   179      * @param contentTree the tree to which the summaries will be added
   182      * @param contentTree the tree to which the summaries will be added
   180      */
   183      * @throws DocletException if there is a problem while building the documentation
   181     public void buildConstantSummaries(XMLNode node, Content contentTree) {
   184      */
       
   185     public void buildConstantSummaries(XMLNode node, Content contentTree) throws DocletException {
   182         printedPackageHeaders.clear();
   186         printedPackageHeaders.clear();
   183         Content summariesTree = writer.getConstantSummaries();
   187         Content summariesTree = writer.getConstantSummaries();
   184         for (PackageElement aPackage : configuration.packages) {
   188         for (PackageElement aPackage : configuration.packages) {
   185             if (hasConstantField(aPackage)) {
   189             if (hasConstantField(aPackage)) {
   186                 currentPackage = aPackage;
   190                 currentPackage = aPackage;
   209     /**
   213     /**
   210      * Build the summary for the current class.
   214      * Build the summary for the current class.
   211      *
   215      *
   212      * @param node the XML element that specifies which components to document
   216      * @param node the XML element that specifies which components to document
   213      * @param summariesTree the tree to which the class constant summary will be added
   217      * @param summariesTree the tree to which the class constant summary will be added
   214      */
   218      * @throws DocletException if there is a problem while building the documentation
   215     public void buildClassConstantSummary(XMLNode node, Content summariesTree) {
   219      *
       
   220      */
       
   221     public void buildClassConstantSummary(XMLNode node, Content summariesTree)
       
   222             throws DocletException {
   216         SortedSet<TypeElement> classes = !currentPackage.isUnnamed()
   223         SortedSet<TypeElement> classes = !currentPackage.isUnnamed()
   217                 ? utils.getAllClasses(currentPackage)
   224                 ? utils.getAllClasses(currentPackage)
   218                 : configuration.typeElementCatalog.allUnnamedClasses();
   225                 : configuration.typeElementCatalog.allUnnamedClasses();
   219         Content classConstantTree = writer.getClassConstantHeader();
   226         Content classConstantTree = writer.getClassConstantHeader();
   220         for (TypeElement te : classes) {
   227         for (TypeElement te : classes) {