langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/AnnotatedTypeImpl.java
changeset 37938 42baa89d2156
parent 37858 7c04fcb12bd4
child 37939 3eb8c2a89b77
equal deleted inserted replaced
37858:7c04fcb12bd4 37938:42baa89d2156
     1 /*
       
     2  * Copyright (c) 2003, 2013, 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;
       
    27 
       
    28 import com.sun.javadoc.*;
       
    29 import com.sun.tools.javac.code.Attribute;
       
    30 import com.sun.tools.javac.code.Attribute.TypeCompound;
       
    31 import com.sun.tools.javac.util.List;
       
    32 
       
    33 /**
       
    34  * Implementation of <code>AnnotatedType</code>, which
       
    35  * represents an annotated type.
       
    36  *
       
    37  * @author Mahmood Ali
       
    38  * @since 1.8
       
    39  */
       
    40 public class AnnotatedTypeImpl
       
    41         extends AbstractTypeImpl implements AnnotatedType {
       
    42 
       
    43     AnnotatedTypeImpl(DocEnv env, com.sun.tools.javac.code.Type type) {
       
    44         super(env, type);
       
    45     }
       
    46 
       
    47     /**
       
    48      * Get the annotations of this program element.
       
    49      * Return an empty array if there are none.
       
    50      */
       
    51     @Override
       
    52     public AnnotationDesc[] annotations() {
       
    53         List<? extends TypeCompound> tas = type.getAnnotationMirrors();
       
    54         if (tas == null ||
       
    55                 tas.isEmpty()) {
       
    56             return new AnnotationDesc[0];
       
    57         }
       
    58         AnnotationDesc res[] = new AnnotationDesc[tas.length()];
       
    59         int i = 0;
       
    60         for (Attribute.Compound a : tas) {
       
    61             res[i++] = new AnnotationDescImpl(env, a);
       
    62         }
       
    63         return res;
       
    64     }
       
    65 
       
    66     @Override
       
    67     public com.sun.javadoc.Type underlyingType() {
       
    68         return TypeMaker.getType(env, type, true, false);
       
    69     }
       
    70 
       
    71     @Override
       
    72     public AnnotatedType asAnnotatedType() {
       
    73         return this;
       
    74     }
       
    75 
       
    76     @Override
       
    77     public String toString() {
       
    78         return typeName();
       
    79     }
       
    80 
       
    81     @Override
       
    82     public String typeName() {
       
    83         return this.underlyingType().typeName();
       
    84     }
       
    85 
       
    86     @Override
       
    87     public String qualifiedTypeName() {
       
    88         return this.underlyingType().qualifiedTypeName();
       
    89     }
       
    90 
       
    91     @Override
       
    92     public String simpleTypeName() {
       
    93         return this.underlyingType().simpleTypeName();
       
    94     }
       
    95 
       
    96     @Override
       
    97     public String dimension() {
       
    98         return this.underlyingType().dimension();
       
    99     }
       
   100 
       
   101     @Override
       
   102     public boolean isPrimitive() {
       
   103         return this.underlyingType().isPrimitive();
       
   104     }
       
   105 
       
   106     @Override
       
   107     public ClassDoc asClassDoc() {
       
   108         return this.underlyingType().asClassDoc();
       
   109     }
       
   110 
       
   111     @Override
       
   112     public TypeVariable asTypeVariable() {
       
   113         return this.underlyingType().asTypeVariable();
       
   114     }
       
   115 
       
   116     @Override
       
   117     public WildcardType asWildcardType() {
       
   118         return this.underlyingType().asWildcardType();
       
   119     }
       
   120 
       
   121     @Override
       
   122     public ParameterizedType asParameterizedType() {
       
   123         return this.underlyingType().asParameterizedType();
       
   124     }
       
   125 }