KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > javadoc > Type


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
8 package com.sun.javadoc;
9
10 /**
11  * Represents a type. A type can be a class or interface, an
12  * invocation (like {@code List<String>}) of a generic class or interface,
13  * a type variable, a wildcard type ("<code>?</code>"),
14  * or a primitive data type (like <code>char</code>).
15  *
16  * @since JDK1.2
17  * @author Kaiyang Liu (original)
18  * @author Robert Field (rewrite)
19  * @author Scott Seligman (generics)
20  */

21 public interface Type {
22
23     /**
24      * Return unqualified name of type excluding any dimension information.
25      * <p>
26      * For example, a two dimensional array of String returns
27      * "<code>String</code>".
28      */

29     String JavaDoc typeName();
30
31     /**
32      * Return qualified name of type excluding any dimension information.
33      *<p>
34      * For example, a two dimensional array of String
35      * returns "<code>java.lang.String</code>".
36      */

37     String JavaDoc qualifiedTypeName();
38
39     /**
40      * Return the simple name of this type excluding any dimension information.
41      * This is the unqualified name of the type, except that for nested types
42      * only the identifier of the innermost type is included.
43      * <p>
44      * For example, the class {@code Outer.Inner} returns
45      * "<code>Inner</code>".
46      *
47      * @since 1.5
48      */

49     String JavaDoc simpleTypeName();
50
51     /**
52      * Return the type's dimension information, as a string.
53      * <p>
54      * For example, a two dimensional array of String returns
55      * "<code>[][]</code>".
56      */

57     String JavaDoc dimension();
58
59     /**
60      * Return a string representation of the type.
61      * This includes any dimension information and type arguments.
62      * <p>
63      * For example, a two dimensional array of String may return
64      * "<code>java.lang.String[][]</code>",
65      * and the parameterized type {@code List<Integer>} may return
66      * "{@code java.util.List<java.lang.Integer>}".
67      *
68      * @return a string representation of the type.
69      */

70     String JavaDoc toString();
71
72     /**
73      * Return true if this type represents a primitive type.
74      *
75      * @return true if this type represents a primitive type.
76      * @since 1.5
77      */

78     boolean isPrimitive();
79
80     /**
81      * Return this type as a <code>ClassDoc</code> if it represents a class
82      * or interface. Array dimensions are ignored.
83      * If this type is a <code>ParameterizedType</code>,
84      * <code>TypeVariable</code>, or <code>WildcardType</code>, return
85      * the <code>ClassDoc</code> of the type's erasure. If this is an
86      * <code>AnnotationTypeDoc</code>, return this as a <code>ClassDoc</code>
87      * (but see {@link #asAnnotationTypeDoc()}).
88      * If this is a primitive type, return null.
89      *
90      * @return the <code>ClassDoc</code> of this type,
91      * or null if it is a primitive type.
92      */

93     ClassDoc asClassDoc();
94
95     /**
96      * Return this type as a <code>ParameterizedType</code> if it represents
97      * an invocation of a generic class or interface. Array dimensions
98      * are ignored.
99      *
100      * @return a <code>ParameterizedType</code> if the type is an
101      * invocation of a generic type, or null if it is not.
102      * @since 1.5
103      */

104     ParameterizedType asParameterizedType();
105
106     /**
107      * Return this type as a <code>TypeVariable</code> if it represents
108      * a type variable. Array dimensions are ignored.
109      *
110      * @return a <code>TypeVariable</code> if the type is a type variable,
111      * or null if it is not.
112      * @since 1.5
113      */

114     TypeVariable asTypeVariable();
115
116     /**
117      * Return this type as a <code>WildcardType</code> if it represents
118      * a wildcard type.
119      *
120      * @return a <code>WildcardType</code> if the type is a wildcard type,
121      * or null if it is not.
122      * @since 1.5
123      */

124     WildcardType asWildcardType();
125
126     /**
127      * Return this type as an <code>AnnotationTypeDoc</code> if it represents
128      * an annotation type. Array dimensions are ignored.
129      *
130      * @return an <code>AnnotationTypeDoc</code> if the type is an annotation
131      * type, or null if it is not.
132      * @since 1.5
133      */

134     AnnotationTypeDoc asAnnotationTypeDoc();
135 }
136
Popular Tags