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

changeset 0
959103a6100f
child 2525
2eb010b6cb22
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javadoc/AnnotatedTypeImpl.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,125 @@
     1.4 +/*
     1.5 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package com.sun.tools.javadoc;
    1.30 +
    1.31 +import com.sun.javadoc.*;
    1.32 +import com.sun.tools.javac.code.Attribute;
    1.33 +import com.sun.tools.javac.code.Attribute.TypeCompound;
    1.34 +import com.sun.tools.javac.util.List;
    1.35 +
    1.36 +/**
    1.37 + * Implementation of <code>AnnotatedType</code>, which
    1.38 + * represents an annotated type.
    1.39 + *
    1.40 + * @author Mahmood Ali
    1.41 + * @since 1.8
    1.42 + */
    1.43 +public class AnnotatedTypeImpl
    1.44 +        extends AbstractTypeImpl implements AnnotatedType {
    1.45 +
    1.46 +    AnnotatedTypeImpl(DocEnv env, com.sun.tools.javac.code.Type type) {
    1.47 +        super(env, type);
    1.48 +    }
    1.49 +
    1.50 +    /**
    1.51 +     * Get the annotations of this program element.
    1.52 +     * Return an empty array if there are none.
    1.53 +     */
    1.54 +    @Override
    1.55 +    public AnnotationDesc[] annotations() {
    1.56 +        List<? extends TypeCompound> tas = type.getAnnotationMirrors();
    1.57 +        if (tas == null ||
    1.58 +                tas.isEmpty()) {
    1.59 +            return new AnnotationDesc[0];
    1.60 +        }
    1.61 +        AnnotationDesc res[] = new AnnotationDesc[tas.length()];
    1.62 +        int i = 0;
    1.63 +        for (Attribute.Compound a : tas) {
    1.64 +            res[i++] = new AnnotationDescImpl(env, a);
    1.65 +        }
    1.66 +        return res;
    1.67 +    }
    1.68 +
    1.69 +    @Override
    1.70 +    public com.sun.javadoc.Type underlyingType() {
    1.71 +        return TypeMaker.getType(env, type.unannotatedType(), true, false);
    1.72 +    }
    1.73 +
    1.74 +    @Override
    1.75 +    public AnnotatedType asAnnotatedType() {
    1.76 +        return this;
    1.77 +    }
    1.78 +
    1.79 +    @Override
    1.80 +    public String toString() {
    1.81 +        return typeName();
    1.82 +    }
    1.83 +
    1.84 +    @Override
    1.85 +    public String typeName() {
    1.86 +        return this.underlyingType().typeName();
    1.87 +    }
    1.88 +
    1.89 +    @Override
    1.90 +    public String qualifiedTypeName() {
    1.91 +        return this.underlyingType().qualifiedTypeName();
    1.92 +    }
    1.93 +
    1.94 +    @Override
    1.95 +    public String simpleTypeName() {
    1.96 +        return this.underlyingType().simpleTypeName();
    1.97 +    }
    1.98 +
    1.99 +    @Override
   1.100 +    public String dimension() {
   1.101 +        return this.underlyingType().dimension();
   1.102 +    }
   1.103 +
   1.104 +    @Override
   1.105 +    public boolean isPrimitive() {
   1.106 +        return this.underlyingType().isPrimitive();
   1.107 +    }
   1.108 +
   1.109 +    @Override
   1.110 +    public ClassDoc asClassDoc() {
   1.111 +        return this.underlyingType().asClassDoc();
   1.112 +    }
   1.113 +
   1.114 +    @Override
   1.115 +    public TypeVariable asTypeVariable() {
   1.116 +        return this.underlyingType().asTypeVariable();
   1.117 +    }
   1.118 +
   1.119 +    @Override
   1.120 +    public WildcardType asWildcardType() {
   1.121 +        return this.underlyingType().asWildcardType();
   1.122 +    }
   1.123 +
   1.124 +    @Override
   1.125 +    public ParameterizedType asParameterizedType() {
   1.126 +        return this.underlyingType().asParameterizedType();
   1.127 +    }
   1.128 +}

mercurial