src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/PrimitiveType.java
branchniosocketimpl-branch
changeset 57208 7a45c67e73d0
parent 57207 30695f27d7ea
parent 53902 7a6fd71449e7
child 57210 a67ea4f53e56
equal deleted inserted replaced
57207:30695f27d7ea 57208:7a45c67e73d0
     1 /*
       
     2  * Copyright (c) 2001, 2018, 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  */
       
    25 
       
    26 package com.sun.tools.javadoc.main;
       
    27 
       
    28 import com.sun.javadoc.*;
       
    29 
       
    30 /**
       
    31  *  <p><b>This is NOT part of any supported API.
       
    32  *  If you write code that depends on this, you do so at your own risk.
       
    33  *  This code and its internal interfaces are subject to change or
       
    34  *  deletion without notice.</b>
       
    35  */
       
    36 @Deprecated(since="9", forRemoval=true)
       
    37 @SuppressWarnings("removal")
       
    38 class PrimitiveType implements com.sun.javadoc.Type {
       
    39 
       
    40     private final String name;
       
    41 
       
    42     static final PrimitiveType voidType = new PrimitiveType("void");
       
    43     static final PrimitiveType booleanType = new PrimitiveType("boolean");
       
    44     static final PrimitiveType byteType = new PrimitiveType("byte");
       
    45     static final PrimitiveType charType = new PrimitiveType("char");
       
    46     static final PrimitiveType shortType = new PrimitiveType("short");
       
    47     static final PrimitiveType intType = new PrimitiveType("int");
       
    48     static final PrimitiveType longType = new PrimitiveType("long");
       
    49     static final PrimitiveType floatType = new PrimitiveType("float");
       
    50     static final PrimitiveType doubleType = new PrimitiveType("double");
       
    51 
       
    52     // error type, should never actually be used
       
    53     static final PrimitiveType errorType = new PrimitiveType("");
       
    54 
       
    55     PrimitiveType(String name) {
       
    56         this.name = name;
       
    57     }
       
    58 
       
    59     /**
       
    60      * Return unqualified name of type excluding any dimension information.
       
    61      * <p>
       
    62      * For example, a two dimensional array of String returns 'String'.
       
    63      */
       
    64     public String typeName() {
       
    65         return name;
       
    66     }
       
    67 
       
    68     public com.sun.javadoc.Type getElementType() {
       
    69         return null;
       
    70     }
       
    71 
       
    72     /**
       
    73      * Return qualified name of type excluding any dimension information.
       
    74      *<p>
       
    75      * For example, a two dimensional array of String
       
    76      * returns 'java.lang.String'.
       
    77      */
       
    78     public String qualifiedTypeName() {
       
    79         return name;
       
    80     }
       
    81 
       
    82     /**
       
    83      * Return the simple name of this type.
       
    84      */
       
    85     public String simpleTypeName() {
       
    86         return name;
       
    87     }
       
    88 
       
    89     /**
       
    90      * Return the type's dimension information, as a string.
       
    91      * <p>
       
    92      * For example, a two dimensional array of String returns '[][]'.
       
    93      */
       
    94     public String dimension() {
       
    95         return "";
       
    96     }
       
    97 
       
    98     /**
       
    99      * Return this type as a class.  Array dimensions are ignored.
       
   100      *
       
   101      * @return a ClassDocImpl if the type is a Class.
       
   102      * Return null if it is a primitive type..
       
   103      */
       
   104     public ClassDoc asClassDoc() {
       
   105         return null;
       
   106     }
       
   107 
       
   108     /**
       
   109      * Return null, as this is not an annotation type.
       
   110      */
       
   111     public AnnotationTypeDoc asAnnotationTypeDoc() {
       
   112         return null;
       
   113     }
       
   114 
       
   115     /**
       
   116      * Return null, as this is not an instantiation.
       
   117      */
       
   118     public ParameterizedType asParameterizedType() {
       
   119         return null;
       
   120     }
       
   121 
       
   122     /**
       
   123      * Return null, as this is not a type variable.
       
   124      */
       
   125     public TypeVariable asTypeVariable() {
       
   126         return null;
       
   127     }
       
   128 
       
   129     /**
       
   130      * Return null, as this is not a wildcard type.
       
   131      */
       
   132     public WildcardType asWildcardType() {
       
   133         return null;
       
   134     }
       
   135 
       
   136     /**
       
   137      * Return null, as this is not an annotated type.
       
   138      */
       
   139     public AnnotatedType asAnnotatedType() {
       
   140         return null;
       
   141     }
       
   142 
       
   143     /**
       
   144      * Returns a string representation of the type.
       
   145      *
       
   146      * Return name of type including any dimension information.
       
   147      * <p>
       
   148      * For example, a two dimensional array of String returns
       
   149      * <code>String[][]</code>.
       
   150      *
       
   151      * @return name of type including any dimension information.
       
   152      */
       
   153     public String toString() {
       
   154         return qualifiedTypeName();
       
   155     }
       
   156 
       
   157     /**
       
   158      * Return true if this is a primitive type.
       
   159      */
       
   160     public boolean isPrimitive() {
       
   161         return true;
       
   162     }
       
   163 }