duke@1: /* jjg@1521: * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as ohair@554: * published by the Free Software Foundation. Oracle designates this duke@1: * particular file as subject to the "Classpath" exception as provided ohair@554: * by Oracle in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. duke@1: */ duke@1: duke@1: package com.sun.javadoc; duke@1: duke@1: /** duke@1: * Represents a type. A type can be a class or interface, an duke@1: * invocation (like {@code List}) of a generic class or interface, duke@1: * a type variable, a wildcard type ("?"), duke@1: * or a primitive data type (like char). duke@1: * duke@1: * @since 1.2 duke@1: * @author Kaiyang Liu (original) duke@1: * @author Robert Field (rewrite) duke@1: * @author Scott Seligman (generics) duke@1: */ duke@1: public interface Type { duke@1: duke@1: /** duke@1: * Return unqualified name of type excluding any dimension information. duke@1: *

duke@1: * For example, a two dimensional array of String returns duke@1: * "String". duke@1: */ duke@1: String typeName(); duke@1: duke@1: /** duke@1: * Return qualified name of type excluding any dimension information. duke@1: *

duke@1: * For example, a two dimensional array of String duke@1: * returns "java.lang.String". duke@1: */ duke@1: String qualifiedTypeName(); duke@1: duke@1: /** duke@1: * Return the simple name of this type excluding any dimension information. duke@1: * This is the unqualified name of the type, except that for nested types duke@1: * only the identifier of the innermost type is included. duke@1: *

duke@1: * For example, the class {@code Outer.Inner} returns duke@1: * "Inner". duke@1: * duke@1: * @since 1.5 duke@1: */ duke@1: String simpleTypeName(); duke@1: duke@1: /** duke@1: * Return the type's dimension information, as a string. duke@1: *

duke@1: * For example, a two dimensional array of String returns duke@1: * "[][]". duke@1: */ duke@1: String dimension(); duke@1: duke@1: /** duke@1: * Return a string representation of the type. duke@1: * This includes any dimension information and type arguments. duke@1: *

duke@1: * For example, a two dimensional array of String may return duke@1: * "java.lang.String[][]", duke@1: * and the parameterized type {@code List} may return duke@1: * "{@code java.util.List}". duke@1: * duke@1: * @return a string representation of the type. duke@1: */ duke@1: String toString(); duke@1: duke@1: /** duke@1: * Return true if this type represents a primitive type. duke@1: * duke@1: * @return true if this type represents a primitive type. duke@1: * @since 1.5 duke@1: */ duke@1: boolean isPrimitive(); duke@1: duke@1: /** duke@1: * Return this type as a ClassDoc if it represents a class duke@1: * or interface. Array dimensions are ignored. duke@1: * If this type is a ParameterizedType, duke@1: * TypeVariable, or WildcardType, return duke@1: * the ClassDoc of the type's erasure. If this is an duke@1: * AnnotationTypeDoc, return this as a ClassDoc duke@1: * (but see {@link #asAnnotationTypeDoc()}). duke@1: * If this is a primitive type, return null. duke@1: * duke@1: * @return the ClassDoc of this type, duke@1: * or null if it is a primitive type. duke@1: */ duke@1: ClassDoc asClassDoc(); duke@1: duke@1: /** duke@1: * Return this type as a ParameterizedType if it represents duke@1: * an invocation of a generic class or interface. Array dimensions duke@1: * are ignored. duke@1: * duke@1: * @return a ParameterizedType if the type is an duke@1: * invocation of a generic type, or null if it is not. duke@1: * @since 1.5 duke@1: */ duke@1: ParameterizedType asParameterizedType(); duke@1: duke@1: /** duke@1: * Return this type as a TypeVariable if it represents duke@1: * a type variable. Array dimensions are ignored. duke@1: * duke@1: * @return a TypeVariable if the type is a type variable, duke@1: * or null if it is not. duke@1: * @since 1.5 duke@1: */ duke@1: TypeVariable asTypeVariable(); duke@1: duke@1: /** duke@1: * Return this type as a WildcardType if it represents duke@1: * a wildcard type. duke@1: * duke@1: * @return a WildcardType if the type is a wildcard type, duke@1: * or null if it is not. duke@1: * @since 1.5 duke@1: */ duke@1: WildcardType asWildcardType(); duke@1: duke@1: /** jjg@1521: * Returns this type as a AnnotatedType if it represents jjg@1521: * an annotated type. jjg@1521: * jjg@1521: * @return a AnnotatedType if the type if an annotated type, jjg@1521: * or null if it is not jjg@1521: * @since 1.8 jjg@1521: */ jjg@1521: AnnotatedType asAnnotatedType(); jjg@1521: jjg@1521: /** duke@1: * Return this type as an AnnotationTypeDoc if it represents duke@1: * an annotation type. Array dimensions are ignored. duke@1: * duke@1: * @return an AnnotationTypeDoc if the type is an annotation duke@1: * type, or null if it is not. duke@1: * @since 1.5 duke@1: */ duke@1: AnnotationTypeDoc asAnnotationTypeDoc(); duke@1: }