KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > logicalcobwebs > 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  * Contact: Eric.Bruneton@rd.francetelecom.com
31  *
32  * Author: Eric Bruneton
33  */

34
35 package org.logicalcobwebs.asm;
36
37 /**
38  * A visitor to visit a Java class. The methods of this interface must be called
39  * in the following order: <tt>visit</tt> (<tt>visitField</tt> |
40  * <tt>visitMethod</tt> | <tt>visitInnerClass</tt> | <tt>visitAttribute</tt>)*
41  * <tt>visitEnd</tt>.
42  */

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

62
63   void visit (
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}. <i>This parameter is only used for static
103    * fields</i>. Its value is ignored for non static fields, which must be
104    * initialized through bytecode instructions in constructors or methods.
105    * @param attrs the non standard method attributes, linked together by their
106    * <tt>next</tt> field. May be <tt>null</tt>.
107    */

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

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

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

156
157   void visitEnd ();
158 }
159
Popular Tags