KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > uka > ipd > coverage > recording > RegisteredMethodBuilder


1 /*
2  * Created on 19.08.2004
3  *
4  * written by Matthias Kempka
5  */

6 package de.uka.ipd.coverage.recording;
7
8 import java.util.LinkedList JavaDoc;
9 import java.util.List JavaDoc;
10
11 import org.apache.bcel.classfile.JavaClass;
12 import org.apache.bcel.classfile.Method;
13
14 /**
15  * Created on 19.08.2004
16  * @author Matthias Kempka
17  */

18 public class RegisteredMethodBuilder {
19     private List JavaDoc rMethodList = new LinkedList JavaDoc();
20     
21     /**
22      * creates all RegisteredMethods for a JavaClass. The methods can
23      * be meet via getMethods(). Declared abstract methods are ignored
24      * @param jclass
25      */

26     public void createRegisteredMethods(JavaClass jclass) {
27         Method[] methods = jclass.getMethods();
28         for (int i = 0; i < methods.length; i++) {
29             if (! methods[i].isAbstract()) {
30                 rMethodList.add(createRegisteredMethod(methods[i], jclass));
31             }
32         }
33     }
34     
35     /**
36      * Creates a RegisteredMethod for a given <code>org.apache.bcel.classfile.Method</code>
37      * and a given <code>org.apache.bcel.classfile.JavaClass</code>.
38      * This is primarily used as a helper method in this class
39      * @param method
40      * @param jclass
41      */

42     RegisteredMethod createRegisteredMethod(Method method, JavaClass jclass) {
43         RegisteredMethod rMethod = new RegisteredMethod(method, jclass);
44         BasicBlock[] blocks = BasicBlockIdentifyer.getBasicBlocks(rMethod);
45         rMethod.setBasicBlocks(blocks);
46         return rMethod;
47     }
48
49     /**
50      * returns the methods that were created at the last call of
51      * createRegisteredMethods(JavaClass).
52      */

53     public RegisteredMethod[] getRegisteredMethods() {
54        return (RegisteredMethod[]) rMethodList.toArray(
55                new RegisteredMethod[rMethodList.size()]);
56     }
57 }
58
Popular Tags