1/*
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 it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.  Oracle designates this
7 * particular file as subject to the "Classpath" exception as provided
8 * 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 WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 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 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 */
24
25/*
26 * This file is available under and governed by the GNU General Public
27 * License version 2 only, as published by the Free Software Foundation.
28 * However, the following notice accompanied the original version of this
29 * file:
30 *
31 * ASM: a very small and fast Java bytecode manipulation framework
32 * Copyright (c) 2000-2011 INRIA, France Telecom
33 * All rights reserved.
34 *
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
37 * are met:
38 * 1. Redistributions of source code must retain the above copyright
39 *    notice, this list of conditions and the following disclaimer.
40 * 2. Redistributions in binary form must reproduce the above copyright
41 *    notice, this list of conditions and the following disclaimer in the
42 *    documentation and/or other materials provided with the distribution.
43 * 3. Neither the name of the copyright holders nor the names of its
44 *    contributors may be used to endorse or promote products derived from
45 *    this software without specific prior written permission.
46 *
47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
51 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
52 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
53 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
54 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
55 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
56 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
57 * THE POSSIBILITY OF SUCH DAMAGE.
58 */
59package jdk.internal.org.objectweb.asm.signature;
60
61import jdk.internal.org.objectweb.asm.Opcodes;
62
63/**
64 * A visitor to visit a generic signature. The methods of this interface must be
65 * called in one of the three following orders (the last one is the only valid
66 * order for a {@link SignatureVisitor} that is returned by a method of this
67 * interface):
68 * <ul>
69 * <li><i>ClassSignature</i> = ( <tt>visitFormalTypeParameter</tt>
70 * <tt>visitClassBound</tt>? <tt>visitInterfaceBound</tt>* )* (
71 * <tt>visitSuperclass</tt> <tt>visitInterface</tt>* )</li>
72 * <li><i>MethodSignature</i> = ( <tt>visitFormalTypeParameter</tt>
73 * <tt>visitClassBound</tt>? <tt>visitInterfaceBound</tt>* )* (
74 * <tt>visitParameterType</tt>* <tt>visitReturnType</tt>
75 * <tt>visitExceptionType</tt>* )</li>
76 * <li><i>TypeSignature</i> = <tt>visitBaseType</tt> |
77 * <tt>visitTypeVariable</tt> | <tt>visitArrayType</tt> | (
78 * <tt>visitClassType</tt> <tt>visitTypeArgument</tt>* (
79 * <tt>visitInnerClassType</tt> <tt>visitTypeArgument</tt>* )* <tt>visitEnd</tt>
80 * ) )</li>
81 * </ul>
82 *
83 * @author Thomas Hallgren
84 * @author Eric Bruneton
85 */
86public abstract class SignatureVisitor {
87
88    /**
89     * Wildcard for an "extends" type argument.
90     */
91    public final static char EXTENDS = '+';
92
93    /**
94     * Wildcard for a "super" type argument.
95     */
96    public final static char SUPER = '-';
97
98    /**
99     * Wildcard for a normal type argument.
100     */
101    public final static char INSTANCEOF = '=';
102
103    /**
104     * The ASM API version implemented by this visitor. The value of this field
105     * must be one of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
106     */
107    protected final int api;
108
109    /**
110     * Constructs a new {@link SignatureVisitor}.
111     *
112     * @param api
113     *            the ASM API version implemented by this visitor. Must be one
114     *            of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
115     */
116    public SignatureVisitor(final int api) {
117        if (api != Opcodes.ASM4 && api != Opcodes.ASM5) {
118            throw new IllegalArgumentException();
119        }
120        this.api = api;
121    }
122
123    /**
124     * Visits a formal type parameter.
125     *
126     * @param name
127     *            the name of the formal parameter.
128     */
129    public void visitFormalTypeParameter(String name) {
130    }
131
132    /**
133     * Visits the class bound of the last visited formal type parameter.
134     *
135     * @return a non null visitor to visit the signature of the class bound.
136     */
137    public SignatureVisitor visitClassBound() {
138        return this;
139    }
140
141    /**
142     * Visits an interface bound of the last visited formal type parameter.
143     *
144     * @return a non null visitor to visit the signature of the interface bound.
145     */
146    public SignatureVisitor visitInterfaceBound() {
147        return this;
148    }
149
150    /**
151     * Visits the type of the super class.
152     *
153     * @return a non null visitor to visit the signature of the super class
154     *         type.
155     */
156    public SignatureVisitor visitSuperclass() {
157        return this;
158    }
159
160    /**
161     * Visits the type of an interface implemented by the class.
162     *
163     * @return a non null visitor to visit the signature of the interface type.
164     */
165    public SignatureVisitor visitInterface() {
166        return this;
167    }
168
169    /**
170     * Visits the type of a method parameter.
171     *
172     * @return a non null visitor to visit the signature of the parameter type.
173     */
174    public SignatureVisitor visitParameterType() {
175        return this;
176    }
177
178    /**
179     * Visits the return type of the method.
180     *
181     * @return a non null visitor to visit the signature of the return type.
182     */
183    public SignatureVisitor visitReturnType() {
184        return this;
185    }
186
187    /**
188     * Visits the type of a method exception.
189     *
190     * @return a non null visitor to visit the signature of the exception type.
191     */
192    public SignatureVisitor visitExceptionType() {
193        return this;
194    }
195
196    /**
197     * Visits a signature corresponding to a primitive type.
198     *
199     * @param descriptor
200     *            the descriptor of the primitive type, or 'V' for <tt>void</tt>
201     *            .
202     */
203    public void visitBaseType(char descriptor) {
204    }
205
206    /**
207     * Visits a signature corresponding to a type variable.
208     *
209     * @param name
210     *            the name of the type variable.
211     */
212    public void visitTypeVariable(String name) {
213    }
214
215    /**
216     * Visits a signature corresponding to an array type.
217     *
218     * @return a non null visitor to visit the signature of the array element
219     *         type.
220     */
221    public SignatureVisitor visitArrayType() {
222        return this;
223    }
224
225    /**
226     * Starts the visit of a signature corresponding to a class or interface
227     * type.
228     *
229     * @param name
230     *            the internal name of the class or interface.
231     */
232    public void visitClassType(String name) {
233    }
234
235    /**
236     * Visits an inner class.
237     *
238     * @param name
239     *            the local name of the inner class in its enclosing class.
240     */
241    public void visitInnerClassType(String name) {
242    }
243
244    /**
245     * Visits an unbounded type argument of the last visited class or inner
246     * class type.
247     */
248    public void visitTypeArgument() {
249    }
250
251    /**
252     * Visits a type argument of the last visited class or inner class type.
253     *
254     * @param wildcard
255     *            '+', '-' or '='.
256     * @return a non null visitor to visit the signature of the type argument.
257     */
258    public SignatureVisitor visitTypeArgument(char wildcard) {
259        return this;
260    }
261
262    /**
263     * Ends the visit of a signature corresponding to a class or interface type.
264     */
265    public void visitEnd() {
266    }
267}
268