langtools/src/share/classes/com/sun/javadoc/Type.java
changeset 23136 aa8958a4c8f4
parent 16969 b58d8a70d921
equal deleted inserted replaced
23135:3c45d467788f 23136:aa8958a4c8f4
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    26 package com.sun.javadoc;
    26 package com.sun.javadoc;
    27 
    27 
    28 /**
    28 /**
    29  * Represents a type.  A type can be a class or interface, an
    29  * Represents a type.  A type can be a class or interface, an
    30  * invocation (like {@code List<String>}) of a generic class or interface,
    30  * invocation (like {@code List<String>}) of a generic class or interface,
    31  * a type variable, a wildcard type ("<code>?</code>"),
    31  * a type variable, a wildcard type ("{@code ?}"),
    32  * or a primitive data type (like <code>char</code>).
    32  * or a primitive data type (like {@code char}).
    33  *
    33  *
    34  * @since 1.2
    34  * @since 1.2
    35  * @author Kaiyang Liu (original)
    35  * @author Kaiyang Liu (original)
    36  * @author Robert Field (rewrite)
    36  * @author Robert Field (rewrite)
    37  * @author Scott Seligman (generics)
    37  * @author Scott Seligman (generics)
    40 
    40 
    41     /**
    41     /**
    42      * Return unqualified name of type excluding any dimension information.
    42      * Return unqualified name of type excluding any dimension information.
    43      * <p>
    43      * <p>
    44      * For example, a two dimensional array of String returns
    44      * For example, a two dimensional array of String returns
    45      * "<code>String</code>".
    45      * "{@code String}".
       
    46      * @return unqualified name of type excluding any dimension information.
    46      */
    47      */
    47     String typeName();
    48     String typeName();
    48 
    49 
    49     /**
    50     /**
    50      * Return qualified name of type excluding any dimension information.
    51      * Return qualified name of type excluding any dimension information.
    51      *<p>
    52      *<p>
    52      * For example, a two dimensional array of String
    53      * For example, a two dimensional array of String
    53      * returns "<code>java.lang.String</code>".
    54      * returns "{@code java.lang.String}".
       
    55      * @return qualified name of this type excluding any dimension information.
    54      */
    56      */
    55     String qualifiedTypeName();
    57     String qualifiedTypeName();
    56 
    58 
    57     /**
    59     /**
    58      * Return the simple name of this type excluding any dimension information.
    60      * Return the simple name of this type excluding any dimension information.
    59      * This is the unqualified name of the type, except that for nested types
    61      * This is the unqualified name of the type, except that for nested types
    60      * only the identifier of the innermost type is included.
    62      * only the identifier of the innermost type is included.
    61      * <p>
    63      * <p>
    62      * For example, the class {@code Outer.Inner} returns
    64      * For example, the class {@code Outer.Inner} returns
    63      * "<code>Inner</code>".
    65      * "{@code Inner}".
    64      *
    66      *
    65      * @since 1.5
    67      * @since 1.5
       
    68      * @return the simple name of this type excluding any dimension information.
    66      */
    69      */
    67     String simpleTypeName();
    70     String simpleTypeName();
    68 
    71 
    69     /**
    72     /**
    70      * Return the type's dimension information, as a string.
    73      * Return the type's dimension information, as a string.
    71      * <p>
    74      * <p>
    72      * For example, a two dimensional array of String returns
    75      * For example, a two dimensional array of String returns
    73      * "<code>[][]</code>".
    76      * "{@code [][]}".
       
    77      * @return the type's dimension information as a string.
    74      */
    78      */
    75     String dimension();
    79     String dimension();
    76 
    80 
    77     /**
    81     /**
    78      * Return a string representation of the type.
    82      * Return a string representation of the type.
    79      * This includes any dimension information and type arguments.
    83      * This includes any dimension information and type arguments.
    80      * <p>
    84      * <p>
    81      * For example, a two dimensional array of String may return
    85      * For example, a two dimensional array of String may return
    82      * "<code>java.lang.String[][]</code>",
    86      * "{@code java.lang.String[][]}",
    83      * and the parameterized type {@code List<Integer>} may return
    87      * and the parameterized type {@code List<Integer>} may return
    84      * "{@code java.util.List<java.lang.Integer>}".
    88      * "{@code java.util.List<java.lang.Integer>}".
    85      *
    89      *
    86      * @return a string representation of the type.
    90      * @return a string representation of the type.
    87      */
    91      */
    94      * @since 1.5
    98      * @since 1.5
    95      */
    99      */
    96     boolean isPrimitive();
   100     boolean isPrimitive();
    97 
   101 
    98     /**
   102     /**
    99      * Return this type as a <code>ClassDoc</code> if it represents a class
   103      * Return this type as a {@code ClassDoc} if it represents a class
   100      * or interface.  Array dimensions are ignored.
   104      * or interface.  Array dimensions are ignored.
   101      * If this type is a <code>ParameterizedType</code>,
   105      * If this type is a {@code ParameterizedType},
   102      * <code>TypeVariable</code>, or <code>WildcardType</code>, return
   106      * {@code TypeVariable}, or {@code WildcardType}, return
   103      * the <code>ClassDoc</code> of the type's erasure.  If this is an
   107      * the {@code ClassDoc} of the type's erasure.  If this is an
   104      * <code>AnnotationTypeDoc</code>, return this as a <code>ClassDoc</code>
   108      * {@code AnnotationTypeDoc}, return this as a {@code ClassDoc}
   105      * (but see {@link #asAnnotationTypeDoc()}).
   109      * (but see {@link #asAnnotationTypeDoc()}).
   106      * If this is a primitive type, return null.
   110      * If this is a primitive type, return null.
   107      *
   111      *
   108      * @return the <code>ClassDoc</code> of this type,
   112      * @return the {@code ClassDoc} of this type,
   109      *         or null if it is a primitive type.
   113      *         or null if it is a primitive type.
   110      */
   114      */
   111     ClassDoc asClassDoc();
   115     ClassDoc asClassDoc();
   112 
   116 
   113     /**
   117     /**
   114      * Return this type as a <code>ParameterizedType</code> if it represents
   118      * Return this type as a {@code ParameterizedType} if it represents
   115      * an invocation of a generic class or interface.  Array dimensions
   119      * an invocation of a generic class or interface.  Array dimensions
   116      * are ignored.
   120      * are ignored.
   117      *
   121      *
   118      * @return a <code>ParameterizedType</code> if the type is an
   122      * @return a {@code ParameterizedType} if the type is an
   119      *         invocation of a generic type, or null if it is not.
   123      *         invocation of a generic type, or null if it is not.
   120      * @since 1.5
   124      * @since 1.5
   121      */
   125      */
   122     ParameterizedType asParameterizedType();
   126     ParameterizedType asParameterizedType();
   123 
   127 
   124     /**
   128     /**
   125      * Return this type as a <code>TypeVariable</code> if it represents
   129      * Return this type as a {@code TypeVariable} if it represents
   126      * a type variable.  Array dimensions are ignored.
   130      * a type variable.  Array dimensions are ignored.
   127      *
   131      *
   128      * @return a <code>TypeVariable</code> if the type is a type variable,
   132      * @return a {@code TypeVariable} if the type is a type variable,
   129      *         or null if it is not.
   133      *         or null if it is not.
   130      * @since 1.5
   134      * @since 1.5
   131      */
   135      */
   132     TypeVariable asTypeVariable();
   136     TypeVariable asTypeVariable();
   133 
   137 
   134     /**
   138     /**
   135      * Return this type as a <code>WildcardType</code> if it represents
   139      * Return this type as a {@code WildcardType} if it represents
   136      * a wildcard type.
   140      * a wildcard type.
   137      *
   141      *
   138      * @return a <code>WildcardType</code> if the type is a wildcard type,
   142      * @return a {@code WildcardType} if the type is a wildcard type,
   139      *         or null if it is not.
   143      *         or null if it is not.
   140      * @since 1.5
   144      * @since 1.5
   141      */
   145      */
   142     WildcardType asWildcardType();
   146     WildcardType asWildcardType();
   143 
   147 
   144     /**
   148     /**
   145      * Returns this type as a <code>AnnotatedType</code> if it represents
   149      * Returns this type as a {@code AnnotatedType} if it represents
   146      * an annotated type.
   150      * an annotated type.
   147      *
   151      *
   148      * @return a <code>AnnotatedType</code> if the type if an annotated type,
   152      * @return a {@code AnnotatedType} if the type if an annotated type,
   149      *         or null if it is not
   153      *         or null if it is not
   150      * @since 1.8
   154      * @since 1.8
   151      */
   155      */
   152     AnnotatedType asAnnotatedType();
   156     AnnotatedType asAnnotatedType();
   153 
   157 
   154     /**
   158     /**
   155      * Return this type as an <code>AnnotationTypeDoc</code> if it represents
   159      * Return this type as an {@code AnnotationTypeDoc} if it represents
   156      * an annotation type.  Array dimensions are ignored.
   160      * an annotation type.  Array dimensions are ignored.
   157      *
   161      *
   158      * @return an <code>AnnotationTypeDoc</code> if the type is an annotation
   162      * @return an {@code AnnotationTypeDoc} if the type is an annotation
   159      *         type, or null if it is not.
   163      *         type, or null if it is not.
   160      * @since 1.5
   164      * @since 1.5
   161      */
   165      */
   162     AnnotationTypeDoc asAnnotationTypeDoc();
   166     AnnotationTypeDoc asAnnotationTypeDoc();
   163 
   167 
   164     /**
   168     /**
   165      * If this type is an array type, return the element type of the
   169      * If this type is an array type, return the element type of the
   166      * array. Otherwise, return null.
   170      * array. Otherwise, return null.
   167      *
   171      *
   168      * @return a <code>Type</code> representing the element type or null.
   172      * @return a {@code Type} representing the element type or null.
   169      * @since 1.8
   173      * @since 1.8
   170      */
   174      */
   171     Type getElementType();
   175     Type getElementType();
   172 }
   176 }