langtools/src/share/classes/com/sun/tools/javadoc/DocImpl.java
author jjg
Thu, 13 Sep 2012 14:29:36 -0700
changeset 13844 56339cf983a3
parent 10189 57268b86d4da
child 14258 8d2148961366
permissions -rw-r--r--
7177970: fix issues in langtools doc comments Reviewed-by: mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
13844
56339cf983a3 7177970: fix issues in langtools doc comments
jjg
parents: 10189
diff changeset
     2
 * Copyright (c) 1997, 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: 2212
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: 2212
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: 2212
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2212
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2212
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.javadoc;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
8632
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
    28
import java.io.DataInputStream;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import java.io.InputStream;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.io.IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import java.text.CollationKey;
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 10
diff changeset
    32
import javax.tools.FileObject;
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 10
diff changeset
    33
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 10
diff changeset
    34
import com.sun.javadoc.*;
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 10
diff changeset
    35
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
import com.sun.tools.javac.util.Position;
8632
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
    37
import java.util.regex.Matcher;
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
    38
import java.util.regex.Pattern;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * abstract base class of all Doc classes.  Doc item's are representations
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * of java language constructs (class, package, method,...) which have
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * comments and have been processed by this run of javadoc.  All Doc items
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * are unique, that is, they are == comparable.
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * @since 1.2
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * @author Robert Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 * @author Neal Gafter (rewrite)
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 */
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 10
diff changeset
    51
public abstract class DocImpl implements Doc, Comparable<Object> {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     * Doc environment
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    protected final DocEnv env;   //### Rename this everywhere to 'docenv' ?
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
     *  The complex comment object, lazily initialized.
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    private Comment comment;
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     * The cached sort key, to take care of Natural Language Text sorting.
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
    private CollationKey collationkey = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
     *  Raw documentation string.
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
    protected String documentation;  // Accessed in PackageDocImpl, RootDocImpl
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     * Cached first sentence.
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    private Tag[] firstSentence;
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * Cached inline tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    private Tag[] inlineTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
     * Constructor.
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    DocImpl(DocEnv env, String documentation) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
        this.documentation = documentation;
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
        this.env = env;
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     * So subclasses have the option to do lazy initialization of
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     * "documentation" string.
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     */
10189
57268b86d4da 7059905: (javadoc) promote method visibility for netbeans usage
ksrini
parents: 8632
diff changeset
    95
    protected String documentation() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
        if (documentation == null) documentation = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
        return documentation;
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
     * For lazy initialization of comment.
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    Comment comment() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
        if (comment == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
            comment = new Comment(this, documentation());
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
        return comment;
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     * Return the text of the comment for this doc item.
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
     * TagImpls have been removed.
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
    public String commentText() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
        return comment().commentText();
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     * Return all tags in this Doc item.
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     * @return an array of TagImpl containing all tags on this Doc item.
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
    public Tag[] tags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        return comment().tags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     * Return tags of the specified kind in this Doc item.
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     * @param tagname name of the tag kind to search for.
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
     * @return an array of TagImpl containing all tags whose 'kind()'
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     * matches 'tagname'.
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
    public Tag[] tags(String tagname) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
        return comment().tags(tagname);
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     * Return the see also tags in this Doc item.
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     *
13844
56339cf983a3 7177970: fix issues in langtools doc comments
jjg
parents: 10189
diff changeset
   141
     * @return an array of SeeTag containing all &#64;see tags.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
    public SeeTag[] seeTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
        return comment().seeTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
    public Tag[] inlineTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
        if (inlineTags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
            inlineTags = Comment.getInlineTags(this, commentText());
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
        return inlineTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
    public Tag[] firstSentenceTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
        if (firstSentence == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
            //Parse all sentences first to avoid duplicate warnings.
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
            inlineTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
            try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
                env.setSilent(true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
                firstSentence = Comment.firstSentenceTags(this, commentText());
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
            } finally {
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
                env.setSilent(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
        return firstSentence;
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     * Utility for subclasses which read HTML documentation files.
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
     */
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 10
diff changeset
   171
    String readHTMLDocumentation(InputStream input, FileObject filename) throws IOException {
8632
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
   172
        byte[] filecontents = new byte[input.available()];
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
   173
        try {
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
   174
            DataInputStream dataIn = new DataInputStream(input);
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
   175
            dataIn.readFully(filecontents);
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
   176
        } finally {
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
   177
            input.close();
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
   178
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
        String encoding = env.getEncoding();
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        String rawDoc = (encoding!=null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
            ? new String(filecontents, encoding)
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
            : new String(filecontents);
8632
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
   183
        Pattern bodyPat = Pattern.compile("(?is).*<body\\b[^>]*>(.*)</body\\b.*");
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
   184
        Matcher m = bodyPat.matcher(rawDoc);
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
   185
        if (m.matches()) {
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
   186
            return m.group(1);
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
   187
        } else {
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
   188
            String key = rawDoc.matches("(?is).*<body\\b.*")
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
   189
                    ? "javadoc.End_body_missing_from_html_file"
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
   190
                    : "javadoc.Body_missing_from_html_file";
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
   191
            env.error(SourcePositionImpl.make(filename, Position.NOPOS, null), key);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
            return "";
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
     * Return the full unprocessed text of the comment.  Tags
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
     * are included as text.  Used mainly for store and retrieve
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
     * operations like internalization.
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
    public String getRawCommentText() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        return documentation();
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
     * Set the full unprocessed text of the comment.  Tags
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
     * are included as text.  Used mainly for store and retrieve
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
     * operations like internalization.
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
    public void setRawCommentText(String rawDocumentation) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
        documentation = rawDocumentation;
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
        comment = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
     * return a key for sorting.
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
    CollationKey key() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        if (collationkey == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
            collationkey = generateKey();
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
        return collationkey;
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
     * Generate a key for sorting.
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
     * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
     * Default is name().
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
    CollationKey generateKey() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
        String k = name();
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
        // System.out.println("COLLATION KEY FOR " + this + " is \"" + k + "\"");
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
        return env.doclocale.collator.getCollationKey(k);
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
     * Returns a string representation of this Doc item.
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
     */
8632
af2a1f02c8ac 6227454: package.html and overview.html may not be read fully
jjg
parents: 5520
diff changeset
   239
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
    public String toString() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
        return qualifiedName();
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
     * Returns the name of this Doc item.
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
     * @return  the name
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
    public abstract String name();
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
     * Returns the qualified name of this Doc item.
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
     * @return  the name
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
    public abstract String qualifiedName();
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
     * Compares this Object with the specified Object for order.  Returns a
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
     * negative integer, zero, or a positive integer as this Object is less
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
     * than, equal to, or greater than the given Object.
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
     * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
     * Included so that Doc item are java.lang.Comparable.
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
     * @param   o the <code>Object</code> to be compared.
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
     * @return  a negative integer, zero, or a positive integer as this Object
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
     *          is less than, equal to, or greater than the given Object.
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
     * @exception ClassCastException the specified Object's type prevents it
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
     *            from being compared to this Object.
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
    public int compareTo(Object obj) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
        // System.out.println("COMPARE \"" + this + "\" to \"" + obj + "\" = " + key().compareTo(((DocImpl)obj).key()));
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
        return key().compareTo(((DocImpl)obj).key());
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
     * Is this Doc item a field?  False until overridden.
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
     * @return true if it represents a field
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
    public boolean isField() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
     * Is this Doc item an enum constant?  False until overridden.
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
     * @return true if it represents an enum constant
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
    public boolean isEnumConstant() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
     * Is this Doc item a constructor?  False until overridden.
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
     * @return true if it represents a constructor
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
    public boolean isConstructor() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
        return false;
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
     * Is this Doc item a method (but not a constructor or annotation
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
     * type element)?
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
     * False until overridden.
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
     * @return true if it represents a method
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
    public boolean isMethod() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
     * Is this Doc item an annotation type element?
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
     * False until overridden.
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
     * @return true if it represents an annotation type element
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
    public boolean isAnnotationTypeElement() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
     * Is this Doc item a interface (but not an annotation type)?
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
     * False until overridden.
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
     * @return true if it represents a interface
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
    public boolean isInterface() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
     * Is this Doc item a exception class?  False until overridden.
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
     * @return true if it represents a exception
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
    public boolean isException() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
     * Is this Doc item a error class?  False until overridden.
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
     * @return true if it represents a error
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
    public boolean isError() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
     * Is this Doc item an enum type?  False until overridden.
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
     * @return true if it represents an enum type
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
    public boolean isEnum() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
     * Is this Doc item an annotation type?  False until overridden.
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
     * @return true if it represents an annotation type
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
    public boolean isAnnotationType() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
     * Is this Doc item an ordinary class (i.e. not an interface,
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
     * annotation type, enumeration, exception, or error)?
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
     * False until overridden.
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
     * @return true if it represents an ordinary class
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
    public boolean isOrdinaryClass() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
     * Is this Doc item a class
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
     * (and not an interface or annotation type)?
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
     * This includes ordinary classes, enums, errors and exceptions.
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
     * False until overridden.
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
     * @return true if it represents a class
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
    public boolean isClass() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
     * return true if this Doc is include in the active set.
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
    public abstract boolean isIncluded();
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
     * Return the source position of the entity, or null if
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
     * no position is available.
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
    public SourcePosition position() { return null; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
}