aoqi@0: /*
aoqi@0: * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0: *
aoqi@0: * This code is free software; you can redistribute it and/or modify it
aoqi@0: * under the terms of the GNU General Public License version 2 only, as
aoqi@0: * published by the Free Software Foundation. Oracle designates this
aoqi@0: * particular file as subject to the "Classpath" exception as provided
aoqi@0: * by Oracle in the LICENSE file that accompanied this code.
aoqi@0: *
aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0: * accompanied this code).
aoqi@0: *
aoqi@0: * You should have received a copy of the GNU General Public License version
aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0: *
aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0: * or visit www.oracle.com if you need additional information or have any
aoqi@0: * questions.
aoqi@0: */
aoqi@0:
aoqi@0: package com.sun.tools.javadoc;
aoqi@0:
aoqi@0: import com.sun.javadoc.*;
aoqi@0:
aoqi@0: import com.sun.tools.javac.code.Symbol.ClassSymbol;
aoqi@0: import com.sun.tools.javac.code.Type;
aoqi@0: import com.sun.tools.javac.util.List;
aoqi@0:
aoqi@0:
aoqi@0: /**
aoqi@0: * Implementation of WildcardType
, which
aoqi@0: * represents a wildcard type.
aoqi@0: *
aoqi@0: *
This is NOT part of any supported API.
aoqi@0: * If you write code that depends on this, you do so at your own risk.
aoqi@0: * This code and its internal interfaces are subject to change or
aoqi@0: * deletion without notice.
aoqi@0: *
aoqi@0: * @author Scott Seligman
aoqi@0: * @since 1.5
aoqi@0: */
aoqi@0: public class WildcardTypeImpl extends AbstractTypeImpl implements WildcardType {
aoqi@0:
aoqi@0: WildcardTypeImpl(DocEnv env, Type.WildcardType type) {
aoqi@0: super(env, type);
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Return the upper bounds of this wildcard type argument
aoqi@0: * as given by the extends clause.
aoqi@0: * Return an empty array if no such bounds are explicitly given.
aoqi@0: */
aoqi@0: public com.sun.javadoc.Type[] extendsBounds() {
aoqi@0: return TypeMaker.getTypes(env, getExtendsBounds((Type.WildcardType)type));
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Return the lower bounds of this wildcard type argument
aoqi@0: * as given by the super clause.
aoqi@0: * Return an empty array if no such bounds are explicitly given.
aoqi@0: */
aoqi@0: public com.sun.javadoc.Type[] superBounds() {
aoqi@0: return TypeMaker.getTypes(env, getSuperBounds((Type.WildcardType)type));
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Return the ClassDoc of the erasure of this wildcard type.
aoqi@0: */
aoqi@0: @Override
aoqi@0: public ClassDoc asClassDoc() {
aoqi@0: return env.getClassDoc((ClassSymbol)env.types.erasure(type).tsym);
aoqi@0: }
aoqi@0:
aoqi@0: @Override
aoqi@0: public WildcardType asWildcardType() {
aoqi@0: return this;
aoqi@0: }
aoqi@0:
aoqi@0: @Override
aoqi@0: public String typeName() { return "?"; }
aoqi@0: @Override
aoqi@0: public String qualifiedTypeName() { return "?"; }
aoqi@0: @Override
aoqi@0: public String simpleTypeName() { return "?"; }
aoqi@0:
aoqi@0: @Override
aoqi@0: public String toString() {
aoqi@0: return wildcardTypeToString(env, (Type.WildcardType)type, true);
aoqi@0: }
aoqi@0:
aoqi@0:
aoqi@0: /**
aoqi@0: * Return the string form of a wildcard type ("?") along with any
aoqi@0: * "extends" or "super" clause. Delimiting brackets are not
aoqi@0: * included. Class names are qualified if "full" is true.
aoqi@0: */
aoqi@0: static String wildcardTypeToString(DocEnv env,
aoqi@0: Type.WildcardType wildThing, boolean full) {
aoqi@0: if (env.legacyDoclet) {
aoqi@0: return TypeMaker.getTypeName(env.types.erasure(wildThing), full);
aoqi@0: }
aoqi@0: StringBuilder s = new StringBuilder("?");
aoqi@0: List