1. /*
  2. * @(#)ClassDoc.java 1.15 02/10/06
  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 java class or interface and provides access to
  10. * information about the class, the class's comment and tags, and the
  11. * members of the class. A ClassDoc only exists if it was
  12. * processed in this run of javadoc. References to classes
  13. * which may or may not have been processed in this run are
  14. * referred to using Type (which can be converted to ClassDoc,
  15. * if possible).
  16. *
  17. * @see Type
  18. *
  19. * @since JDK1.2
  20. * @author Kaiyang Liu (original)
  21. * @author Robert Field (rewrite)
  22. */
  23. public interface ClassDoc extends ProgramElementDoc, Type {
  24. /**
  25. * Return true if this class is abstract. Return true
  26. * for all interfaces.
  27. */
  28. boolean isAbstract();
  29. /**
  30. * Return true if this class implements or interface extends
  31. * <code>java.io.Serializable</code>.
  32. *
  33. * Since <code>java.io.Externalizable</code> extends
  34. * <code>java.io.Serializable</code>,
  35. * Externalizable objects are also Serializable.
  36. */
  37. boolean isSerializable();
  38. /**
  39. * Return true if this class implements or interface extends
  40. * <code>java.io.Externalizable</code>.
  41. */
  42. boolean isExternalizable();
  43. /**
  44. * Return the serialization methods for this class or
  45. * interface.
  46. *
  47. * @return an array of MethodDoc objects that represents
  48. * the serialization methods for this class or interface.
  49. */
  50. MethodDoc[] serializationMethods();
  51. /**
  52. * Return the Serializable fields of this class or interface.
  53. * <p>
  54. * Return either a list of default fields documented by
  55. * <code>serial</code> tag<br>
  56. * or return a single <code>FieldDoc</code> for
  57. * <code>serialPersistentField</code> member.
  58. * There should be a <code>serialField</code> tag for
  59. * each Serializable field defined by an <code>ObjectStreamField</code>
  60. * array component of <code>serialPersistentField</code>.
  61. *
  62. * @return an array of <code>FieldDoc</code> objects for the Serializable
  63. * fields of this class or interface.
  64. *
  65. * @see #definesSerializableFields()
  66. * @see SerialFieldTag
  67. */
  68. FieldDoc[] serializableFields();
  69. /**
  70. * Return true if Serializable fields are explicitly defined with
  71. * the special class member <code>serialPersistentFields</code>.
  72. *
  73. * @see #serializableFields()
  74. * @see SerialFieldTag
  75. */
  76. boolean definesSerializableFields();
  77. /**
  78. * Return the superclass of this class. Return null if this is an
  79. * interface.
  80. *
  81. * <p> <i>This method cannot accommodate certain generic type constructs.
  82. * The <code>superclassType</code> method should be used instead.</i>
  83. *
  84. * @return the ClassDoc for the superclass of this class, null if
  85. * there is no superclass.
  86. * @see #superclassType
  87. */
  88. ClassDoc superclass();
  89. /**
  90. * Return the superclass of this class. Return null if this is an
  91. * interface. A superclass is represented by either a
  92. * <code>ClassDoc</code> or a <code>ParametrizedType</code>.
  93. *
  94. * @return the superclass of this class, or null if there is no superclass.
  95. * @since 1.5
  96. */
  97. Type superclassType();
  98. /**
  99. * Test whether this class is a subclass of the specified class.
  100. * If this is an interface, return false for all classes except
  101. * <code>java.lang.Object</code> (we must keep this unexpected
  102. * behavior for compatibility reasons).
  103. *
  104. * @param cd the candidate superclass.
  105. * @return true if cd is a superclass of this class.
  106. */
  107. boolean subclassOf(ClassDoc cd);
  108. /**
  109. * Return interfaces implemented by this class or interfaces extended
  110. * by this interface. Includes only directly-declared interfaces, not
  111. * inherited interfaces.
  112. * Return an empty array if there are no interfaces.
  113. *
  114. * <p> <i>This method cannot accommodate certain generic type constructs.
  115. * The <code>interfaceTypes</code> method should be used instead.</i>
  116. *
  117. * @return an array of ClassDoc objects representing the interfaces.
  118. * @see #interfaceTypes
  119. */
  120. ClassDoc[] interfaces();
  121. /**
  122. * Return interfaces implemented by this class or interfaces extended
  123. * by this interface. Includes only directly-declared interfaces, not
  124. * inherited interfaces.
  125. * Return an empty array if there are no interfaces.
  126. *
  127. * @return an array of interfaces, each represented by a
  128. * <code>ClassDoc</code> or a <code>ParametrizedType</code>.
  129. * @since 1.5
  130. */
  131. Type[] interfaceTypes();
  132. /**
  133. * Return the formal type parameters of this class or interface.
  134. * Return an empty array if there are none.
  135. *
  136. * @return the formal type parameters of this class or interface.
  137. * @since 1.5
  138. */
  139. TypeVariable[] typeParameters();
  140. /**
  141. * Return the type parameter tags of this class or interface.
  142. * Return an empty array if there are none.
  143. *
  144. * @return the type parameter tags of this class or interface.
  145. * @since 1.5
  146. */
  147. ParamTag[] typeParamTags();
  148. /**
  149. * Return
  150. * <a href="{@docRoot}/com/sun/javadoc/package-summary.html#included">included</a>
  151. * fields in this class or interface.
  152. * Excludes enum constants if this is an enum type.
  153. *
  154. * @return an array of FieldDoc objects representing the included
  155. * fields in this class or interface.
  156. */
  157. FieldDoc[] fields();
  158. /**
  159. * Return fields in this class or interface, filtered to the specified
  160. * <a href="{@docRoot}/com/sun/javadoc/package-summary.html#included">access
  161. * modifier option</a>.
  162. * Excludes enum constants if this is an enum type.
  163. *
  164. * @param filter Specify true to filter according to the specified access
  165. * modifier option.
  166. * Specify false to include all fields regardless of
  167. * access modifier option.
  168. * @return an array of FieldDoc objects representing the included
  169. * fields in this class or interface.
  170. */
  171. FieldDoc[] fields(boolean filter);
  172. /**
  173. * Return the enum constants if this is an enum type.
  174. * Return an empty array if there are no enum constants, or if
  175. * this is not an enum type.
  176. *
  177. * @return the enum constants if this is an enum type.
  178. */
  179. FieldDoc[] enumConstants();
  180. /**
  181. * Return
  182. * <a href="{@docRoot}/com/sun/javadoc/package-summary.html#included">included</a>
  183. * methods in this class or interface.
  184. * Same as <code>methods(true)</code>.
  185. *
  186. * @return an array of MethodDoc objects representing the included
  187. * methods in this class or interface. Does not include
  188. * constructors or annotation type elements.
  189. */
  190. MethodDoc[] methods();
  191. /**
  192. * Return methods in this class or interface, filtered to the specified
  193. * <a href="{@docRoot}/com/sun/javadoc/package-summary.html#included">access
  194. * modifier option</a>. Does not include constructors or annotation
  195. * type elements.
  196. *
  197. * @param filter Specify true to filter according to the specified access
  198. * modifier option.
  199. * Specify false to include all methods regardless of
  200. * access modifier option.
  201. * @return an array of MethodDoc objects representing the included
  202. * methods in this class or interface.
  203. */
  204. MethodDoc[] methods(boolean filter);
  205. /**
  206. * Return
  207. * <a href="{@docRoot}/com/sun/javadoc/package-summary.html#included">included</a>
  208. * constructors in this class. An array containing the default
  209. * no-arg constructor is returned if no other constructors exist.
  210. * Return empty array if this is an interface.
  211. *
  212. * @return an array of ConstructorDoc objects representing the included
  213. * constructors in this class.
  214. */
  215. ConstructorDoc[] constructors();
  216. /**
  217. * Return constructors in this class, filtered to the specified
  218. * <a href="{@docRoot}/com/sun/javadoc/package-summary.html#included">access
  219. * modifier option</a>. Return an array containing the default
  220. * no-arg constructor if no other constructors exist.
  221. *
  222. * @param filter Specify true to filter according to the specified access
  223. * modifier option.
  224. * Specify false to include all constructors regardless of
  225. * access modifier option.
  226. * @return an array of ConstructorDoc objects representing the included
  227. * constructors in this class.
  228. */
  229. ConstructorDoc[] constructors(boolean filter);
  230. /**
  231. * Return
  232. * <a href="{@docRoot}/com/sun/javadoc/package-summary.html#included">included</a>
  233. * nested classes and interfaces within this class or interface.
  234. * This includes both static and non-static nested classes.
  235. * (This method should have been named <code>nestedClasses()</code>,
  236. * as inner classes are technically non-static.) Anonymous and local classes
  237. * or interfaces are not included.
  238. *
  239. * @return an array of ClassDoc objects representing the included classes
  240. * and interfaces defined in this class or interface.
  241. */
  242. ClassDoc[] innerClasses();
  243. /**
  244. * Return nested classes and interfaces within this class or interface
  245. * filtered to the specified
  246. * <a href="{@docRoot}/com/sun/javadoc/package-summary.html#included">access
  247. * modifier option</a>.
  248. * This includes both static and non-static nested classes.
  249. * Anonymous and local classes are not included.
  250. *
  251. * @param filter Specify true to filter according to the specified access
  252. * modifier option.
  253. * Specify false to include all nested classes regardless of
  254. * access modifier option.
  255. * @return a filtered array of ClassDoc objects representing the included
  256. * classes and interfaces defined in this class or interface.
  257. */
  258. ClassDoc[] innerClasses(boolean filter);
  259. /**
  260. * Find the specified class or interface within the context of this class doc.
  261. * Search order: 1) qualified name, 2) nested in this class or interface,
  262. * 3) in this package, 4) in the class imports, 5) in the package imports.
  263. * Return the ClassDoc if found, null if not found.
  264. */
  265. ClassDoc findClass(String className);
  266. /**
  267. * Get the list of classes and interfaces declared as imported.
  268. * These are called "single-type-import declarations" in the
  269. * Java Language Specification.
  270. *
  271. * @return an array of ClassDoc representing the imported classes.
  272. *
  273. * @deprecated Import declarations are implementation details that
  274. * should not be exposed here. In addition, not all imported
  275. * classes are imported through single-type-import declarations.
  276. */
  277. @Deprecated
  278. ClassDoc[] importedClasses();
  279. /**
  280. * Get the list of packages declared as imported.
  281. * These are called "type-import-on-demand declarations" in the
  282. * Java Language Specification.
  283. *
  284. * @return an array of PackageDoc representing the imported packages.
  285. *
  286. * @deprecated Import declarations are implementation details that
  287. * should not be exposed here. In addition, this method's
  288. * return type does not allow for all type-import-on-demand
  289. * declarations to be returned.
  290. */
  291. @Deprecated
  292. PackageDoc[] importedPackages();
  293. }