KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > retrotranslator > runtime > asm > ClassVisitor


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 net.sf.retrotranslator.runtime.asm;
31
32 /**
33  * A visitor to visit a Java class. The methods of this interface must be called
34  * in the following order: <tt>visit</tt> [ <tt>visitSource</tt> ] [
35  * <tt>visitOuterClass</tt> ] ( <tt>visitAnnotation</tt> |
36  * <tt>visitAttribute</tt> )* (<tt>visitInnerClass</tt> |
37  * <tt>visitField</tt> | <tt>visitMethod</tt> )* <tt>visitEnd</tt>.
38  *
39  * @author Eric Bruneton
40  */

41 public interface ClassVisitor {
42
43     /**
44      * Visits the header of the class.
45      *
46      * @param version the class version.
47      * @param access the class's access flags (see {@link Opcodes}). This
48      * parameter also indicates if the class is deprecated.
49      * @param name the internal name of the class (see
50      * {@link Type#getInternalName() getInternalName}).
51      * @param signature the signature of this class. May be <tt>null</tt> if
52      * the class is not a generic one, and does not extend or implement
53      * generic classes or interfaces.
54      * @param superName the internal of name of the super class (see
55      * {@link Type#getInternalName() getInternalName}). For interfaces,
56      * the super class is {@link Object}. May be <tt>null</tt>, but
57      * only for the {@link Object} class.
58      * @param interfaces the internal names of the class's interfaces (see
59      * {@link Type#getInternalName() getInternalName}). May be
60      * <tt>null</tt>.
61      */

62     void visit(
63         int version,
64         int access,
65         String JavaDoc name,
66         String JavaDoc signature,
67         String JavaDoc superName,
68         String JavaDoc[] interfaces);
69
70     /**
71      * Visits the source of the class.
72      *
73      * @param source the name of the source file from which the class was
74      * compiled. May be <tt>null</tt>.
75      * @param debug additional debug information to compute the correspondance
76      * between source and compiled elements of the class. May be
77      * <tt>null</tt>.
78      */

79     void visitSource(String JavaDoc source, String JavaDoc debug);
80
81     /**
82      * Visits the enclosing class of the class. This method must be called only
83      * if the class has an enclosing class.
84      *
85      * @param owner internal name of the enclosing class of the class.
86      * @param name the name of the method that contains the class, or
87      * <tt>null</tt> if the class is not enclosed in a method of its
88      * enclosing class.
89      * @param desc the descriptor of the method that contains the class, or
90      * <tt>null</tt> if the class is not enclosed in a method of its
91      * enclosing class.
92      */

93     void visitOuterClass(String JavaDoc owner, String JavaDoc name, String JavaDoc desc);
94
95     /**
96      * Visits an annotation of the class.
97      *
98      * @param desc the class descriptor of the annotation class.
99      * @param visible <tt>true</tt> if the annotation is visible at runtime.
100      * @return a non null visitor to visit the annotation values.
101      */

102     AnnotationVisitor visitAnnotation(String JavaDoc desc, boolean visible);
103
104     /**
105      * Visits a non standard attribute of the class.
106      *
107      * @param attr an attribute.
108      */

109     void visitAttribute(Attribute attr);
110
111     /**
112      * Visits information about an inner class. This inner class is not
113      * necessarily a member of the class being visited.
114      *
115      * @param name the internal name of an inner class (see
116      * {@link Type#getInternalName() getInternalName}).
117      * @param outerName the internal name of the class to which the inner class
118      * belongs (see {@link Type#getInternalName() getInternalName}). May
119      * be <tt>null</tt>.
120      * @param innerName the (simple) name of the inner class inside its
121      * enclosing class. May be <tt>null</tt> for anonymous inner
122      * classes.
123      * @param access the access flags of the inner class as originally declared
124      * in the enclosing class.
125      */

126     void visitInnerClass(
127         String JavaDoc name,
128         String JavaDoc outerName,
129         String JavaDoc innerName,
130         int access);
131
132     /**
133      * Visits a field of the class.
134      *
135      * @param access the field's access flags (see {@link Opcodes}). This
136      * parameter also indicates if the field is synthetic and/or
137      * deprecated.
138      * @param name the field's name.
139      * @param desc the field's descriptor (see {@link Type Type}).
140      * @param signature the field's signature. May be <tt>null</tt> if the
141      * field's type does not use generic types.
142      * @param value the field's initial value. This parameter, which may be
143      * <tt>null</tt> if the field does not have an initial value, must
144      * be an {@link Integer}, a {@link Float}, a {@link Long}, a
145      * {@link Double} or a {@link String} (for <tt>int</tt>,
146      * <tt>float</tt>, <tt>long</tt> or <tt>String</tt> fields
147      * respectively). <i>This parameter is only used for static fields</i>.
148      * Its value is ignored for non static fields, which must be
149      * initialized through bytecode instructions in constructors or
150      * methods.
151      * @return a visitor to visit field annotations and attributes, or
152      * <tt>null</tt> if this class visitor is not interested in
153      * visiting these annotations and attributes.
154      */

155     FieldVisitor visitField(
156         int access,
157         String JavaDoc name,
158         String JavaDoc desc,
159         String JavaDoc signature,
160         Object JavaDoc value);
161
162     /**
163      * Visits a method of the class. This method <i>must</i> return a new
164      * {@link MethodVisitor} instance (or <tt>null</tt>) each time it is
165      * called, i.e., it should not return a previously returned visitor.
166      *
167      * @param access the method's access flags (see {@link Opcodes}). This
168      * parameter also indicates if the method is synthetic and/or
169      * deprecated.
170      * @param name the method's name.
171      * @param desc the method's descriptor (see {@link Type Type}).
172      * @param signature the method's signature. May be <tt>null</tt> if the
173      * method parameters, return type and exceptions do not use generic
174      * types.
175      * @param exceptions the internal names of the method's exception classes
176      * (see {@link Type#getInternalName() getInternalName}). May be
177      * <tt>null</tt>.
178      * @return an object to visit the byte code of the method, or <tt>null</tt>
179      * if this class visitor is not interested in visiting the code of
180      * this method.
181      */

182     MethodVisitor visitMethod(
183         int access,
184         String JavaDoc name,
185         String JavaDoc desc,
186         String JavaDoc signature,
187         String JavaDoc[] exceptions);
188
189     /**
190      * Visits the end of the class. This method, which is the last one to be
191      * called, is used to inform the visitor that all the fields and methods of
192      * the class have been visited.
193      */

194     void visitEnd();
195 }
196
Popular Tags