langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java
author jjg
Tue, 15 Jul 2008 19:22:51 -0700
changeset 868 d0f233085cbb
parent 10 06bc494ca11e
child 1264 076a3cde30d5
permissions -rw-r--r--
6657907: javadoc has unchecked warnings Reviewed-by: bpatel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
 * Copyright 1999-2005 Sun Microsystems, Inc.  All Rights Reserved.
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
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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.util;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import com.sun.javadoc.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.tools.doclets.internal.toolkit.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * A data structure that encapsulates the visible members of a particular
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * type for a given class tree.  To use this data structor, you must specify
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * the type of member you are interested in (nested class, field, constructor
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * or method) and the leaf of the class tree.  The data structure will map
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * all visible members in the leaf and classes above the leaf in the tree.
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * This code is not part of an API.
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * It is implementation that is subject to change.
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * Do not use it as an API
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * @author Jamie Ho (rewrite)
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
public class VisibleMemberMap {
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    private boolean noVisibleMembers = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    public static final int INNERCLASSES    = 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
    public static final int ENUM_CONSTANTS  = 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
    public static final int FIELDS          = 2;
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    public static final int CONSTRUCTORS    = 3;
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    public static final int METHODS         = 4;
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    public static final int ANNOTATION_TYPE_MEMBER_OPTIONAL = 5;
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    public static final int ANNOTATION_TYPE_MEMBER_REQUIRED = 6;
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
     * The total number of member types is {@value}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    public static final int NUM_MEMBER_TYPES = 7;
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    public static final String STARTLEVEL = "start";
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     * List of ClassDoc objects for which ClassMembers objects are built.
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    68
    private final List<ClassDoc> visibleClasses = new ArrayList<ClassDoc>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     * Map for each member name on to a map which contains members with same
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     * name-signature. The mapped map will contain mapping for each MemberDoc
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     * onto it's respecive level string.
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    75
    private final Map<Object,Map<ProgramElementDoc,String>> memberNameMap = new HashMap<Object,Map<ProgramElementDoc,String>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     * Map of class and it's ClassMembers object.
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    80
    private final Map<ClassDoc,ClassMembers> classMap = new HashMap<ClassDoc,ClassMembers>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
     * Type whose visible members are requested.  This is the leaf of
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
     * the class tree being mapped.
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    private final ClassDoc classdoc;
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
     * Member kind: InnerClasses/Fields/Methods?
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
    private final int kind;
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     * Deprected members should be excluded or not?
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
    private final boolean nodepr;
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
     * Construct a VisibleMemberMap of the given type for the given
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
     * class.  If nodepr is true, exclude the deprecated members from
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
     * the map.
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     * @param classdoc the class whose members are being mapped.
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
     * @param kind the kind of member that is being mapped.
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     * @param nodepr if true, exclude the deprecated members from the map.
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
    public VisibleMemberMap(ClassDoc classdoc, int kind, boolean nodepr) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
        this.classdoc = classdoc;
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        this.nodepr = nodepr;
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
        this.kind = kind;
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
        new ClassMembers(classdoc, STARTLEVEL).build();
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
     * Return the list of visible classes in this map.
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     * @return the list of visible classes in this map.
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    public List getVisibleClassesList() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
        sort(visibleClasses);
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        return visibleClasses;
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
     * Return the package private members inherited by the class.  Only return
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
     * if parent is package private and not documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     * @param configuation the current configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     * @return the package private members inherited by the class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   131
    private List<ProgramElementDoc> getInheritedPackagePrivateMethods(Configuration configuration) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   132
        List<ProgramElementDoc> results = new ArrayList<ProgramElementDoc>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
        for (Iterator iter = visibleClasses.iterator(); iter.hasNext(); ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
            ClassDoc currentClass = (ClassDoc) iter.next();
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
            if (currentClass != classdoc &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
                currentClass.isPackagePrivate() &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
                !Util.isLinkable(currentClass, configuration)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
                // Document these members in the child class because
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
                // the parent is inaccessible.
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
                results.addAll(getMembersFor(currentClass));
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        return results;
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
     * Return the visible members of the class being mapped.  Also append at the
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
     * end of the list members that are inherited by inaccessible parents. We
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
     * document these members in the child because the parent is not documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
     * @param configuation the current configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   153
    public List<ProgramElementDoc> getLeafClassMembers(Configuration configuration) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   154
        List<ProgramElementDoc> result = getMembersFor(classdoc);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
        result.addAll(getInheritedPackagePrivateMethods(configuration));
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
     * Retrn the list of members for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
     * @param cd the class to retrieve the list of visible members for.
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
     * @return the list of members for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   166
    public List<ProgramElementDoc> getMembersFor(ClassDoc cd) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   167
        ClassMembers clmembers = classMap.get(cd);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
        if (clmembers == null) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   169
            return new ArrayList<ProgramElementDoc>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
        return clmembers.getMembers();
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
     * Sort the given mixed list of classes and interfaces to a list of
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
     * classes followed by interfaces traversed. Don't sort alphabetically.
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   178
    private void sort(List<ClassDoc> list) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   179
        List<ClassDoc> classes = new ArrayList<ClassDoc>();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   180
        List<ClassDoc> interfaces = new ArrayList<ClassDoc>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
        for (int i = 0; i < list.size(); i++) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   182
            ClassDoc cd = list.get(i);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
            if (cd.isClass()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
                classes.add(cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
                interfaces.add(cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        list.clear();
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
        list.addAll(classes);
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
        list.addAll(interfaces);
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   194
    private void fillMemberLevelMap(List<ProgramElementDoc> list, String level) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
        for (int i = 0; i < list.size(); i++) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   196
            Object key = getMemberKey(list.get(i));
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   197
            Map<ProgramElementDoc,String> memberLevelMap = memberNameMap.get(key);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
            if (memberLevelMap == null) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   199
                memberLevelMap = new HashMap<ProgramElementDoc,String>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
                memberNameMap.put(key, memberLevelMap);
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
            memberLevelMap.put(list.get(i), level);
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
    private void purgeMemberLevelMap(List list, String level) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
        for (int i = 0; i < list.size(); i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
            Object key = getMemberKey((ProgramElementDoc)list.get(i));
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
            Map memberLevelMap = (Map) memberNameMap.get(key);
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
            if (level.equals(memberLevelMap.get(list.get(i))))
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
                memberLevelMap.remove(list.get(i));
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
     * Represents a class member.  We should be able to just use a
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
     * ProgramElementDoc instead of this class, but that doesn't take
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
     * type variables in consideration when comparing.
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
    private class ClassMember {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   221
        private Set<ProgramElementDoc> members;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
        public ClassMember(ProgramElementDoc programElementDoc) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   224
            members = new HashSet<ProgramElementDoc>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
            members.add(programElementDoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
        public void addMember(ProgramElementDoc programElementDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
            members.add(programElementDoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
        public boolean isEqual(MethodDoc member) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
            for (Iterator iter = members.iterator(); iter.hasNext(); ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
                MethodDoc member2 = (MethodDoc) iter.next();
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
                if (Util.executableMembersEqual(member, member2)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
                    members.add(member);
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
                        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
     * A data structure that represents the class members for
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
     * a visible class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
    private class ClassMembers {
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
         * The mapping class, whose inherited members are put in the
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
         * {@link #members} list.
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
        private ClassDoc mappingClass;
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
         * List of inherited members from the mapping class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
         */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   259
        private List<ProgramElementDoc> members = new ArrayList<ProgramElementDoc>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
         * Level/Depth of inheritance.
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
        private String level;
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
         * Return list of inherited members from mapping class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
         *
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
         * @return List Inherited members.
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
         */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   271
        public List<ProgramElementDoc> getMembers() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
            return members;
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
        private ClassMembers(ClassDoc mappingClass, String level) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
            this.mappingClass = mappingClass;
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
            this.level = level;
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
            if (classMap.containsKey(mappingClass) &&
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   279
                        level.startsWith(classMap.get(mappingClass).level)) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
                //Remove lower level class so that it can be replaced with
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
                //same class found at higher level.
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
                purgeMemberLevelMap(getClassMembers(mappingClass, false),
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   283
                    classMap.get(mappingClass).level);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
                classMap.remove(mappingClass);
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
                visibleClasses.remove(mappingClass);
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
            if (!classMap.containsKey(mappingClass)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
                classMap.put(mappingClass, this);
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
                visibleClasses.add(mappingClass);
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
        private void build() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
            if (kind == CONSTRUCTORS) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
                addMembers(mappingClass);
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
                mapClass();
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
        private void mapClass() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
            addMembers(mappingClass);
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
            ClassDoc[] interfaces = mappingClass.interfaces();
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
            for (int i = 0; i < interfaces.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
                String locallevel = level + 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
                ClassMembers cm = new ClassMembers(interfaces[i], locallevel);
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
                cm.mapClass();
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
            if (mappingClass.isClass()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
                ClassDoc superclass = mappingClass.superclass();
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
                if (!(superclass == null || mappingClass.equals(superclass))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
                    ClassMembers cm = new ClassMembers(superclass,
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
                                                       level + "c");
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
                    cm.mapClass();
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
         * Get all the valid members from the mapping class. Get the list of
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
         * members for the class to be included into(ctii), also get the level
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
         * string for ctii. If mapping class member is not already in the
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
         * inherited member list and if it is visible in the ctii and not
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
         * overridden, put such a member in the inherited member list.
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
         * Adjust member-level-map, class-map.
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
        private void addMembers(ClassDoc fromClass) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   329
            List<ProgramElementDoc> cdmembers = getClassMembers(fromClass, true);
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   330
            List<ProgramElementDoc> incllist = new ArrayList<ProgramElementDoc>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
            for (int i = 0; i < cdmembers.size(); i++) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   332
                ProgramElementDoc pgmelem = cdmembers.get(i);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
                if (!found(members, pgmelem) &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
                    memberIsVisible(pgmelem) &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
                    !isOverridden(pgmelem, level)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
                    incllist.add(pgmelem);
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
            if (incllist.size() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
                noVisibleMembers = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
            members.addAll(incllist);
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
            fillMemberLevelMap(getClassMembers(fromClass, false), level);
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
         * Is given doc item visible in given classdoc in terms fo inheritance?
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
         * The given doc item is visible in the given classdoc if it is public
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
         * or protected and if it is package-private if it's containing class
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
         * is in the same package as the given classdoc.
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
        private boolean memberIsVisible(ProgramElementDoc pgmdoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
            if (pgmdoc.containingClass().equals(classdoc)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
                //Member is in class that we are finding visible members for.
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
                //Of course it is visible.
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
                return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
            } else if (pgmdoc.isPrivate()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
                //Member is in super class or implemented interface.
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
                //Private, so not inherited.
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
            } else if (pgmdoc.isPackagePrivate()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
                //Member is package private.  Only return true if its class is in
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
                //same package.
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
                return pgmdoc.containingClass().containingPackage().equals(
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
                    classdoc.containingPackage());
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
                //Public members are always inherited.
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
                return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
         * Return all available class members.
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
         */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   375
        private List<ProgramElementDoc> getClassMembers(ClassDoc cd, boolean filter) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
            if (cd.isEnum() && kind == CONSTRUCTORS) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
                //If any of these rules are hit, return empty array because
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
                //we don't document these members ever.
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
                return Arrays.asList(new ProgramElementDoc[] {});
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
            ProgramElementDoc[] members = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
            switch (kind) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
                case ANNOTATION_TYPE_MEMBER_OPTIONAL:
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
                    members = cd.isAnnotationType() ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
                        filter((AnnotationTypeDoc) cd, false) :
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
                        new AnnotationTypeElementDoc[] {};
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
                    break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
                case ANNOTATION_TYPE_MEMBER_REQUIRED:
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
                    members = cd.isAnnotationType() ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
                        filter((AnnotationTypeDoc) cd, true) :
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
                        new AnnotationTypeElementDoc[] {};
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
                    break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
                case INNERCLASSES:
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
                    members = cd.innerClasses(filter);
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
                    break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
                case ENUM_CONSTANTS:
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
                    members = cd.enumConstants();
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
                    break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
                case FIELDS:
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
                    members = cd.fields(filter);
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
                    break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
                case CONSTRUCTORS:
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
                    members = cd.constructors();
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
                    break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
                case METHODS:
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
                    members = cd.methods(filter);
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
                    break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
                default:
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
                    members = new ProgramElementDoc[0];
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
            if (nodepr) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
                return Util.excludeDeprecatedMembersAsList(members);
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
            return Arrays.asList(members);
06bc494ca11e Initial load
duke
parents:
diff changeset
   415
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   416
06bc494ca11e Initial load
duke
parents:
diff changeset
   417
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   418
         * Filter the annotation type members and return either the required
06bc494ca11e Initial load
duke
parents:
diff changeset
   419
         * members or the optional members, depending on the value of the
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
         * required parameter.
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
         *
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
         * @param doc The annotation type to process.
06bc494ca11e Initial load
duke
parents:
diff changeset
   423
         * @param required
06bc494ca11e Initial load
duke
parents:
diff changeset
   424
         * @return the annotation type members and return either the required
06bc494ca11e Initial load
duke
parents:
diff changeset
   425
         * members or the optional members, depending on the value of the
06bc494ca11e Initial load
duke
parents:
diff changeset
   426
         * required parameter.
06bc494ca11e Initial load
duke
parents:
diff changeset
   427
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   428
        private AnnotationTypeElementDoc[] filter(AnnotationTypeDoc doc,
06bc494ca11e Initial load
duke
parents:
diff changeset
   429
            boolean required) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   430
            AnnotationTypeElementDoc[] members = doc.elements();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   431
            List<AnnotationTypeElementDoc> targetMembers = new ArrayList<AnnotationTypeElementDoc>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   432
            for (int i = 0; i < members.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   433
                if ((required && members[i].defaultValue() == null) ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   434
                     ((!required) && members[i].defaultValue() != null)){
06bc494ca11e Initial load
duke
parents:
diff changeset
   435
                    targetMembers.add(members[i]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   436
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   437
            }
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   438
            return targetMembers.toArray(new AnnotationTypeElementDoc[]{});
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   439
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
06bc494ca11e Initial load
duke
parents:
diff changeset
   441
        private boolean found(List list, ProgramElementDoc elem) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   442
            for (int i = 0; i < list.size(); i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   443
                ProgramElementDoc pgmelem = (ProgramElementDoc)list.get(i);
06bc494ca11e Initial load
duke
parents:
diff changeset
   444
                if (Util.matches(pgmelem, elem)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
                    return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   446
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   448
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   450
06bc494ca11e Initial load
duke
parents:
diff changeset
   451
06bc494ca11e Initial load
duke
parents:
diff changeset
   452
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   453
         * Is member overridden? The member is overridden if it is found in the
06bc494ca11e Initial load
duke
parents:
diff changeset
   454
         * same level hierarchy e.g. member at level "11" overrides member at
06bc494ca11e Initial load
duke
parents:
diff changeset
   455
         * level "111".
06bc494ca11e Initial load
duke
parents:
diff changeset
   456
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   457
        private boolean isOverridden(ProgramElementDoc pgmdoc, String level) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
            Map memberLevelMap = (Map) memberNameMap.get(getMemberKey(pgmdoc));
06bc494ca11e Initial load
duke
parents:
diff changeset
   459
            if (memberLevelMap == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   460
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   461
            String mappedlevel = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   462
            Iterator iterator = memberLevelMap.values().iterator();
06bc494ca11e Initial load
duke
parents:
diff changeset
   463
            while (iterator.hasNext()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   464
                mappedlevel = (String)(iterator.next());
06bc494ca11e Initial load
duke
parents:
diff changeset
   465
                if (mappedlevel.equals(STARTLEVEL) ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   466
                    (level.startsWith(mappedlevel) &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   467
                     !level.equals(mappedlevel))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   468
                    return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   469
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   470
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   471
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   472
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   473
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   474
06bc494ca11e Initial load
duke
parents:
diff changeset
   475
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   476
     * Return true if this map has no visible members.
06bc494ca11e Initial load
duke
parents:
diff changeset
   477
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   478
     * @return true if this map has no visible members.
06bc494ca11e Initial load
duke
parents:
diff changeset
   479
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   480
    public boolean noVisibleMembers() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   481
        return noVisibleMembers;
06bc494ca11e Initial load
duke
parents:
diff changeset
   482
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   483
06bc494ca11e Initial load
duke
parents:
diff changeset
   484
    private ClassMember getClassMember(MethodDoc member) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   485
        for (Iterator iter = memberNameMap.keySet().iterator(); iter.hasNext();) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   486
            Object key = iter.next();
06bc494ca11e Initial load
duke
parents:
diff changeset
   487
            if (key instanceof String) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   488
                continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   489
            } else if (((ClassMember) key).isEqual(member)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   490
                return (ClassMember) key;
06bc494ca11e Initial load
duke
parents:
diff changeset
   491
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   492
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   493
        return new ClassMember(member);
06bc494ca11e Initial load
duke
parents:
diff changeset
   494
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   495
06bc494ca11e Initial load
duke
parents:
diff changeset
   496
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   497
     * Return the key to the member map for the given member.
06bc494ca11e Initial load
duke
parents:
diff changeset
   498
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   499
    private Object getMemberKey(ProgramElementDoc doc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   500
        if (doc.isConstructor()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   501
            return doc.name() + ((ExecutableMemberDoc)doc).signature();
06bc494ca11e Initial load
duke
parents:
diff changeset
   502
        } else if (doc.isMethod()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   503
            return getClassMember((MethodDoc) doc);
06bc494ca11e Initial load
duke
parents:
diff changeset
   504
        } else if (doc.isField() || doc.isEnumConstant() || doc.isAnnotationTypeElement()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   505
            return doc.name();
06bc494ca11e Initial load
duke
parents:
diff changeset
   506
        } else { // it's a class or interface
06bc494ca11e Initial load
duke
parents:
diff changeset
   507
            String classOrIntName = doc.name();
06bc494ca11e Initial load
duke
parents:
diff changeset
   508
            //Strip off the containing class name because we only want the member name.
06bc494ca11e Initial load
duke
parents:
diff changeset
   509
            classOrIntName = classOrIntName.indexOf('.') != 0 ? classOrIntName.substring(classOrIntName.lastIndexOf('.'), classOrIntName.length()) : classOrIntName;
06bc494ca11e Initial load
duke
parents:
diff changeset
   510
            return "clint" + classOrIntName;
06bc494ca11e Initial load
duke
parents:
diff changeset
   511
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   512
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   513
}