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

Tue, 24 Dec 2013 09:17:37 -0800

author
ksrini
date
Tue, 24 Dec 2013 09:17:37 -0800
changeset 2227
998b10c43157
parent 1691
f10cffab99b4
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8029230: Update copyright year to match last edit in jdk8 langtools repository for 2013
Reviewed-by: ksrini
Contributed-by: steve.sides@oracle.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
bpatel@1691 66 public com.sun.javadoc.Type getElementType() {
bpatel@1691 67 return null;
bpatel@1691 68 }
bpatel@1691 69
duke@1 70 /**
duke@1 71 * Return qualified name of type excluding any dimension information.
duke@1 72 *<p>
duke@1 73 * For example, a two dimensional array of String
duke@1 74 * returns 'java.lang.String'.
duke@1 75 */
duke@1 76 public String qualifiedTypeName() {
duke@1 77 return name;
duke@1 78 }
duke@1 79
duke@1 80 /**
duke@1 81 * Return the simple name of this type.
duke@1 82 */
duke@1 83 public String simpleTypeName() {
duke@1 84 return name;
duke@1 85 }
duke@1 86
duke@1 87 /**
duke@1 88 * Return the type's dimension information, as a string.
duke@1 89 * <p>
duke@1 90 * For example, a two dimensional array of String returns '[][]'.
duke@1 91 */
duke@1 92 public String dimension() {
duke@1 93 return "";
duke@1 94 }
duke@1 95
duke@1 96 /**
duke@1 97 * Return this type as a class. Array dimensions are ignored.
duke@1 98 *
duke@1 99 * @return a ClassDocImpl if the type is a Class.
duke@1 100 * Return null if it is a primitive type..
duke@1 101 */
duke@1 102 public ClassDoc asClassDoc() {
duke@1 103 return null;
duke@1 104 }
duke@1 105
duke@1 106 /**
duke@1 107 * Return null, as this is not an annotation type.
duke@1 108 */
duke@1 109 public AnnotationTypeDoc asAnnotationTypeDoc() {
duke@1 110 return null;
duke@1 111 }
duke@1 112
duke@1 113 /**
duke@1 114 * Return null, as this is not an instantiation.
duke@1 115 */
duke@1 116 public ParameterizedType asParameterizedType() {
duke@1 117 return null;
duke@1 118 }
duke@1 119
duke@1 120 /**
duke@1 121 * Return null, as this is not a type variable.
duke@1 122 */
duke@1 123 public TypeVariable asTypeVariable() {
duke@1 124 return null;
duke@1 125 }
duke@1 126
duke@1 127 /**
jjg@1521 128 * Return null, as this is not a wildcard type.
duke@1 129 */
duke@1 130 public WildcardType asWildcardType() {
duke@1 131 return null;
duke@1 132 }
duke@1 133
duke@1 134 /**
jjg@1521 135 * Return null, as this is not an annotated type.
jjg@1521 136 */
jjg@1521 137 public AnnotatedType asAnnotatedType() {
jjg@1521 138 return null;
jjg@1521 139 }
jjg@1521 140
jjg@1521 141 /**
duke@1 142 * Returns a string representation of the type.
duke@1 143 *
duke@1 144 * Return name of type including any dimension information.
duke@1 145 * <p>
duke@1 146 * For example, a two dimensional array of String returns
duke@1 147 * <code>String[][]</code>.
duke@1 148 *
duke@1 149 * @return name of type including any dimension information.
duke@1 150 */
duke@1 151 public String toString() {
duke@1 152 return qualifiedTypeName();
duke@1 153 }
duke@1 154
duke@1 155 /**
duke@1 156 * Return true if this is a primitive type.
duke@1 157 */
duke@1 158 public boolean isPrimitive() {
duke@1 159 return true;
duke@1 160 }
duke@1 161 }

mercurial