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

Fri, 05 Aug 2011 19:41:05 -0700

author
ksrini
date
Fri, 05 Aug 2011 19:41:05 -0700
changeset 1065
e9f118c2bd3c
parent 554
9d9f26857129
child 1357
c75be5bc5283
permissions
-rw-r--r--

7064544: (javadoc) miscellaneous fixes requested by netbeans
Summary: Contributed by netbeans team, modified to suit by the langtools team.
Reviewed-by: jjg, bpatel

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

mercurial