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

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

mercurial