Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/src/share/classes/com/sun/tools/javadoc/ParameterImpl.java
38899 views
/*1* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.tools.javadoc;2627import com.sun.javadoc.*;2829import com.sun.tools.javac.code.Attribute;30import com.sun.tools.javac.code.Symbol.VarSymbol;3132/**33* ParameterImpl information.34* This includes a parameter type and parameter name.35*36* <p><b>This is NOT part of any supported API.37* If you write code that depends on this, you do so at your own risk.38* This code and its internal interfaces are subject to change or39* deletion without notice.</b>40*41* @author Kaiyang Liu (original)42* @author Robert Field (rewrite)43* @author Scott Seligman (generics, annotations)44*/45class ParameterImpl implements Parameter {4647private final DocEnv env;48private final VarSymbol sym;49private final com.sun.javadoc.Type type;5051/**52* Constructor of parameter info class.53*/54ParameterImpl(DocEnv env, VarSymbol sym) {55this.env = env;56this.sym = sym;57this.type = TypeMaker.getType(env, sym.type, false);58}5960/**61* Get the type of this parameter.62*/63public com.sun.javadoc.Type type() {64return type;65}6667/**68* Get local name of this parameter.69* For example if parameter is the short 'index', returns "index".70*/71public String name() {72return sym.toString();73}7475/**76* Get type name of this parameter.77* For example if parameter is the short 'index', returns "short".78*/79public String typeName() {80return (type instanceof ClassDoc || type instanceof TypeVariable)81? type.typeName() // omit formal type params or bounds82: type.toString();83}8485/**86* Returns a string representation of the parameter.87* <p>88* For example if parameter is the short 'index', returns "short index".89*90* @return type name and parameter name of this parameter.91*/92public String toString() {93return typeName() + " " + sym;94}9596/**97* Get the annotations of this parameter.98* Return an empty array if there are none.99*/100public AnnotationDesc[] annotations() {101AnnotationDesc res[] = new AnnotationDesc[sym.getRawAttributes().length()];102int i = 0;103for (Attribute.Compound a : sym.getRawAttributes()) {104res[i++] = new AnnotationDescImpl(env, a);105}106return res;107}108}109110111