jjg@1521: /* jjg@1521: * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. jjg@1521: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@1521: * jjg@1521: * This code is free software; you can redistribute it and/or modify it jjg@1521: * under the terms of the GNU General Public License version 2 only, as jjg@1521: * published by the Free Software Foundation. Oracle designates this jjg@1521: * particular file as subject to the "Classpath" exception as provided jjg@1521: * by Oracle in the LICENSE file that accompanied this code. jjg@1521: * jjg@1521: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@1521: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@1521: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@1521: * version 2 for more details (a copy is included in the LICENSE file that jjg@1521: * accompanied this code). jjg@1521: * jjg@1521: * You should have received a copy of the GNU General Public License version jjg@1521: * 2 along with this work; if not, write to the Free Software Foundation, jjg@1521: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@1521: * jjg@1521: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jjg@1521: * or visit www.oracle.com if you need additional information or have any jjg@1521: * questions. jjg@1521: */ jjg@1521: jjg@1521: package com.sun.tools.javadoc; jjg@1521: jjg@1521: import com.sun.javadoc.*; jjg@1521: import com.sun.tools.javac.code.Attribute; jjg@1521: import com.sun.tools.javac.code.Attribute.TypeCompound; jjg@1521: import com.sun.tools.javac.util.List; jjg@1521: jjg@1521: /** jjg@1521: * Implementation of AnnotatedType, which jjg@1521: * represents an annotated type. jjg@1521: * jjg@1521: * @author Mahmood Ali jjg@1521: * @since 1.8 jjg@1521: */ jjg@1521: public class AnnotatedTypeImpl jjg@1521: extends AbstractTypeImpl implements AnnotatedType { jjg@1521: jjg@1992: AnnotatedTypeImpl(DocEnv env, com.sun.tools.javac.code.Type type) { jjg@1521: super(env, type); jjg@1521: } jjg@1521: jjg@1521: /** jjg@1521: * Get the annotations of this program element. jjg@1521: * Return an empty array if there are none. jjg@1521: */ jjg@1521: @Override jjg@1521: public AnnotationDesc[] annotations() { jjg@1992: List tas = type.getAnnotationMirrors(); jjg@1521: if (tas == null || jjg@1521: tas.isEmpty()) { jjg@1521: return new AnnotationDesc[0]; jjg@1521: } jjg@1521: AnnotationDesc res[] = new AnnotationDesc[tas.length()]; jjg@1521: int i = 0; jjg@1521: for (Attribute.Compound a : tas) { jjg@1521: res[i++] = new AnnotationDescImpl(env, a); jjg@1521: } jjg@1521: return res; jjg@1521: } jjg@1521: jjg@1521: @Override jjg@1521: public com.sun.javadoc.Type underlyingType() { jjg@1992: return TypeMaker.getType(env, type.unannotatedType(), true, false); jjg@1521: } jjg@1521: jjg@1521: @Override jjg@1521: public AnnotatedType asAnnotatedType() { jjg@1521: return this; jjg@1521: } jjg@1521: jjg@1521: @Override jjg@1521: public String toString() { jjg@1521: return typeName(); jjg@1521: } jjg@1521: jjg@1521: @Override jjg@1521: public String typeName() { jjg@1521: return this.underlyingType().typeName(); jjg@1521: } jjg@1521: jjg@1521: @Override jjg@1521: public String qualifiedTypeName() { jjg@1521: return this.underlyingType().qualifiedTypeName(); jjg@1521: } jjg@1521: jjg@1521: @Override jjg@1521: public String simpleTypeName() { jjg@1521: return this.underlyingType().simpleTypeName(); jjg@1521: } jjg@1521: jjg@1521: @Override jjg@1521: public String dimension() { jjg@1521: return this.underlyingType().dimension(); jjg@1521: } jjg@1521: jjg@1521: @Override jjg@1521: public boolean isPrimitive() { jjg@1521: return this.underlyingType().isPrimitive(); jjg@1521: } jjg@1521: jjg@1521: @Override jjg@1521: public ClassDoc asClassDoc() { jjg@1521: return this.underlyingType().asClassDoc(); jjg@1521: } jjg@1521: jjg@1521: @Override jjg@1521: public TypeVariable asTypeVariable() { jjg@1521: return this.underlyingType().asTypeVariable(); jjg@1521: } jjg@1521: jjg@1521: @Override jjg@1521: public WildcardType asWildcardType() { jjg@1521: return this.underlyingType().asWildcardType(); jjg@1521: } jjg@1521: jjg@1521: @Override jjg@1521: public ParameterizedType asParameterizedType() { jjg@1521: return this.underlyingType().asParameterizedType(); jjg@1521: } jjg@1521: }