Home | History | Annotate | Download | only in signature
      1 /***
      2  * ASM: a very small and fast Java bytecode manipulation framework
      3  * Copyright (c) 2000-2005 INRIA, France Telecom
      4  * All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  * 3. Neither the name of the copyright holders nor the names of its
     15  *    contributors may be used to endorse or promote products derived from
     16  *    this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
     22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     28  * THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 package org.objectweb.asm.signature;
     31 
     32 /**
     33  * A visitor to visit a generic signature. The methods of this interface must be
     34  * called in one of the three following orders (the last one is the only valid
     35  * order for a {@link SignatureVisitor} that is returned by a method of this
     36  * interface): <ul> <li><i>ClassSignature</i> = (
     37  * <tt>visitFormalTypeParameter</tt>
     38  *   <tt>visitClassBound</tt>?
     39  * <tt>visitInterfaceBound</tt>* )* ( <tt>visitSuperClass</tt>
     40  *   <tt>visitInterface</tt>* )</li>
     41  * <li><i>MethodSignature</i> = ( <tt>visitFormalTypeParameter</tt>
     42  *   <tt>visitClassBound</tt>?
     43  * <tt>visitInterfaceBound</tt>* )* ( <tt>visitParameterType</tt>*
     44  * <tt>visitReturnType</tt>
     45  *   <tt>visitExceptionType</tt>* )</li> <li><i>TypeSignature</i> =
     46  * <tt>visitBaseType</tt> | <tt>visitTypeVariable</tt> |
     47  * <tt>visitArrayType</tt> | (
     48  * <tt>visitClassType</tt> <tt>visitTypeArgument</tt>* (
     49  * <tt>visitInnerClassType</tt> <tt>visitTypeArgument</tt>* )*
     50  * <tt>visitEnd</tt> ) )</li> </ul>
     51  *
     52  * @author Thomas Hallgren
     53  * @author Eric Bruneton
     54  */
     55 public interface SignatureVisitor {
     56 
     57     /**
     58      * Wildcard for an "extends" type argument.
     59      */
     60     char EXTENDS = '+';
     61 
     62     /**
     63      * Wildcard for a "super" type argument.
     64      */
     65     char SUPER = '-';
     66 
     67     /**
     68      * Wildcard for a normal type argument.
     69      */
     70     char INSTANCEOF = '=';
     71 
     72     /**
     73      * Visits a formal type parameter.
     74      *
     75      * @param name the name of the formal parameter.
     76      */
     77     void visitFormalTypeParameter(String name);
     78 
     79     /**
     80      * Visits the class bound of the last visited formal type parameter.
     81      *
     82      * @return a non null visitor to visit the signature of the class bound.
     83      */
     84     SignatureVisitor visitClassBound();
     85 
     86     /**
     87      * Visits an interface bound of the last visited formal type parameter.
     88      *
     89      * @return a non null visitor to visit the signature of the interface bound.
     90      */
     91     SignatureVisitor visitInterfaceBound();
     92 
     93     /**
     94      * Visits the type of the super class.
     95      *
     96      * @return a non null visitor to visit the signature of the super class
     97      *         type.
     98      */
     99     SignatureVisitor visitSuperclass();
    100 
    101     /**
    102      * Visits the type of an interface implemented by the class.
    103      *
    104      * @return a non null visitor to visit the signature of the interface type.
    105      */
    106     SignatureVisitor visitInterface();
    107 
    108     /**
    109      * Visits the type of a method parameter.
    110      *
    111      * @return a non null visitor to visit the signature of the parameter type.
    112      */
    113     SignatureVisitor visitParameterType();
    114 
    115     /**
    116      * Visits the return type of the method.
    117      *
    118      * @return a non null visitor to visit the signature of the return type.
    119      */
    120     SignatureVisitor visitReturnType();
    121 
    122     /**
    123      * Visits the type of a method exception.
    124      *
    125      * @return a non null visitor to visit the signature of the exception type.
    126      */
    127     SignatureVisitor visitExceptionType();
    128 
    129     /**
    130      * Visits a signature corresponding to a primitive type.
    131      *
    132      * @param descriptor the descriptor of the primitive type, or 'V' for
    133      *        <tt>void</tt>.
    134      */
    135     void visitBaseType(char descriptor);
    136 
    137     /**
    138      * Visits a signature corresponding to a type variable.
    139      *
    140      * @param name the name of the type variable.
    141      */
    142     void visitTypeVariable(String name);
    143 
    144     /**
    145      * Visits a signature corresponding to an array type.
    146      *
    147      * @return a non null visitor to visit the signature of the array element
    148      *         type.
    149      */
    150     SignatureVisitor visitArrayType();
    151 
    152     /**
    153      * Starts the visit of a signature corresponding to a class or interface
    154      * type.
    155      *
    156      * @param name the internal name of the class or interface.
    157      */
    158     void visitClassType(String name);
    159 
    160     /**
    161      * Visits an inner class.
    162      *
    163      * @param name the local name of the inner class in its enclosing class.
    164      */
    165     void visitInnerClassType(String name);
    166 
    167     /**
    168      * Visits an unbounded type argument of the last visited class or inner
    169      * class type.
    170      */
    171     void visitTypeArgument();
    172 
    173     /**
    174      * Visits a type argument of the last visited class or inner class type.
    175      *
    176      * @param wildcard '+', '-' or '='.
    177      * @return a non null visitor to visit the signature of the type argument.
    178      */
    179     SignatureVisitor visitTypeArgument(char wildcard);
    180 
    181     /**
    182      * Ends the visit of a signature corresponding to a class or interface type.
    183      */
    184     void visitEnd();
    185 }
    186