langtools/src/share/classes/com/sun/javadoc/Tag.java
author jjg
Thu, 13 Sep 2012 14:29:36 -0700
changeset 13844 56339cf983a3
parent 5520 86e4b9a9da40
child 14259 fb94a1df0d53
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: 5520
diff changeset
     2
 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
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: 10
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: 10
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
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.javadoc;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import java.text.BreakIterator;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import java.util.Locale;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 * Represents a simple documentation tag, such as @since, @author, @version.
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * Given a tag (e.g. "@since 1.2"), holds tag name (e.g. "@since")
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * and tag text (e.g. "1.2").  Tags with structure or which require
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * special processing are handled by subclasses such as ParamTag
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * (for @param), SeeTag (for @see and {@link}), and ThrowsTag
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * (for @throws).
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * @author Robert Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * @see SeeTag
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * @see ParamTag
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * @see ThrowsTag
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * @see SerialFieldTag
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * @see Doc#tags()
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
public interface Tag {
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     * Return the name of this tag.  The name is the string
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     * starting with "@" that is used in a doc comment, such as
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
     * <code>@return</code>.  For inline tags, such as
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     * <code>{&#064;link}</code>, the curly brackets
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     * are not part of the name, so in this example the name
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     * would be simply <code>@link</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    String name();
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     * Return the containing {@link Doc} of this Tag element.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    Doc holder();
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     * Return the kind of this tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     * similar or synonymous tags.  For most tags,
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     * <code>kind()&nbsp;==&nbsp;name()</code>;
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
     * the following table lists those cases where there is more
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     * than one tag of a given kind:
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     * <table border="1" cellpadding="4" cellspacing="0">
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     * <tr><th><tt> kind()  </th>  <th><tt> name()      </th></tr>
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     * <tr><td><tt> @throws </td>  <td><tt> @throws     </td></tr>
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     * <tr><td><tt> @throws </td>  <td><tt> @exception  </td></tr>
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     * <tr><td><tt> @see    </td>  <td><tt> @see        </td></tr>
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     * <tr><td><tt> @see    </td>  <td><tt> @link       </td></tr>
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     * <tr><td><tt> @see    </td>  <td><tt> @linkplain  </td></tr>
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * <tr><td><tt> @serial </td>  <td><tt> @serial     </td></tr>
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     * <tr><td><tt> @serial </td>  <td><tt> @serialData </td></tr>
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
     * </table>
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    String kind();
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     * Return the text of this tag, that is, portion beyond tag name.
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    String text();
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     * Convert this object to a string.
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
    String toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     * For a documentation comment with embedded <code>{&#064;link}</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     * tags, return an array of <code>Tag</code> objects.  The entire
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
     * doc comment is broken down into strings separated by
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
     * <code>{&#064;link}</code> tags, where each successive element
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
     * of the array represents either a string or
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
     * <code>{&#064;link}</code> tag, in order, from start to end.
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     * Each string is represented by a <code>Tag</code> object of
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     * name "Text", where {@link #text()} returns the string.  Each
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
     * <code>{&#064;link}</code> tag is represented by a
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     * {@link SeeTag} of name "@link" and kind "@see".
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     * For example, given the following comment
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     * tag:
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     *  <code>This is a {&#064;link Doc commentlabel} example.</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     * return an array of Tag objects:
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
     * <ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     *    <li> tags[0] is a {@link Tag} with name "Text" and text consisting
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
     *         of "This is a "
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
     *    <li> tags[1] is a {@link SeeTag} with name "@link", referenced
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     *         class <code>Doc</code> and label "commentlabel"
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     *    <li> tags[2] is a {@link Tag} with name "Text" and text consisting
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     *         of " example."
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     * </ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     * @return Tag[] array of tags
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     * @see ParamTag
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     * @see ThrowsTag
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
    Tag[] inlineTags();
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 the first sentence of the comment as an array of tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     * Includes inline tags
13844
56339cf983a3 7177970: fix issues in langtools doc comments
jjg
parents: 5520
diff changeset
   130
     * (i.e. {&#64;link <i>reference</i>} tags)  but not
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
     * block tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     * Each section of plain text is represented as a {@link Tag}
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     * of kind "Text".
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     * Inline tags are represented as a {@link SeeTag} of kind "@link".
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     * If the locale is English language, the first sentence is
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     * determined by the rules described in the Java Language
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     * Specification (first version): &quot;This sentence ends
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     * at the first period that is followed by a blank, tab, or
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     * line terminator or at the first tagline.&quot;, in
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     * addition a line will be terminated by paragraph and
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
     * section terminating HTML tags: &lt;p&gt;  &lt;/p&gt;  &lt;h1&gt;
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     * &lt;h2&gt;  &lt;h3&gt; &lt;h4&gt;  &lt;h5&gt;  &lt;h6&gt;
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
     * &lt;hr&gt;  &lt;pre&gt;  or &lt;/pre&gt;.
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
     * If the locale is not English, the sentence end will be
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
     * determined by
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
     * {@link BreakIterator#getSentenceInstance(Locale)}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
     * @return an array of {@link Tag} objects representing the
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
     *         first sentence of the comment
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
    Tag[] firstSentenceTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
     * Return the source position of this tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
     * @return the source position of this tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
    public SourcePosition position();
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
}