1. /*
  2. * @(#)Type.java 1.18 04/04/30
  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 type. A type can be a class or interface, an
  10. * invocation (like {@code List<String>}) of a generic class or interface,
  11. * a type variable, a wildcard type ("<code>?</code>"),
  12. * or a primitive data type (like <code>char</code>).
  13. *
  14. * @since JDK1.2
  15. * @author Kaiyang Liu (original)
  16. * @author Robert Field (rewrite)
  17. * @author Scott Seligman (generics)
  18. */
  19. public interface Type {
  20. /**
  21. * Return unqualified name of type excluding any dimension information.
  22. * <p>
  23. * For example, a two dimensional array of String returns
  24. * "<code>String</code>".
  25. */
  26. String typeName();
  27. /**
  28. * Return qualified name of type excluding any dimension information.
  29. *<p>
  30. * For example, a two dimensional array of String
  31. * returns "<code>java.lang.String</code>".
  32. */
  33. String qualifiedTypeName();
  34. /**
  35. * Return the simple name of this type excluding any dimension information.
  36. * This is the unqualified name of the type, except that for nested types
  37. * only the identifier of the innermost type is included.
  38. * <p>
  39. * For example, the class {@code Outer.Inner} returns
  40. * "<code>Inner</code>".
  41. *
  42. * @since 1.5
  43. */
  44. String simpleTypeName();
  45. /**
  46. * Return the type's dimension information, as a string.
  47. * <p>
  48. * For example, a two dimensional array of String returns
  49. * "<code>[][]</code>".
  50. */
  51. String dimension();
  52. /**
  53. * Return a string representation of the type.
  54. * This includes any dimension information and type arguments.
  55. * <p>
  56. * For example, a two dimensional array of String may return
  57. * "<code>java.lang.String[][]</code>",
  58. * and the parameterized type {@code List<Integer>} may return
  59. * "{@code java.util.List<java.lang.Integer>}".
  60. *
  61. * @return a string representation of the type.
  62. */
  63. String toString();
  64. /**
  65. * Return true if this type represents a primitive type.
  66. *
  67. * @return true if this type represents a primitive type.
  68. * @since 1.5
  69. */
  70. boolean isPrimitive();
  71. /**
  72. * Return this type as a <code>ClassDoc</code> if it represents a class
  73. * or interface. Array dimensions are ignored.
  74. * If this type is a <code>ParameterizedType</code>,
  75. * <code>TypeVariable</code>, or <code>WildcardType</code>, return
  76. * the <code>ClassDoc</code> of the type's erasure. If this is an
  77. * <code>AnnotationTypeDoc</code>, return this as a <code>ClassDoc</code>
  78. * (but see {@link #asAnnotationTypeDoc()}).
  79. * If this is a primitive type, return null.
  80. *
  81. * @return the <code>ClassDoc</code> of this type,
  82. * or null if it is a primitive type.
  83. */
  84. ClassDoc asClassDoc();
  85. /**
  86. * Return this type as a <code>ParameterizedType</code> if it represents
  87. * an invocation of a generic class or interface. Array dimensions
  88. * are ignored.
  89. *
  90. * @return a <code>ParameterizedType</code> if the type is an
  91. * invocation of a generic type, or null if it is not.
  92. * @since 1.5
  93. */
  94. ParameterizedType asParameterizedType();
  95. /**
  96. * Return this type as a <code>TypeVariable</code> if it represents
  97. * a type variable. Array dimensions are ignored.
  98. *
  99. * @return a <code>TypeVariable</code> if the type is a type variable,
  100. * or null if it is not.
  101. * @since 1.5
  102. */
  103. TypeVariable asTypeVariable();
  104. /**
  105. * Return this type as a <code>WildcardType</code> if it represents
  106. * a wildcard type.
  107. *
  108. * @return a <code>WildcardType</code> if the type is a wildcard type,
  109. * or null if it is not.
  110. * @since 1.5
  111. */
  112. WildcardType asWildcardType();
  113. /**
  114. * Return this type as an <code>AnnotationTypeDoc</code> if it represents
  115. * an annotation type. Array dimensions are ignored.
  116. *
  117. * @return an <code>AnnotationTypeDoc</code> if the type is an annotation
  118. * type, or null if it is not.
  119. * @since 1.5
  120. */
  121. AnnotationTypeDoc asAnnotationTypeDoc();
  122. }