langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java
author mcimadamore
Tue, 13 Jan 2009 13:27:14 +0000
changeset 1789 7ac8c0815000
parent 1264 076a3cde30d5
child 5520 86e4b9a9da40
permissions -rw-r--r--
6765045: Remove rawtypes warnings from langtools Summary: Removed all occurrences of rawtypes warnings from langtools Reviewed-by: jjg, bpatel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
1264
076a3cde30d5 6754988: Update copyright year
xdono
parents: 868
diff changeset
     2
 * Copyright 2001-2008 Sun Microsystems, Inc.  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
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.taglets;
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.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import java.io.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import java.lang.reflect.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import java.net.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
import java.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * Manages the<code>Taglet</code>s used by doclets.
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 Jamie Ho
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * @since 1.4
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
public class TagletManager {
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
     * The default seperator for the simple tag option.
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
    public static final char SIMPLE_TAGLET_OPT_SEPERATOR = ':';
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     * The alternate seperator for simple tag options.  Use this
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     * with you want the default seperator to be in the name of the
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
     * custom tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    public static final String ALT_SIMPLE_TAGLET_OPT_SEPERATOR = "-";
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     * The map of custom tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    64
    private LinkedHashMap<String,Taglet> customTags;
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
     * The array of custom tags that can appear in packages.
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    private Taglet[] packageTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     * The array of custom tags that can appear in classes or interfaces.
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    private Taglet[] typeTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     * The array of custom tags that can appear in fields.
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
    private Taglet[] fieldTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     * The array of custom tags that can appear in constructors.
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
    private Taglet[] constructorTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     * The array of custom tags that can appear in methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
    private Taglet[] methodTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     * The array of custom tags that can appear in the overview.
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    private Taglet[] overviewTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     * The array of custom tags that can appear in comments.
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
    private Taglet[] inlineTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     * The array of custom tags that can appear in the serialized form.
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
    private Taglet[] serializedFormTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     * The message retriever that will be used to print error messages.
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
    private MessageRetriever message;
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
     * Keep track of standard tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   114
    private Set<String> standardTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     * Keep track of standard tags in lowercase to compare for better
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     * error messages when a tag like @docRoot is mistakenly spelled
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     * lowercase @docroot.
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   121
    private Set<String> standardTagsLowercase;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
     * Keep track of overriden standard tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   126
    private Set<String> overridenStandardTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     * Keep track of the tags that may conflict
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     * with standard tags in the future (any custom tag without
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
     * a period in its name).
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   133
    private Set<String> potentiallyConflictingTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     * The set of unseen custom tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   138
    private Set<String> unseenCustomTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
     * True if we do not want to use @since tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
    private boolean nosince;
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
     * True if we want to use @version tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
    private boolean showversion;
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
     * True if we want to use @author tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
    private boolean showauthor;
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     * Construct a new <code>TagletManager</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
     * @param nosince true if we do not want to use @since tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
     * @param showversion true if we want to use @version tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
     * @param showauthor true if we want to use @author tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
     * @param message the message retriever to print warnings.
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
    public TagletManager(boolean nosince, boolean showversion,
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
                         boolean showauthor, MessageRetriever message){
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   164
        overridenStandardTags = new HashSet<String>();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   165
        potentiallyConflictingTags = new HashSet<String>();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   166
        standardTags = new HashSet<String>();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   167
        standardTagsLowercase = new HashSet<String>();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   168
        unseenCustomTags = new HashSet<String>();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   169
        customTags = new LinkedHashMap<String,Taglet>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
        this.nosince = nosince;
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
        this.showversion = showversion;
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
        this.showauthor = showauthor;
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
        this.message = message;
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
        initStandardTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
        initStandardTagsLowercase();
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
     * Add a new <code>CustomTag</code>.  This is used to add a Taglet from within
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
     * a Doclet.  No message is printed to indicate that the Taglet is properly
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
     * registered because these Taglets are typically added for every execution of the
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
     * Doclet.  We don't want to see this type of error message every time.
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
     * @param customTag the new <code>CustomTag</code> to add.
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
    public void addCustomTag(Taglet customTag) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
        if (customTag != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
            String name = customTag.getName();
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
            if (customTags.containsKey(name)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
                customTags.remove(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
            customTags.put(name, customTag);
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
            checkTagName(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
     * Add a new <code>Taglet</code>.  Print a message to indicate whether or not
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
     * the Taglet was registered properly.
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
     * @param classname  the name of the class representing the custom tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
     * @param tagletPath  the path to the class representing the custom tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
    public void addCustomTag(String classname, String tagletPath) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        try {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   204
            Class<?> customTagClass = null;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
            // construct class loader
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
            String cpString = null;   // make sure env.class.path defaults to dot
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
            // do prepends to get correct ordering
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
            cpString = appendPath(System.getProperty("env.class.path"), cpString);
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
            cpString = appendPath(System.getProperty("java.class.path"), cpString);
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
            cpString = appendPath(tagletPath, cpString);
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
            URLClassLoader appClassLoader = new URLClassLoader(pathToURLs(cpString));
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
            customTagClass = appClassLoader.loadClass(classname);
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
            Method meth = customTagClass.getMethod("register",
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   215
                                                   new Class<?>[] {java.util.Map.class});
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
            Object[] list = customTags.values().toArray();
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
            Taglet lastTag = (list != null && list.length > 0)
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
                ? (Taglet) list[list.length-1] : null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
            meth.invoke(null, new Object[] {customTags});
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
            list = customTags.values().toArray();
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
            Object newLastTag = (list != null&& list.length > 0)
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   222
                ? list[list.length-1] : null;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
            if (lastTag != newLastTag) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
                //New taglets must always be added to the end of the LinkedHashMap.
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
                //If the current and previous last taglet are not equal, that
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
                //means a new Taglet has been added.
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
                message.notice("doclet.Notice_taglet_registered", classname);
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
                if (newLastTag != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
                    checkTaglet(newLastTag);
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
        } catch (Exception exc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
            message.error("doclet.Error_taglet_not_registered", exc.getClass().getName(), classname);
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
    private String appendPath(String path1, String path2) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
        if (path1 == null || path1.length() == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
            return path2 == null ? "." : path2;
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
        } else if (path2 == null || path2.length() == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
            return path1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
            return path1  + File.pathSeparator + path2;
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
        }
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
     * Utility method for converting a search path string to an array
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
     * of directory and JAR file URLs.
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
     * @param path the search path string
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
     * @return the resulting array of directory and JAR file URLs
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
    private static URL[] pathToURLs(String path) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
        StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
        URL[] urls = new URL[st.countTokens()];
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
        int count = 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
        while (st.hasMoreTokens()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
            URL url = fileToURL(new File(st.nextToken()));
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
            if (url != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
                urls[count++] = url;
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
        if (urls.length != count) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
            URL[] tmp = new URL[count];
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
            System.arraycopy(urls, 0, tmp, 0, count);
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
            urls = tmp;
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
        return urls;
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
     * Returns the directory or JAR file URL corresponding to the specified
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
     * local file name.
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
     * @param file the File object
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
     * @return the resulting directory or JAR file URL, or null if unknown
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
    private static URL fileToURL(File file) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
        String name;
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
            name = file.getCanonicalPath();
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
        } catch (IOException e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
            name = file.getAbsolutePath();
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
        name = name.replace(File.separatorChar, '/');
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
        if (!name.startsWith("/")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
            name = "/" + name;
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
        // If the file does not exist, then assume that it's a directory
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
        if (!file.isFile()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
            name = name + "/";
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
            return new URL("file", "", name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
        } catch (MalformedURLException e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
            throw new IllegalArgumentException("file");
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
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
     * Add a new <code>SimpleTaglet</code>.  If this tag already exists
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
     * and the header passed as an argument is null, move tag to the back of the
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
     * list. If this tag already exists and the header passed as an argument is
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
     * not null, overwrite previous tag with new one.  Otherwise, add new
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
     * SimpleTaglet to list.
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
     * @param tagName the name of this tag
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
     * @param header the header to output.
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
     * @param locations the possible locations that this tag
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
     * can appear in.
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
    public void addNewSimpleCustomTag(String tagName, String header, String locations) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
        if (tagName == null || locations == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
        }
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   318
        Taglet tag = customTags.get(tagName);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
        locations = locations.toLowerCase();
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
        if (tag == null || header != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
            customTags.remove(tagName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
            customTags.put(tagName, new SimpleTaglet(tagName, header, locations));
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
            if (locations != null && locations.indexOf('x') == -1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
                checkTagName(tagName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
            //Move to back
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
            customTags.remove(tagName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
            customTags.put(tagName, tag);
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
     * Given a tag name, add it to the set of tags it belongs to.
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
    private void checkTagName(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
        if (standardTags.contains(name)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
            overridenStandardTags.add(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
            if (name.indexOf('.') == -1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
                potentiallyConflictingTags.add(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
            unseenCustomTags.add(name);
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
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
     * Check the taglet to see if it is a legacy taglet.  Also
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
     * check its name for errors.
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
    private void checkTaglet(Object taglet) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
        if (taglet instanceof Taglet) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
            checkTagName(((Taglet) taglet).getName());
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
        } else if (taglet instanceof com.sun.tools.doclets.Taglet) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
            com.sun.tools.doclets.Taglet legacyTaglet = (com.sun.tools.doclets.Taglet) taglet;
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
            customTags.remove(legacyTaglet.getName());
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
            customTags.put(legacyTaglet.getName(), new LegacyTaglet(legacyTaglet));
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
            checkTagName(legacyTaglet.getName());
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
            throw new IllegalArgumentException("Given object is not a taglet.");
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
     * Given a name of a seen custom tag, remove it from the set of unseen
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
     * custom tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
     * @param name the name of the seen custom tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
    public void seenCustomTag(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
        unseenCustomTags.remove(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
     * Given an array of <code>Tag</code>s, check for spelling mistakes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
     * @param doc the Doc object that holds the tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
     * @param tags the list of <code>Tag</code>s to check.
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
     * @param areInlineTags true if the array of tags are inline and false otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
    public void checkTags(Doc doc, Tag[] tags, boolean areInlineTags) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
        if (tags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
        Taglet taglet;
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
        for (int i = 0; i < tags.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
            String name = tags[i].name();
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
            if (name.length() > 0 && name.charAt(0) == '@') {
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
                name = name.substring(1, name.length());
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
            if (! (standardTags.contains(name) || customTags.containsKey(name))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
                if (standardTagsLowercase.contains(name.toLowerCase())) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
                    message.warning(tags[i].position(), "doclet.UnknownTagLowercase", tags[i].name());
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
                    continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
                } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
                    message.warning(tags[i].position(), "doclet.UnknownTag", tags[i].name());
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
                    continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
            //Check if this tag is being used in the wrong location.
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   399
            if ((taglet = customTags.get(name)) != null) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
                if (areInlineTags && ! taglet.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
                    printTagMisuseWarn(taglet, tags[i], "inline");
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
                if ((doc instanceof RootDoc) && ! taglet.inOverview()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
                    printTagMisuseWarn(taglet, tags[i], "overview");
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
                } else if ((doc instanceof PackageDoc) && ! taglet.inPackage()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
                    printTagMisuseWarn(taglet, tags[i], "package");
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
                } else if ((doc instanceof ClassDoc) && ! taglet.inType()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
                    printTagMisuseWarn(taglet, tags[i], "class");
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
                } else if ((doc instanceof ConstructorDoc) && ! taglet.inConstructor()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
                    printTagMisuseWarn(taglet, tags[i], "constructor");
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
                } else if ((doc instanceof FieldDoc) && ! taglet.inField()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
                    printTagMisuseWarn(taglet, tags[i], "field");
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
                } else if ((doc instanceof MethodDoc) && ! taglet.inMethod()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
                    printTagMisuseWarn(taglet, tags[i], "method");
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
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   419
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
     * Given the taglet, the tag and the type of documentation that the tag
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
     * was found in, print a tag misuse warning.
06bc494ca11e Initial load
duke
parents:
diff changeset
   423
     * @param taglet the taglet representing the misused tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   424
     * @param tag the misused tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   425
     * @param holderType the type of documentation that the misused tag was found in.
06bc494ca11e Initial load
duke
parents:
diff changeset
   426
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   427
    private void printTagMisuseWarn(Taglet taglet, Tag tag, String holderType) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   428
        Set<String> locationsSet = new LinkedHashSet<String>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   429
        if (taglet.inOverview()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   430
            locationsSet.add("overview");
06bc494ca11e Initial load
duke
parents:
diff changeset
   431
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   432
        if (taglet.inPackage()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   433
            locationsSet.add("package");
06bc494ca11e Initial load
duke
parents:
diff changeset
   434
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   435
        if (taglet.inType()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   436
            locationsSet.add("class/interface");
06bc494ca11e Initial load
duke
parents:
diff changeset
   437
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   438
        if (taglet.inConstructor())  {
06bc494ca11e Initial load
duke
parents:
diff changeset
   439
            locationsSet.add("constructor");
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   441
        if (taglet.inField()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   442
            locationsSet.add("field");
06bc494ca11e Initial load
duke
parents:
diff changeset
   443
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   444
        if (taglet.inMethod()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
            locationsSet.add("method");
06bc494ca11e Initial load
duke
parents:
diff changeset
   446
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
        if (taglet.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   448
            locationsSet.add("inline text");
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
        }
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   450
        String[] locations = locationsSet.toArray(new String[]{});
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   451
        if (locations == null || locations.length == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   452
            //This known tag is excluded.
06bc494ca11e Initial load
duke
parents:
diff changeset
   453
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   454
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   455
        StringBuffer combined_locations = new StringBuffer();
06bc494ca11e Initial load
duke
parents:
diff changeset
   456
        for (int i = 0; i < locations.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   457
            if (i > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
                combined_locations.append(", ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   459
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   460
            combined_locations.append(locations[i]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   461
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   462
        message.warning(tag.position(), "doclet.tag_misuse",
06bc494ca11e Initial load
duke
parents:
diff changeset
   463
            "@" + taglet.getName(), holderType, combined_locations.toString());
06bc494ca11e Initial load
duke
parents:
diff changeset
   464
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   465
06bc494ca11e Initial load
duke
parents:
diff changeset
   466
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   467
     * Return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   468
     * appear in packages.
06bc494ca11e Initial load
duke
parents:
diff changeset
   469
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   470
     * appear in packages.
06bc494ca11e Initial load
duke
parents:
diff changeset
   471
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   472
    public Taglet[] getPackageCustomTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   473
        if (packageTags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   474
            initCustomTagArrays();
06bc494ca11e Initial load
duke
parents:
diff changeset
   475
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   476
        return packageTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   477
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   478
06bc494ca11e Initial load
duke
parents:
diff changeset
   479
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   480
     * Return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   481
     * appear in classes or interfaces.
06bc494ca11e Initial load
duke
parents:
diff changeset
   482
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   483
     * appear in classes or interfaces.
06bc494ca11e Initial load
duke
parents:
diff changeset
   484
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   485
    public Taglet[] getTypeCustomTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   486
        if (typeTags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   487
            initCustomTagArrays();
06bc494ca11e Initial load
duke
parents:
diff changeset
   488
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   489
        return typeTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   490
    }
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 the array of inline <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   494
     * appear in comments.
06bc494ca11e Initial load
duke
parents:
diff changeset
   495
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   496
     * appear in comments.
06bc494ca11e Initial load
duke
parents:
diff changeset
   497
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   498
    public Taglet[] getInlineCustomTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   499
        if (inlineTags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   500
            initCustomTagArrays();
06bc494ca11e Initial load
duke
parents:
diff changeset
   501
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   502
        return inlineTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   503
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   504
06bc494ca11e Initial load
duke
parents:
diff changeset
   505
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   506
     * Return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   507
     * appear in fields.
06bc494ca11e Initial load
duke
parents:
diff changeset
   508
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   509
     * appear in field.
06bc494ca11e Initial load
duke
parents:
diff changeset
   510
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   511
    public Taglet[] getFieldCustomTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   512
        if (fieldTags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   513
            initCustomTagArrays();
06bc494ca11e Initial load
duke
parents:
diff changeset
   514
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   515
        return fieldTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   516
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   517
06bc494ca11e Initial load
duke
parents:
diff changeset
   518
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   519
     * Return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   520
     * appear in the serialized form.
06bc494ca11e Initial load
duke
parents:
diff changeset
   521
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   522
     * appear in the serialized form.
06bc494ca11e Initial load
duke
parents:
diff changeset
   523
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   524
    public Taglet[] getSerializedFormTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   525
        if (serializedFormTags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   526
            initCustomTagArrays();
06bc494ca11e Initial load
duke
parents:
diff changeset
   527
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   528
        return serializedFormTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   529
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   530
06bc494ca11e Initial load
duke
parents:
diff changeset
   531
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   532
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   533
     * appear in the given Doc.
06bc494ca11e Initial load
duke
parents:
diff changeset
   534
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   535
    public Taglet[] getCustomTags(Doc doc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   536
        if (doc instanceof ConstructorDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   537
            return getConstructorCustomTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   538
        } else if (doc instanceof MethodDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   539
            return getMethodCustomTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   540
        } else if (doc instanceof FieldDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   541
            return getFieldCustomTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   542
        } else if (doc instanceof ClassDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   543
            return getTypeCustomTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   544
        } else if (doc instanceof PackageDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   545
            return getPackageCustomTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   546
        } else if (doc instanceof RootDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   547
            return getOverviewCustomTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   548
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   549
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   550
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   551
06bc494ca11e Initial load
duke
parents:
diff changeset
   552
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   553
     * Return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   554
     * appear in constructors.
06bc494ca11e Initial load
duke
parents:
diff changeset
   555
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   556
     * appear in constructors.
06bc494ca11e Initial load
duke
parents:
diff changeset
   557
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   558
    public Taglet[] getConstructorCustomTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   559
        if (constructorTags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   560
            initCustomTagArrays();
06bc494ca11e Initial load
duke
parents:
diff changeset
   561
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   562
        return constructorTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   563
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   564
06bc494ca11e Initial load
duke
parents:
diff changeset
   565
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   566
     * Return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   567
     * appear in methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
   568
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   569
     * appear in methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
   570
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   571
    public Taglet[] getMethodCustomTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   572
        if (methodTags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   573
            initCustomTagArrays();
06bc494ca11e Initial load
duke
parents:
diff changeset
   574
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   575
        return methodTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   576
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   577
06bc494ca11e Initial load
duke
parents:
diff changeset
   578
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   579
     * Return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   580
     * appear in an overview.
06bc494ca11e Initial load
duke
parents:
diff changeset
   581
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   582
     * appear in overview.
06bc494ca11e Initial load
duke
parents:
diff changeset
   583
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   584
    public Taglet[] getOverviewCustomTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   585
        if (overviewTags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   586
            initCustomTagArrays();
06bc494ca11e Initial load
duke
parents:
diff changeset
   587
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   588
        return overviewTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   589
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   590
06bc494ca11e Initial load
duke
parents:
diff changeset
   591
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   592
     * Initialize the custom tag arrays.
06bc494ca11e Initial load
duke
parents:
diff changeset
   593
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   594
    private void initCustomTagArrays() {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   595
        Iterator<Taglet> it = customTags.values().iterator();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   596
        ArrayList<Taglet> pTags = new ArrayList<Taglet>(customTags.size());
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   597
        ArrayList<Taglet> tTags = new ArrayList<Taglet>(customTags.size());
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   598
        ArrayList<Taglet> fTags = new ArrayList<Taglet>(customTags.size());
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   599
        ArrayList<Taglet> cTags = new ArrayList<Taglet>(customTags.size());
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   600
        ArrayList<Taglet> mTags = new ArrayList<Taglet>(customTags.size());
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   601
        ArrayList<Taglet> iTags = new ArrayList<Taglet>(customTags.size());
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   602
        ArrayList<Taglet> oTags = new ArrayList<Taglet>(customTags.size());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   603
        Taglet current;
06bc494ca11e Initial load
duke
parents:
diff changeset
   604
        while (it.hasNext()) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   605
            current = it.next();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   606
            if (current.inPackage() && !current.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   607
                pTags.add(current);
06bc494ca11e Initial load
duke
parents:
diff changeset
   608
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   609
            if (current.inType() && !current.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   610
                tTags.add(current);
06bc494ca11e Initial load
duke
parents:
diff changeset
   611
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   612
            if (current.inField() && !current.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   613
                fTags.add(current);
06bc494ca11e Initial load
duke
parents:
diff changeset
   614
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   615
            if (current.inConstructor() && !current.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   616
                cTags.add(current);
06bc494ca11e Initial load
duke
parents:
diff changeset
   617
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   618
            if (current.inMethod() && !current.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   619
                mTags.add(current);
06bc494ca11e Initial load
duke
parents:
diff changeset
   620
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   621
            if (current.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   622
                iTags.add(current);
06bc494ca11e Initial load
duke
parents:
diff changeset
   623
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   624
            if (current.inOverview() && !current.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   625
                oTags.add(current);
06bc494ca11e Initial load
duke
parents:
diff changeset
   626
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   627
        }
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   628
        packageTags = pTags.toArray(new Taglet[] {});
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   629
        typeTags = tTags.toArray(new Taglet[] {});
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   630
        fieldTags = fTags.toArray(new Taglet[] {});
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   631
        constructorTags = cTags.toArray(new Taglet[] {});
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   632
        methodTags = mTags.toArray(new Taglet[] {});
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   633
        overviewTags = oTags.toArray(new Taglet[] {});
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   634
        inlineTags = iTags.toArray(new Taglet[] {});
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   635
06bc494ca11e Initial load
duke
parents:
diff changeset
   636
        //Init the serialized form tags
06bc494ca11e Initial load
duke
parents:
diff changeset
   637
        serializedFormTags = new Taglet[4];
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   638
        serializedFormTags[0] = customTags.get("serialData");
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   639
        serializedFormTags[1] = customTags.get("throws");
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   640
        serializedFormTags[2] = customTags.get("since");
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   641
        serializedFormTags[3] = customTags.get("see");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   642
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   643
06bc494ca11e Initial load
duke
parents:
diff changeset
   644
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   645
     * Initialize standard Javadoc tags for ordering purposes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   646
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   647
    private void initStandardTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   648
        Taglet temp;
06bc494ca11e Initial load
duke
parents:
diff changeset
   649
        customTags.put((temp = new ParamTaglet()).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   650
        customTags.put((temp = new ReturnTaglet()).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   651
        customTags.put((temp = new ThrowsTaglet()).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   652
        customTags.put((temp = new SimpleTaglet("exception",
06bc494ca11e Initial load
duke
parents:
diff changeset
   653
            null, SimpleTaglet.METHOD + SimpleTaglet.CONSTRUCTOR)).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   654
        if (!nosince) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   655
            customTags.put((temp = new SimpleTaglet("since", message.getText("doclet.Since"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   656
               SimpleTaglet.ALL)).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   657
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   658
        if (showversion) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   659
            customTags.put((temp = new SimpleTaglet("version", message.getText("doclet.Version"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   660
                SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW)).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   661
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   662
        if (showauthor) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   663
            customTags.put((temp = new SimpleTaglet("author", message.getText("doclet.Author"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   664
                SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW)).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   665
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   666
        customTags.put((temp = new SimpleTaglet("serialData", message.getText("doclet.SerialData"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   667
            SimpleTaglet.EXCLUDED)).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   668
        customTags.put((temp = new SimpleTaglet("factory", message.getText("doclet.Factory"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   669
            SimpleTaglet.METHOD)).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   670
        customTags.put((temp = new SeeTaglet()).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   671
        //Standard inline tags
06bc494ca11e Initial load
duke
parents:
diff changeset
   672
        customTags.put((temp = new DocRootTaglet()).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   673
        customTags.put((temp = new InheritDocTaglet()).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   674
        customTags.put((temp = new ValueTaglet()).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   675
        customTags.put((temp = new LegacyTaglet(new LiteralTaglet())).getName(),
06bc494ca11e Initial load
duke
parents:
diff changeset
   676
            temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   677
        customTags.put((temp = new LegacyTaglet(new CodeTaglet())).getName(),
06bc494ca11e Initial load
duke
parents:
diff changeset
   678
            temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   679
06bc494ca11e Initial load
duke
parents:
diff changeset
   680
        //Keep track of the names of standard tags for error
06bc494ca11e Initial load
duke
parents:
diff changeset
   681
        //checking purposes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   682
        standardTags.add("param");
06bc494ca11e Initial load
duke
parents:
diff changeset
   683
        standardTags.add("return");
06bc494ca11e Initial load
duke
parents:
diff changeset
   684
        standardTags.add("throws");
06bc494ca11e Initial load
duke
parents:
diff changeset
   685
        standardTags.add("exception");
06bc494ca11e Initial load
duke
parents:
diff changeset
   686
        standardTags.add("since");
06bc494ca11e Initial load
duke
parents:
diff changeset
   687
        standardTags.add("version");
06bc494ca11e Initial load
duke
parents:
diff changeset
   688
        standardTags.add("author");
06bc494ca11e Initial load
duke
parents:
diff changeset
   689
        standardTags.add("see");
06bc494ca11e Initial load
duke
parents:
diff changeset
   690
        standardTags.add("deprecated");
06bc494ca11e Initial load
duke
parents:
diff changeset
   691
        standardTags.add("link");
06bc494ca11e Initial load
duke
parents:
diff changeset
   692
        standardTags.add("linkplain");
06bc494ca11e Initial load
duke
parents:
diff changeset
   693
        standardTags.add("inheritDoc");
06bc494ca11e Initial load
duke
parents:
diff changeset
   694
        standardTags.add("docRoot");
06bc494ca11e Initial load
duke
parents:
diff changeset
   695
        standardTags.add("value");
06bc494ca11e Initial load
duke
parents:
diff changeset
   696
        standardTags.add("serial");
06bc494ca11e Initial load
duke
parents:
diff changeset
   697
        standardTags.add("serialData");
06bc494ca11e Initial load
duke
parents:
diff changeset
   698
        standardTags.add("serialField");
06bc494ca11e Initial load
duke
parents:
diff changeset
   699
        standardTags.add("Text");
06bc494ca11e Initial load
duke
parents:
diff changeset
   700
        standardTags.add("literal");
06bc494ca11e Initial load
duke
parents:
diff changeset
   701
        standardTags.add("code");
06bc494ca11e Initial load
duke
parents:
diff changeset
   702
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   703
06bc494ca11e Initial load
duke
parents:
diff changeset
   704
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   705
     * Initialize lowercase version of standard Javadoc tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   706
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   707
    private void initStandardTagsLowercase() {
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   708
        Iterator<String> it = standardTags.iterator();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   709
        while (it.hasNext()) {
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   710
            standardTagsLowercase.add(it.next().toLowerCase());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   711
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   712
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   713
06bc494ca11e Initial load
duke
parents:
diff changeset
   714
    public boolean isKnownCustomTag(String tagName) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   715
        return customTags.containsKey(tagName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   716
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   717
06bc494ca11e Initial load
duke
parents:
diff changeset
   718
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   719
     * Print a list of {@link Taglet}s that might conflict with
06bc494ca11e Initial load
duke
parents:
diff changeset
   720
     * standard tags in the future and a list of standard tags
06bc494ca11e Initial load
duke
parents:
diff changeset
   721
     * that have been overriden.
06bc494ca11e Initial load
duke
parents:
diff changeset
   722
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   723
    public void printReport() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   724
        printReportHelper("doclet.Notice_taglet_conflict_warn", potentiallyConflictingTags);
06bc494ca11e Initial load
duke
parents:
diff changeset
   725
        printReportHelper("doclet.Notice_taglet_overriden", overridenStandardTags);
06bc494ca11e Initial load
duke
parents:
diff changeset
   726
        printReportHelper("doclet.Notice_taglet_unseen", unseenCustomTags);
06bc494ca11e Initial load
duke
parents:
diff changeset
   727
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   728
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   729
    private void printReportHelper(String noticeKey, Set<String> names) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   730
        if (names.size() > 0) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   731
            String[] namesArray = names.toArray(new String[] {});
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   732
            String result = " ";
06bc494ca11e Initial load
duke
parents:
diff changeset
   733
            for (int i = 0; i < namesArray.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   734
                result += "@" + namesArray[i];
06bc494ca11e Initial load
duke
parents:
diff changeset
   735
                if (i + 1 < namesArray.length) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   736
                    result += ", ";
06bc494ca11e Initial load
duke
parents:
diff changeset
   737
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   738
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   739
            message.notice(noticeKey, result);
06bc494ca11e Initial load
duke
parents:
diff changeset
   740
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   741
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   742
06bc494ca11e Initial load
duke
parents:
diff changeset
   743
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   744
     * Given the name of a tag, return the corresponding taglet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   745
     * Return null if the tag is unknown.
06bc494ca11e Initial load
duke
parents:
diff changeset
   746
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   747
     * @param name the name of the taglet to retrieve.
06bc494ca11e Initial load
duke
parents:
diff changeset
   748
     * @return return the corresponding taglet. Return null if the tag is
06bc494ca11e Initial load
duke
parents:
diff changeset
   749
     *         unknown.
06bc494ca11e Initial load
duke
parents:
diff changeset
   750
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   751
    public Taglet getTaglet(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   752
        if (name.indexOf("@") == 0) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   753
            return customTags.get(name.substring(1));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   754
        } else {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   755
            return customTags.get(name);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   756
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   757
06bc494ca11e Initial load
duke
parents:
diff changeset
   758
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   759
}