src/share/classes/com/sun/tools/javadoc/PrimitiveType.java

Wed, 23 Jan 2013 13:27:24 -0800

author
jjg
date
Wed, 23 Jan 2013 13:27:24 -0800
changeset 1521
71f35e4b93a5
parent 1359
25e14ad23cef
child 1691
f10cffab99b4
permissions
-rw-r--r--

8006775: JSR 308: Compiler changes in JDK8
Reviewed-by: jjg
Contributed-by: mernst@cs.washington.edu, wmdietl@cs.washington.edu, mpapi@csail.mit.edu, mahmood@notnoop.com

duke@1 1 /*
jjg@1521 2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
duke@1 24 */
duke@1 25
duke@1 26 package com.sun.tools.javadoc;
duke@1 27
duke@1 28 import com.sun.javadoc.*;
duke@1 29
jjg@1359 30 /**
jjg@1359 31 * <p><b>This is NOT part of any supported API.
jjg@1359 32 * If you write code that depends on this, you do so at your own risk.
jjg@1359 33 * This code and its internal interfaces are subject to change or
jjg@1359 34 * deletion without notice.</b>
jjg@1359 35 */
duke@1 36 class PrimitiveType implements com.sun.javadoc.Type {
duke@1 37
duke@1 38 private final String name;
duke@1 39
duke@1 40 static final PrimitiveType voidType = new PrimitiveType("void");
duke@1 41 static final PrimitiveType booleanType = new PrimitiveType("boolean");
duke@1 42 static final PrimitiveType byteType = new PrimitiveType("byte");
duke@1 43 static final PrimitiveType charType = new PrimitiveType("char");
duke@1 44 static final PrimitiveType shortType = new PrimitiveType("short");
duke@1 45 static final PrimitiveType intType = new PrimitiveType("int");
duke@1 46 static final PrimitiveType longType = new PrimitiveType("long");
duke@1 47 static final PrimitiveType floatType = new PrimitiveType("float");
duke@1 48 static final PrimitiveType doubleType = new PrimitiveType("double");
duke@1 49
duke@1 50 // error type, should never actually be used
duke@1 51 static final PrimitiveType errorType = new PrimitiveType("");
duke@1 52
duke@1 53 PrimitiveType(String name) {
duke@1 54 this.name = name;
duke@1 55 }
duke@1 56
duke@1 57 /**
duke@1 58 * Return unqualified name of type excluding any dimension information.
duke@1 59 * <p>
duke@1 60 * For example, a two dimensional array of String returns 'String'.
duke@1 61 */
duke@1 62 public String typeName() {
duke@1 63 return name;
duke@1 64 }
duke@1 65
duke@1 66 /**
duke@1 67 * Return qualified name of type excluding any dimension information.
duke@1 68 *<p>
duke@1 69 * For example, a two dimensional array of String
duke@1 70 * returns 'java.lang.String'.
duke@1 71 */
duke@1 72 public String qualifiedTypeName() {
duke@1 73 return name;
duke@1 74 }
duke@1 75
duke@1 76 /**
duke@1 77 * Return the simple name of this type.
duke@1 78 */
duke@1 79 public String simpleTypeName() {
duke@1 80 return name;
duke@1 81 }
duke@1 82
duke@1 83 /**
duke@1 84 * Return the type's dimension information, as a string.
duke@1 85 * <p>
duke@1 86 * For example, a two dimensional array of String returns '[][]'.
duke@1 87 */
duke@1 88 public String dimension() {
duke@1 89 return "";
duke@1 90 }
duke@1 91
duke@1 92 /**
duke@1 93 * Return this type as a class. Array dimensions are ignored.
duke@1 94 *
duke@1 95 * @return a ClassDocImpl if the type is a Class.
duke@1 96 * Return null if it is a primitive type..
duke@1 97 */
duke@1 98 public ClassDoc asClassDoc() {
duke@1 99 return null;
duke@1 100 }
duke@1 101
duke@1 102 /**
duke@1 103 * Return null, as this is not an annotation type.
duke@1 104 */
duke@1 105 public AnnotationTypeDoc asAnnotationTypeDoc() {
duke@1 106 return null;
duke@1 107 }
duke@1 108
duke@1 109 /**
duke@1 110 * Return null, as this is not an instantiation.
duke@1 111 */
duke@1 112 public ParameterizedType asParameterizedType() {
duke@1 113 return null;
duke@1 114 }
duke@1 115
duke@1 116 /**
duke@1 117 * Return null, as this is not a type variable.
duke@1 118 */
duke@1 119 public TypeVariable asTypeVariable() {
duke@1 120 return null;
duke@1 121 }
duke@1 122
duke@1 123 /**
jjg@1521 124 * Return null, as this is not a wildcard type.
duke@1 125 */
duke@1 126 public WildcardType asWildcardType() {
duke@1 127 return null;
duke@1 128 }
duke@1 129
duke@1 130 /**
jjg@1521 131 * Return null, as this is not an annotated type.
jjg@1521 132 */
jjg@1521 133 public AnnotatedType asAnnotatedType() {
jjg@1521 134 return null;
jjg@1521 135 }
jjg@1521 136
jjg@1521 137 /**
duke@1 138 * Returns a string representation of the type.
duke@1 139 *
duke@1 140 * Return name of type including any dimension information.
duke@1 141 * <p>
duke@1 142 * For example, a two dimensional array of String returns
duke@1 143 * <code>String[][]</code>.
duke@1 144 *
duke@1 145 * @return name of type including any dimension information.
duke@1 146 */
duke@1 147 public String toString() {
duke@1 148 return qualifiedTypeName();
duke@1 149 }
duke@1 150
duke@1 151 /**
duke@1 152 * Return true if this is a primitive type.
duke@1 153 */
duke@1 154 public boolean isPrimitive() {
duke@1 155 return true;
duke@1 156 }
duke@1 157 }

mercurial