KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > libraries > asm > ClassVisitor


1 /***
2  * ASM: a very small and fast Java bytecode manipulation framework
3  * Copyright (c) 2000,2002,2003 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
31 package oracle.toplink.libraries.asm;
32
33 /**
34  * A visitor to visit a Java class. The methods of this interface must be called
35  * in the following order: <tt>visit</tt> (<tt>visitField</tt> |
36  * <tt>visitMethod</tt> | <tt>visitInnerClass</tt> | <tt>visitAttribute</tt>)*
37  * <tt>visitEnd</tt>.
38  *
39  * @author Eric Bruneton
40  */

41
42 public interface ClassVisitor {
43
44   /**
45    * Visits the header of the class.
46    *
47    * @param version the class version.
48    * @param access the class's access flags (see {@link Constants}). This
49    * parameter also indicates if the class is deprecated.
50    * @param name the internal name of the class (see {@link Type#getInternalName()
51    * getInternalName}).
52    * @param superName the internal of name of the super class (see {@link
53    * Type#getInternalName() getInternalName}). For interfaces, the super
54    * class is {@link Object}. May be <tt>null</tt>, but only for the {@link
55    * Object java.lang.Object} class.
56    * @param interfaces the internal names of the class's interfaces (see {@link
57    * Type#getInternalName() getInternalName}). May be <tt>null</tt>.
58    * @param sourceFile the name of the source file from which this class was
59    * compiled. May be <tt>null</tt>.
60    */

61
62   void visit (
63     int version,
64     int access,
65     String JavaDoc name,
66     String JavaDoc superName,
67     String JavaDoc[] interfaces,
68     String JavaDoc sourceFile);
69
70   /**
71    * Visits information about an inner class. This inner class is not
72    * necessarily a member of the class being visited.
73    *
74    * @param name the internal name of an inner class (see {@link
75    * Type#getInternalName() getInternalName}).
76    * @param outerName the internal name of the class to which the inner class
77    * belongs (see {@link Type#getInternalName() getInternalName}). May be
78    * <tt>null</tt>.
79    * @param innerName the (simple) name of the inner class inside its enclosing
80    * class. May be <tt>null</tt> for anonymous inner classes.
81    * @param access the access flags of the inner class as originally declared
82    * in the enclosing class.
83    */

84
85   void visitInnerClass (
86     String JavaDoc name,
87     String JavaDoc outerName,
88     String JavaDoc innerName,
89     int access);
90
91   /**
92    * Visits a field of the class.
93    *
94    * @param access the field's access flags (see {@link Constants}). This
95    * parameter also indicates if the field is synthetic and/or deprecated.
96    * @param name the field's name.
97    * @param desc the field's descriptor (see {@link Type Type}).
98    * @param value the field's initial value. This parameter, which may be
99    * <tt>null</tt> if the field does not have an initial value, must be an
100    * {@link java.lang.Integer Integer}, a {@link java.lang.Float Float}, a
101    * {@link java.lang.Long Long}, a {@link java.lang.Double Double} or a
102    * {@link String String} (for <tt>int</tt>, <tt>float</tt>, <tt>long</tt>
103    * or <tt>String</tt> fields respectively). <i>This parameter is only
104    * used for static fields</i>. Its value is ignored for non static
105    * fields, which must be initialized through bytecode instructions in
106    * constructors or methods.
107    * @param attrs the non standard method attributes, linked together by their
108    * <tt>next</tt> field. May be <tt>null</tt>.
109    */

110
111   void visitField (
112     int access,
113     String JavaDoc name,
114     String JavaDoc desc,
115     Object JavaDoc value,
116     Attribute attrs);
117
118   /**
119    * Visits a method of the class. This method <i>must</i> return a new
120    * {@link CodeVisitor CodeVisitor} instance (or <tt>null</tt>) each time it
121    * is called, i.e., it should not return a previously returned visitor.
122    *
123    * @param access the method's access flags (see {@link Constants}). This
124    * parameter also indicates if the method is synthetic and/or deprecated.
125    * @param name the method's name.
126    * @param desc the method's descriptor (see {@link Type Type}).
127    * @param exceptions the internal names of the method's exception
128    * classes (see {@link Type#getInternalName() getInternalName}). May be
129    * <tt>null</tt>.
130    * @param attrs the non standard method attributes, linked together by their
131    * <tt>next</tt> field. May be <tt>null</tt>.
132    * @return an object to visit the byte code of the method, or <tt>null</tt> if
133    * this class visitor is not interested in visiting the code of this
134    * method.
135    */

136
137   CodeVisitor visitMethod (
138     int access,
139     String JavaDoc name,
140     String JavaDoc desc,
141     String JavaDoc[] exceptions,
142     Attribute attrs);
143
144   /**
145    * Visits a non standard attribute of the class. This method must visit only
146    * the first attribute in the given attribute list.
147    *
148    * @param attr a non standard class attribute. Must not be <tt>null</tt>.
149    */

150
151   void visitAttribute (Attribute attr);
152
153   /**
154    * Visits the end of the class. This method, which is the last one to be
155    * called, is used to inform the visitor that all the fields and methods of
156    * the class have been visited.
157    */

158
159   void visitEnd ();
160 }
161
Popular Tags