src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PropertyBuilder.java

Sun, 24 Feb 2013 11:36:58 -0800

author
jjg
date
Sun, 24 Feb 2013 11:36:58 -0800
changeset 1606
ccbe7ffdd867
parent 0
959103a6100f
permissions
-rw-r--r--

7112427: The doclet needs to be able to generate JavaFX documentation.
Reviewed-by: jjg
Contributed-by: jan.valenta@oracle.com

     1 /*
     2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.tools.doclets.internal.toolkit.builders;
    28 import java.util.*;
    30 import com.sun.tools.doclets.internal.toolkit.util.*;
    31 import com.sun.tools.doclets.internal.toolkit.*;
    32 import com.sun.javadoc.*;
    34 /**
    35  * Builds documentation for a property.
    36  *
    37  *  <p><b>This is NOT part of any supported API.
    38  *  If you write code that depends on this, you do so at your own risk.
    39  *  This code and its internal interfaces are subject to change or
    40  *  deletion without notice.</b>
    41  *
    42  * @author Jamie Ho
    43  * @author Bhavesh Patel (Modified)
    44  * @since 1.7
    45  */
    46 public class PropertyBuilder extends AbstractMemberBuilder {
    48     /**
    49      * The class whose properties are being documented.
    50      */
    51     private final ClassDoc classDoc;
    53     /**
    54      * The visible properties for the given class.
    55      */
    56     private final VisibleMemberMap visibleMemberMap;
    58     /**
    59      * The writer to output the property documentation.
    60      */
    61     private final PropertyWriter writer;
    63     /**
    64      * The list of properties being documented.
    65      */
    66     private final List<ProgramElementDoc> properties;
    68     /**
    69      * The index of the current property that is being documented at this point
    70      * in time.
    71      */
    72     private int currentPropertyIndex;
    74     /**
    75      * Construct a new PropertyBuilder.
    76      *
    77      * @param context  the build context.
    78      * @param classDoc the class whoses members are being documented.
    79      * @param writer the doclet specific writer.
    80      */
    81     private PropertyBuilder(Context context,
    82             ClassDoc classDoc,
    83             PropertyWriter writer) {
    84         super(context);
    85         this.classDoc = classDoc;
    86         this.writer = writer;
    87         visibleMemberMap =
    88                 new VisibleMemberMap(
    89                 classDoc,
    90                 VisibleMemberMap.PROPERTIES,
    91                 configuration);
    92         properties =
    93                 new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
    94         if (configuration.getMemberComparator() != null) {
    95             Collections.sort(properties, configuration.getMemberComparator());
    96         }
    97     }
    99     /**
   100      * Construct a new PropertyBuilder.
   101      *
   102      * @param context  the build context.
   103      * @param classDoc the class whoses members are being documented.
   104      * @param writer the doclet specific writer.
   105      */
   106     public static PropertyBuilder getInstance(Context context,
   107             ClassDoc classDoc,
   108             PropertyWriter writer) {
   109         return new PropertyBuilder(context, classDoc, writer);
   110     }
   112     /**
   113      * {@inheritDoc}
   114      */
   115     public String getName() {
   116         return "PropertyDetails";
   117     }
   119     /**
   120      * Returns a list of properties that will be documented for the given class.
   121      * This information can be used for doclet specific documentation
   122      * generation.
   123      *
   124      * @param classDoc the {@link ClassDoc} we want to check.
   125      * @return a list of properties that will be documented.
   126      */
   127     public List<ProgramElementDoc> members(ClassDoc classDoc) {
   128         return visibleMemberMap.getMembersFor(classDoc);
   129     }
   131     /**
   132      * Returns the visible member map for the properties of this class.
   133      *
   134      * @return the visible member map for the properties of this class.
   135      */
   136     public VisibleMemberMap getVisibleMemberMap() {
   137         return visibleMemberMap;
   138     }
   140     /**
   141      * summaryOrder.size()
   142      */
   143     public boolean hasMembersToDocument() {
   144         return properties.size() > 0;
   145     }
   147     /**
   148      * Build the property documentation.
   149      *
   150      * @param node the XML element that specifies which components to document
   151      * @param memberDetailsTree the content tree to which the documentation will be added
   152      */
   153     public void buildPropertyDoc(XMLNode node, Content memberDetailsTree) {
   154         if (writer == null) {
   155             return;
   156         }
   157         int size = properties.size();
   158         if (size > 0) {
   159             Content propertyDetailsTree = writer.getPropertyDetailsTreeHeader(
   160                     classDoc, memberDetailsTree);
   161             for (currentPropertyIndex = 0; currentPropertyIndex < size;
   162                     currentPropertyIndex++) {
   163                 Content propertyDocTree = writer.getPropertyDocTreeHeader(
   164                         (MethodDoc) properties.get(currentPropertyIndex),
   165                         propertyDetailsTree);
   166                 buildChildren(node, propertyDocTree);
   167                 propertyDetailsTree.addContent(writer.getPropertyDoc(
   168                         propertyDocTree, (currentPropertyIndex == size - 1)));
   169             }
   170             memberDetailsTree.addContent(
   171                     writer.getPropertyDetails(propertyDetailsTree));
   172         }
   173     }
   175     /**
   176      * Build the signature.
   177      *
   178      * @param node the XML element that specifies which components to document
   179      * @param propertyDocTree the content tree to which the documentation will be added
   180      */
   181     public void buildSignature(XMLNode node, Content propertyDocTree) {
   182         propertyDocTree.addContent(
   183                 writer.getSignature((MethodDoc) properties.get(currentPropertyIndex)));
   184     }
   186     /**
   187      * Build the deprecation information.
   188      *
   189      * @param node the XML element that specifies which components to document
   190      * @param propertyDocTree the content tree to which the documentation will be added
   191      */
   192     public void buildDeprecationInfo(XMLNode node, Content propertyDocTree) {
   193         writer.addDeprecated(
   194                 (MethodDoc) properties.get(currentPropertyIndex), propertyDocTree);
   195     }
   197     /**
   198      * Build the comments for the property.  Do nothing if
   199      * {@link Configuration#nocomment} is set to true.
   200      *
   201      * @param node the XML element that specifies which components to document
   202      * @param propertyDocTree the content tree to which the documentation will be added
   203      */
   204     public void buildPropertyComments(XMLNode node, Content propertyDocTree) {
   205         if (!configuration.nocomment) {
   206             writer.addComments((MethodDoc) properties.get(currentPropertyIndex), propertyDocTree);
   207         }
   208     }
   210     /**
   211      * Build the tag information.
   212      *
   213      * @param node the XML element that specifies which components to document
   214      * @param propertyDocTree the content tree to which the documentation will be added
   215      */
   216     public void buildTagInfo(XMLNode node, Content propertyDocTree) {
   217         writer.addTags((MethodDoc) properties.get(currentPropertyIndex), propertyDocTree);
   218     }
   220     /**
   221      * Return the property writer for this builder.
   222      *
   223      * @return the property writer for this builder.
   224      */
   225     public PropertyWriter getWriter() {
   226         return writer;
   227     }
   228 }

mercurial