langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java
author jjg
Fri, 18 Jun 2010 21:13:56 -0700
changeset 5855 00d9c252e60c
parent 5520 86e4b9a9da40
child 7614 cfadc977ca75
permissions -rw-r--r--
6961178: Allow doclet.xml to contain XML attributes Reviewed-by: bpatel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
diff changeset
     2
 * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.doclets.internal.toolkit.builders;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import com.sun.tools.doclets.internal.toolkit.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.tools.doclets.internal.toolkit.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import com.sun.javadoc.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import java.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * Builds the member summary.
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * This code is not part of an API.
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * It is implementation that is subject to change.
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * Do not use it as an API
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * @author Jamie Ho
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * @since 1.5
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
public class MemberSummaryBuilder extends AbstractMemberBuilder {
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
         * The XML root for this builder.
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
        public static final String NAME = "MemberSummary";
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
         * The visible members for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
        private VisibleMemberMap[] visibleMemberMaps;
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
         * The member summary writers for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
        private MemberSummaryWriter[] memberSummaryWriters;
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
         * The type being documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
        private ClassDoc classDoc;
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
        private MemberSummaryBuilder(Configuration configuration) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
                super(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
         * Construct a new MemberSummaryBuilder.
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
         *
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
         * @param classWriter   the writer for the class whose members are being
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
         *                      summarized.
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
         * @param configuration the current configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
        public static MemberSummaryBuilder getInstance(
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
                ClassWriter classWriter, Configuration configuration)
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
        throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
                MemberSummaryBuilder builder = new MemberSummaryBuilder(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
                builder.classDoc = classWriter.getClassDoc();
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
                builder.init(classWriter);
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
                return builder;
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     * Construct a new MemberSummaryBuilder.
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
     * @param annotationTypeWriter the writer for the class whose members are
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
     *                             being summarized.
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     * @param configuration the current configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    public static MemberSummaryBuilder getInstance(
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
        AnnotationTypeWriter annotationTypeWriter, Configuration configuration)
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
        MemberSummaryBuilder builder = new MemberSummaryBuilder(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
        builder.classDoc = annotationTypeWriter.getAnnotationTypeDoc();
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
        builder.init(annotationTypeWriter);
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
        return builder;
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    private void init(Object writer) throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
        visibleMemberMaps =
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
            new VisibleMemberMap[VisibleMemberMap.NUM_MEMBER_TYPES];
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
        for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
            visibleMemberMaps[i] =
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
                new VisibleMemberMap(
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
                    classDoc,
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
                    i,
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
                    configuration.nodeprecated);
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
        memberSummaryWriters =
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
            new MemberSummaryWriter[VisibleMemberMap.NUM_MEMBER_TYPES];
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
        for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
            if (classDoc.isAnnotationType()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
                memberSummaryWriters[i] =
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
                    visibleMemberMaps[i].noVisibleMembers()?
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
                        null :
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
                        configuration.getWriterFactory().getMemberSummaryWriter(
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
                            (AnnotationTypeWriter) writer, i);
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
                memberSummaryWriters[i] =
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
                    visibleMemberMaps[i].noVisibleMembers()?
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
                        null :
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
                        configuration.getWriterFactory().getMemberSummaryWriter(
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
                            (ClassWriter) writer, i);
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
         * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
        public String getName() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
                return NAME;
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
         * Return the specified visible member map.
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
         *
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
         * @param type the type of visible member map to return.
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
         * @return the specified visible member map.
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
         * @throws ArrayIndexOutOfBoundsException when the type is invalid.
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
         * @see VisibleMemberMap
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        public VisibleMemberMap getVisibleMemberMap(int type) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
                return visibleMemberMaps[type];
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
         * Return the specified member summary writer.
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
         *
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
         * @param type the type of member summary writer to return.
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
         * @return the specified member summary writer.
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
         * @throws ArrayIndexOutOfBoundsException when the type is invalid.
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
         * @see VisibleMemberMap
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
        public MemberSummaryWriter getMemberSummaryWriter(int type) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
                return memberSummaryWriters[type];
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
         * Returns a list of methods that will be documented for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
         * This information can be used for doclet specific documentation
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
         * generation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
         *
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
         * @param classDoc the {@link ClassDoc} we want to check.
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
         * @param type the type of members to return.
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
         * @return a list of methods that will be documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
         * @see VisibleMemberMap
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
         */
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   172
        public List<ProgramElementDoc> members(int type) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
                return visibleMemberMaps[type].getLeafClassMembers(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
         * Return true it there are any members to summarize.
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
         *
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
         * @return true if there are any members to summarize.
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
        public boolean hasMembersToDocument() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
        if (classDoc instanceof AnnotationTypeDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
            return ((AnnotationTypeDoc) classDoc).elements().length > 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
                for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
                        VisibleMemberMap members = visibleMemberMaps[i];
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
                        if (!members.noVisibleMembers()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
                                return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
                        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
         * Build the summary for the enum constants.
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
         */
5855
00d9c252e60c 6961178: Allow doclet.xml to contain XML attributes
jjg
parents: 5520
diff changeset
   197
        public void buildEnumConstantsSummary(XMLNode node) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
                buildSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
                        memberSummaryWriters[VisibleMemberMap.ENUM_CONSTANTS],
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
                        visibleMemberMaps[VisibleMemberMap.ENUM_CONSTANTS]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
     * Build the summary for the optional members.
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
     */
5855
00d9c252e60c 6961178: Allow doclet.xml to contain XML attributes
jjg
parents: 5520
diff changeset
   206
    public void buildAnnotationTypeOptionalMemberSummary(XMLNode node) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
        buildSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
            memberSummaryWriters[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL],
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
                visibleMemberMaps[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
     * Build the summary for the optional members.
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
     */
5855
00d9c252e60c 6961178: Allow doclet.xml to contain XML attributes
jjg
parents: 5520
diff changeset
   215
    public void buildAnnotationTypeRequiredMemberSummary(XMLNode node) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
        buildSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
            memberSummaryWriters[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED],
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
                visibleMemberMaps[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
         * Build the summary for the fields.
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
         */
5855
00d9c252e60c 6961178: Allow doclet.xml to contain XML attributes
jjg
parents: 5520
diff changeset
   224
        public void buildFieldsSummary(XMLNode node) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
                buildSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
                        memberSummaryWriters[VisibleMemberMap.FIELDS],
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
                        visibleMemberMaps[VisibleMemberMap.FIELDS]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
         * Build the inherited summary for the fields.
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
         */
5855
00d9c252e60c 6961178: Allow doclet.xml to contain XML attributes
jjg
parents: 5520
diff changeset
   233
        public void buildFieldsInheritedSummary(XMLNode node) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
                buildInheritedSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
                        memberSummaryWriters[VisibleMemberMap.FIELDS],
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
                        visibleMemberMaps[VisibleMemberMap.FIELDS]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
         * Build the summary for the nested classes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
         */
5855
00d9c252e60c 6961178: Allow doclet.xml to contain XML attributes
jjg
parents: 5520
diff changeset
   242
        public void buildNestedClassesSummary(XMLNode node) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
                buildSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
                        memberSummaryWriters[VisibleMemberMap.INNERCLASSES],
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
                        visibleMemberMaps[VisibleMemberMap.INNERCLASSES]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
         * Build the inherited summary for the nested classes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
         */
5855
00d9c252e60c 6961178: Allow doclet.xml to contain XML attributes
jjg
parents: 5520
diff changeset
   251
        public void buildNestedClassesInheritedSummary(XMLNode node) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
                buildInheritedSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
                        memberSummaryWriters[VisibleMemberMap.INNERCLASSES],
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
                        visibleMemberMaps[VisibleMemberMap.INNERCLASSES]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
         * Build the method summary.
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
         */
5855
00d9c252e60c 6961178: Allow doclet.xml to contain XML attributes
jjg
parents: 5520
diff changeset
   260
        public void buildMethodsSummary(XMLNode node) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
                buildSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
                        memberSummaryWriters[VisibleMemberMap.METHODS],
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
                        visibleMemberMaps[VisibleMemberMap.METHODS]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
         * Build the inherited method summary.
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
         */
5855
00d9c252e60c 6961178: Allow doclet.xml to contain XML attributes
jjg
parents: 5520
diff changeset
   269
        public void buildMethodsInheritedSummary(XMLNode node) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
                buildInheritedSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
                        memberSummaryWriters[VisibleMemberMap.METHODS],
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
                        visibleMemberMaps[VisibleMemberMap.METHODS]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
         * Build the constructor summary.
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
         */
5855
00d9c252e60c 6961178: Allow doclet.xml to contain XML attributes
jjg
parents: 5520
diff changeset
   278
        public void buildConstructorsSummary(XMLNode node) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
                buildSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
                        memberSummaryWriters[VisibleMemberMap.CONSTRUCTORS],
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
                        visibleMemberMaps[VisibleMemberMap.CONSTRUCTORS]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
         * Build the member summary for the given members.
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
         *
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
         * @param writer           the summary writer to write the output.
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
         * @param visibleMemberMap the given members to summarize.
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
        private void buildSummary(MemberSummaryWriter writer,
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
            VisibleMemberMap visibleMemberMap) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   292
        List<ProgramElementDoc> members = new ArrayList<ProgramElementDoc>(visibleMemberMap.getLeafClassMembers(
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
            configuration));
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
        if (members.size() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
            Collections.sort(members);
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
            writer.writeMemberSummaryHeader(classDoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
            for (int i = 0; i < members.size(); i++) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   298
                ProgramElementDoc member = members.get(i);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
                Tag[] firstSentenceTags = member.firstSentenceTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
                if (member instanceof MethodDoc && firstSentenceTags.length == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
                    //Inherit comments from overriden or implemented method if
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
                    //necessary.
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
                    DocFinder.Output inheritedDoc =
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
                        DocFinder.search(new DocFinder.Input((MethodDoc) member));
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
                    if (inheritedDoc.holder != null &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
                            inheritedDoc.holder.firstSentenceTags().length > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
                        firstSentenceTags = inheritedDoc.holder.firstSentenceTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
                writer.writeMemberSummary(classDoc, member, firstSentenceTags,
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
                    i == 0, i == members.size() - 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
            writer.writeMemberSummaryFooter(classDoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
     * Build the inherited member summary for the given methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
     * @param writer           the writer for this member summary.
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
     * @param visibleMemberMap the map for the members to document.
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
        private void buildInheritedSummary(MemberSummaryWriter writer,
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
            VisibleMemberMap visibleMemberMap) {
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   325
        for (Iterator<ClassDoc> iter = visibleMemberMap.getVisibleClassesList().iterator();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
                iter.hasNext();) {
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   327
            ClassDoc inhclass = iter.next();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
            if (! (inhclass.isPublic() ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
                Util.isLinkable(inhclass, configuration))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
                continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
            if (inhclass == classDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
                continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
            }
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   335
            List<ProgramElementDoc> inhmembers = visibleMemberMap.getMembersFor(inhclass);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
            if (inhmembers.size() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
                Collections.sort(inhmembers);
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
                writer.writeInheritedMemberSummaryHeader(inhclass);
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
                for (int j = 0; j < inhmembers.size(); ++j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
                    writer.writeInheritedMemberSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
                        inhclass.isPackagePrivate() &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
                            ! Util.isLinkable(inhclass, configuration) ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
                            classDoc : inhclass,
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   344
                        inhmembers.get(j),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
                        j == 0,
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
                        j == inhmembers.size() - 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
                writer.writeInheritedMemberSummaryFooter(inhclass);
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
}