langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Group.java
author briangoetz
Wed, 18 Dec 2013 16:05:18 -0500
changeset 22163 3651128c74eb
parent 22159 682da512ec17
child 24221 2376793dd33b
permissions -rw-r--r--
8030244: Update langtools to use Diamond Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 5520
diff changeset
     2
 * Copyright (c) 1998, 2012, 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.util;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 5520
diff changeset
    28
import java.util.*;
8d2148961366 8000663: clean up langtools imports
jjg
parents: 5520
diff changeset
    29
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import com.sun.javadoc.*;
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 5520
diff changeset
    31
import com.sun.tools.doclets.internal.toolkit.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * Process and manage grouping of packages, as specified by "-group" option on
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * For example, if user has used -group option as
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * -group "Core Packages" "java.*" -group "CORBA Packages" "org.omg.*", then
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * the packages specified on the command line will be grouped according to their
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * names starting with either "java." or "org.omg.". All the other packages
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * which do not fall in the user given groups, are grouped in default group,
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * named as either "Other Packages" or "Packages" depending upon if "-group"
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * option used or not at all used respectively.
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * </p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * Also the packages are grouped according to the longest possible match of
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * their names with the grouping information provided. For example, if there
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 * are two groups, like -group "Lang" "java.lang" and -group "Core" "java.*",
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 * will put the package java.lang in the group "Lang" and not in group "Core".
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 * </p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    52
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    53
 *  If you write code that depends on this, you do so at your own risk.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    54
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    55
 *  deletion without notice.</b>
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
public class Group {
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     * Map of regular expressions with the corresponding group name.
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
    64
    private Map<String,String> regExpGroupMap = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     * List of regular expressions sorted according to the length. Regular
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     * expression with longest length will be first in the sorted order.
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
    70
    private List<String> sortedRegExpList = new ArrayList<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     * List of group names in the same order as given on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
    75
    private List<String> groupList = new ArrayList<>();
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 non-regular expressions(possible package names) with the
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * corresponding group name.
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
    81
    private Map<String,String> pkgNameGroupMap = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
     * The global configuration information for this run.
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    private final Configuration configuration;
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
     * Since we need to sort the keys in the reverse order(longest key first),
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     * the compare method in the implementing class is doing the reverse
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     * comparison.
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    93
    private static class MapKeyComparator implements Comparator<String> {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    94
        public int compare(String key1, String key2) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    95
            return key2.length() - key1.length();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
1475
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 1264
diff changeset
    99
    public Group(Configuration configuration) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
        this.configuration = configuration;
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
     * Depending upon the format of the package name provided in the "-group"
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     * option, generate two separate maps. There will be a map for mapping
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     * regular expression(only meta character allowed is '*' and that is at the
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     * end of the regular expression) on to the group name. And another map
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     * for mapping (possible) package names(if the name format doesen't contain
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     * meta character '*', then it is assumed to be a package name) on to the
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     * group name. This will also sort all the regular expressions found in the
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     * reverse order of their lengths, i.e. longest regular expression will be
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
     * first in the sorted list.
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
     * @param groupname       The name of the group from -group option.
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
     * @param pkgNameFormList List of the package name formats.
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    public boolean checkPackageGroups(String groupname,
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
            String pkgNameFormList) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
        StringTokenizer strtok = new StringTokenizer(pkgNameFormList, ":");
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
        if (groupList.contains(groupname)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
            configuration.message.warning("doclet.Groupname_already_used", groupname);
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        groupList.add(groupname);
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        while (strtok.hasMoreTokens()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
            String id = strtok.nextToken();
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
            if (id.length() == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
                configuration.message.warning("doclet.Error_in_packagelist", groupname, pkgNameFormList);
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
            if (id.endsWith("*")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
                id = id.substring(0, id.length() - 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
                if (foundGroupFormat(regExpGroupMap, id)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
                    return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
                regExpGroupMap.put(id, groupname);
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
                sortedRegExpList.add(id);
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
                if (foundGroupFormat(pkgNameGroupMap, id)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
                    return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
                pkgNameGroupMap.put(id, groupname);
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
        Collections.sort(sortedRegExpList, new MapKeyComparator());
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
     * Search if the given map has given the package format.
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
     * @param map Map to be searched.
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
     * @param pkgFormat The pacakge format to search.
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
     * @return true if package name format found in the map, else false.
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     */
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1475
diff changeset
   157
    boolean foundGroupFormat(Map<String,?> map, String pkgFormat) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
        if (map.containsKey(pkgFormat)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
            configuration.message.error("doclet.Same_package_name_used", pkgFormat);
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
            return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
     * Group the packages according the grouping information provided on the
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
     * command line. Given a list of packages, search each package name in
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
     * regular expression map as well as package name map to get the
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     * corresponding group name. Create another map with mapping of group name
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
     * to the package list, which will fall under the specified group. If any
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
     * package doesen't belong to any specified group on the comamnd line, then
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
     * a new group named "Other Packages" will be created for it. If there are
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
     * no groups found, in other words if "-group" option is not at all used,
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
     * then all the packages will be grouped under group "Packages".
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
     * @param packages Packages specified on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   178
    public Map<String,List<PackageDoc>> groupPackages(PackageDoc[] packages) {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   179
        Map<String,List<PackageDoc>> groupPackageMap = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        String defaultGroupName =
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
            (pkgNameGroupMap.isEmpty() && regExpGroupMap.isEmpty())?
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
                configuration.message.getText("doclet.Packages") :
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
                configuration.message.getText("doclet.Other_Packages");
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
        // if the user has not used the default group name, add it
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
        if (!groupList.contains(defaultGroupName)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
            groupList.add(defaultGroupName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
        }
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 14260
diff changeset
   188
        for (PackageDoc pkg : packages) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
            String pkgName = pkg.name();
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   190
            String groupName = pkgNameGroupMap.get(pkgName);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
            // if this package is not explicitly assigned to a group,
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
            // try matching it to group specified by regular expression
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
            if (groupName == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
                groupName = regExpGroupName(pkgName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
            // if it is in neither group map, put it in the default
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
            // group
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
            if (groupName == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
                groupName = defaultGroupName;
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
            getPkgList(groupPackageMap, groupName).add(pkg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        return groupPackageMap;
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
     * Search for package name in the sorted regular expression
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
     * list, if found return the group name.  If not, return null.
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
     * @param pkgName Name of package to be found in the regular
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
     * expression list.
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
    String regExpGroupName(String pkgName) {
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 14260
diff changeset
   214
        for (String regexp : sortedRegExpList) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
            if (pkgName.startsWith(regexp)) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   216
                return regExpGroupMap.get(regexp);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
     * For the given group name, return the package list, on which it is mapped.
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
     * Create a new list, if not found.
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
     * @param map Map to be searched for gorup name.
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
     * @param groupname Group name to search.
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   229
    List<PackageDoc> getPkgList(Map<String,List<PackageDoc>> map, String groupname) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   230
        List<PackageDoc> list = map.get(groupname);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
        if (list == null) {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   232
            list = new ArrayList<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
            map.put(groupname, list);
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
        return list;
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
     * Return the list of groups, in the same order as specified
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
     * on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
     */
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1475
diff changeset
   242
    public List<String> getGroupList() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
        return groupList;
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
}