1. /*
  2. * @(#)Doc.java 1.15 02/09/29
  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 Java language constructs (package, class, constructor,
  10. * method, field) which have comments and have been processed by this
  11. * run of javadoc. All Doc objects are unique, that is, they
  12. * are == comparable.
  13. *
  14. * @since JDK1.2
  15. * @author Robert Field
  16. * @author Scott Seligman (generics, enums, annotations)
  17. */
  18. public interface Doc extends Comparable<Object> {
  19. /**
  20. * Return the text of the comment for this doc item.
  21. * Tags have been removed.
  22. */
  23. String commentText();
  24. /**
  25. * Return all tags in this Doc item.
  26. *
  27. * @return an array of {@link Tag} objects containing all tags on
  28. * this Doc item.
  29. */
  30. Tag[] tags();
  31. /**
  32. * Return tags of the specified {@linkplain Tag#kind() kind} in
  33. * this Doc item.
  34. *
  35. * For example, if 'tagname' has value "@serial", all tags in
  36. * this Doc item of kind "@serial" will be returned.
  37. *
  38. * @param tagname name of the tag kind to search for.
  39. * @return an array of Tag containing all tags whose 'kind()'
  40. * matches 'tagname'.
  41. */
  42. Tag[] tags(String tagname);
  43. /**
  44. * Return the see also tags in this Doc item.
  45. *
  46. * @return an array of SeeTag containing all @see tags.
  47. */
  48. SeeTag[] seeTags();
  49. /**
  50. * Return comment as an array of tags. Includes inline tags
  51. * (i.e. {@link <i>reference</i>} tags) but not
  52. * block tags.
  53. * Each section of plain text is represented as a {@link Tag}
  54. * of {@linkplain Tag#kind() kind} "Text".
  55. * Inline tags are represented as a {@link SeeTag} of kind "@see"
  56. * and name "@link".
  57. *
  58. * @return an array of {@link Tag}s representing the comment
  59. */
  60. Tag[] inlineTags();
  61. /**
  62. * Return the first sentence of the comment as an array of tags.
  63. * Includes inline tags
  64. * (i.e. {@link <i>reference</i>} tags) but not
  65. * block tags.
  66. * Each section of plain text is represented as a {@link Tag}
  67. * of {@linkplain Tag#kind() kind} "Text".
  68. * Inline tags are represented as a {@link SeeTag} of kind "@see"
  69. * and name "@link".
  70. * <p>
  71. * If the locale is English language, the first sentence is
  72. * determined by the rules described in the Java Language
  73. * Specification (first version): "This sentence ends
  74. * at the first period that is followed by a blank, tab, or
  75. * line terminator or at the first tagline.", in
  76. * addition a line will be terminated by block
  77. * HTML tags: <p> </p> <h1>
  78. * <h2> <h3> <h4> <h5> <h6>
  79. * <hr> <pre> or </pre>.
  80. * If the locale is not English, the sentence end will be
  81. * determined by
  82. * {@link java.text.BreakIterator#getSentenceInstance(Locale)
  83. * java.text.BreakIterator.getSentenceInstance(Locale)}.
  84. * @return an array of {@link Tag}s representing the
  85. * first sentence of the comment
  86. */
  87. Tag[] firstSentenceTags();
  88. /**
  89. * Return the full unprocessed text of the comment. Tags
  90. * are included as text. Used mainly for store and retrieve
  91. * operations like internalization.
  92. */
  93. String getRawCommentText();
  94. /**
  95. * Set the full unprocessed text of the comment. Tags
  96. * are included as text. Used mainly for store and retrieve
  97. * operations like internalization.
  98. */
  99. void setRawCommentText(String rawDocumentation);
  100. /**
  101. * Returns the non-qualified name of this Doc item.
  102. *
  103. * @return the name
  104. */
  105. String name();
  106. /**
  107. * Compares this doc object with the specified object for order. Returns a
  108. * negative integer, zero, or a positive integer as this doc object is less
  109. * than, equal to, or greater than the given object.
  110. * <p>
  111. * This method satisfies the {@link java.lang.Comparable} interface.
  112. *
  113. * @param obj the <code>Object</code> to be compared.
  114. * @return a negative integer, zero, or a positive integer as this Object
  115. * is less than, equal to, or greater than the given Object.
  116. * @exception ClassCastException the specified Object's type prevents it
  117. * from being compared to this Object.
  118. */
  119. int compareTo(Object obj);
  120. /**
  121. * Is this Doc item a field (but not an enum constant)?
  122. *
  123. * @return true if it represents a field
  124. */
  125. boolean isField();
  126. /**
  127. * Is this Doc item an enum constant?
  128. *
  129. * @return true if it represents an enum constant
  130. * @since 1.5
  131. */
  132. boolean isEnumConstant();
  133. /**
  134. * Is this Doc item a constructor?
  135. *
  136. * @return true if it represents a constructor
  137. */
  138. boolean isConstructor();
  139. /**
  140. * Is this Doc item a method (but not a constructor or annotation
  141. * type element)?
  142. *
  143. * @return true if it represents a method
  144. */
  145. boolean isMethod();
  146. /**
  147. * Is this Doc item an annotation type element?
  148. *
  149. * @return true if it represents an annotation type element
  150. * @since 1.5
  151. */
  152. boolean isAnnotationTypeElement();
  153. /**
  154. * Is this Doc item an interface (but not an annotation type)?
  155. *
  156. * @return true if it represents an interface
  157. */
  158. boolean isInterface();
  159. /**
  160. * Is this Doc item an exception class?
  161. *
  162. * @return true if it represents an exception
  163. */
  164. boolean isException();
  165. /**
  166. * Is this Doc item an error class?
  167. *
  168. * @return true if it represents a error
  169. */
  170. boolean isError();
  171. /**
  172. * Is this Doc item an enum type?
  173. *
  174. * @return true if it represents an enum type
  175. * @since 1.5
  176. */
  177. boolean isEnum();
  178. /**
  179. * Is this Doc item an annotation type?
  180. *
  181. * @return true if it represents an annotation type
  182. * @since 1.5
  183. */
  184. boolean isAnnotationType();
  185. /**
  186. * Is this Doc item an
  187. * <a href="{@docRoot}/com/sun/javadoc/package-summary.html#class">ordinary
  188. * class</em></a>?
  189. * (i.e. not an interface, annotation type, enum, exception, or error)?
  190. *
  191. * @return true if it represents an ordinary class
  192. */
  193. boolean isOrdinaryClass();
  194. /**
  195. * Is this Doc item a
  196. * <a href="{@docRoot}/com/sun/javadoc/package-summary.html#class">class</a>
  197. * (and not an interface or annotation type)?
  198. * This includes ordinary classes, enums, errors and exceptions.
  199. *
  200. * @return true if it represents a class
  201. */
  202. boolean isClass();
  203. /**
  204. * Return true if this Doc item is
  205. * <a href="{@docRoot}/com/sun/javadoc/package-summary.html#included">included</a>
  206. * in the result set.
  207. */
  208. boolean isIncluded();
  209. /**
  210. * Return the source position of the first line of the
  211. * corresponding declaration, or null if
  212. * no position is available. A default constructor returns
  213. * null because it has no location in the source file.
  214. *
  215. * @since 1.4
  216. */
  217. SourcePosition position();
  218. }