1. /*
  2. * @(#)Tag.java 1.12 02/10/15
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.javadoc;
  8. /**
  9. * Represents a simple documentation tag, such as @since, @author, @version.
  10. * Given a tag (e.g. "@since 1.2"), holds tag name (e.g. "@since")
  11. * and tag text (e.g. "1.2"). Tags with structure or which require
  12. * special processing are handled by subclasses such as ParamTag
  13. * (for @param), SeeTag (for @see and {@link}), and ThrowsTag
  14. * (for @throws).
  15. *
  16. * @author Robert Field
  17. * @author Atul M Dambalkar
  18. * @see SeeTag
  19. * @see ParamTag
  20. * @see ThrowsTag
  21. * @see SerialFieldTag
  22. * @see Doc#tags()
  23. *
  24. */
  25. public interface Tag {
  26. /**
  27. * Return the name of this tag. The name is the string
  28. * starting with "@" that is used in a doc comment, such as
  29. * <code>@return</code>. For inline tags, such as
  30. * <code>{@link}</code>, the curly brackets
  31. * are not part of the name, so in this example the name
  32. * would be simply <code>@link</code>.
  33. */
  34. String name();
  35. /**
  36. * Return the containing {@link Doc} of this Tag element.
  37. */
  38. Doc holder();
  39. /**
  40. * Return the kind of this tag.
  41. * similar or synonymous tags. For most tags,
  42. * <code>kind() == name()</code>
  43. * the following table lists those cases where there is more
  44. * than one tag of a given kind:
  45. * <p>
  46. * <table border="1" cellpadding="4" cellspacing="0">
  47. * <tr><th><tt> kind() </th> <th><tt> name() </th></tr>
  48. * <tr><td><tt> @throws </td> <td><tt> @throws </td></tr>
  49. * <tr><td><tt> @throws </td> <td><tt> @exception </td></tr>
  50. * <tr><td><tt> @see </td> <td><tt> @see </td></tr>
  51. * <tr><td><tt> @see </td> <td><tt> @link </td></tr>
  52. * <tr><td><tt> @see </td> <td><tt> @linkplain </td></tr>
  53. * <tr><td><tt> @serial </td> <td><tt> @serial </td></tr>
  54. * <tr><td><tt> @serial </td> <td><tt> @serialData </td></tr>
  55. * </table>
  56. */
  57. String kind();
  58. /**
  59. * Return the text of this tag, that is, portion beyond tag name.
  60. */
  61. String text();
  62. /**
  63. * Convert this object to a string.
  64. */
  65. String toString();
  66. /**
  67. * For a documentation comment with embedded <code>{@link}</code>
  68. * tags, return an array of <code>Tag</code> objects. The entire
  69. * doc comment is broken down into strings separated by
  70. * <code>{@link}</code> tags, where each successive element
  71. * of the array represents either a string or
  72. * <code>{@link}</code> tag, in order, from start to end.
  73. * Each string is represented by a <code>Tag</code> object of
  74. * name "Text", where {@link #text()} returns the string. Each
  75. * <code>{@link}</code> tag is represented by a
  76. * {@link SeeTag} of name "@link" and kind "@see".
  77. * For example, given the following comment
  78. * tag:
  79. * <p>
  80. * <code>This is a {@link Doc commentlabel} example.</code>
  81. * <p>
  82. * return an array of Tag objects:
  83. * <ul>
  84. * <li> tags[0] is a {@link Tag} with name "Text" and text consisting
  85. * of "This is a "
  86. * <li> tags[1] is a {@link SeeTag} with name "@link", referenced
  87. * class <code>Doc</code> and label "commentlabel"
  88. * <li> tags[2] is a {@link Tag} with name "Text" and text consisting
  89. * of " example."
  90. * </ul>
  91. *
  92. * @return Tag[] array of tags
  93. * @see ParamTag
  94. * @see ThrowsTag
  95. */
  96. Tag[] inlineTags();
  97. /**
  98. * Return the first sentence of the comment as an array of tags.
  99. * Includes inline tags
  100. * (i.e. {@link <i>reference</i>} tags) but not
  101. * block tags.
  102. * Each section of plain text is represented as a {@link Tag}
  103. * of kind "Text".
  104. * Inline tags are represented as a {@link SeeTag} of kind "@link".
  105. * If the locale is English language, the first sentence is
  106. * determined by the rules described in the Java Language
  107. * Specification (first version): "This sentence ends
  108. * at the first period that is followed by a blank, tab, or
  109. * line terminator or at the first tagline.", in
  110. * addition a line will be terminated by paragraph and
  111. * section terminating HTML tags: <p> </p> <h1>
  112. * <h2> <h3> <h4> <h5> <h6>
  113. * <hr> <pre> or </pre>.
  114. * If the locale is not English, the sentence end will be
  115. * determined by
  116. * {@link java.text.BreakIterator#getSentenceInstance(Locale)
  117. * java.text.BreakIterator.getSentenceInstance(Locale)}.
  118. *
  119. * @return an array of {@link Tag} objects representing the
  120. * first sentence of the comment
  121. */
  122. Tag[] firstSentenceTags();
  123. /**
  124. * Return the source position of this tag.
  125. * @return the source position of this tag.
  126. */
  127. public SourcePosition position();
  128. }