KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > kirkk > analyzer > framework > bcel > BCELPublicClass


1 package com.kirkk.analyzer.framework.bcel;
2
3 import com.kirkk.analyzer.framework.JarClass;
4 import java.util.*;
5 import org.apache.bcel.classfile.JavaClass;
6 import org.apache.bcel.classfile.Method;
7 import org.apache.bcel.classfile.ConstantPool;
8 import org.apache.bcel.classfile.ConstantUtf8;
9 import org.apache.bcel.classfile.DescendingVisitor;
10
11 public class BCELPublicClass implements JarClass {
12
13     //private JavaClass javaClass;
14
private static List ignorePackages;
15     private List importedPackages;
16     private List publicMethods;
17     private String JavaDoc packageName;
18     private String JavaDoc longName;
19     private boolean isAbstract;
20     private boolean isPublic;
21     private boolean isInterface;
22
23     public BCELPublicClass(String JavaDoc fileName, String JavaDoc className) throws Exception JavaDoc {
24         this(fileName, className, new ArrayList());
25     }
26
27     public BCELPublicClass(String JavaDoc fileName, String JavaDoc className, List ignorePackages) throws Exception JavaDoc {
28         this(BCELClassFactory.getClass(fileName, className), ignorePackages);
29     }
30
31
32     private BCELPublicClass(JavaClass javaClass, List ignorePackages) {
33         this.importedPackages = this.getImportedPackages(javaClass, ignorePackages);
34         //this.publicMethods = this.getPublicMethods(javaClass);
35
this.packageName = javaClass.getPackageName();
36         this.isAbstract = javaClass.isAbstract();
37         this.isPublic = javaClass.isPublic();
38         this.longName = javaClass.getClassName();
39         this.isInterface = javaClass.isInterface();
40         //this.javaClass = javaClass;
41
}
42
43     private List getImportedPackages(JavaClass javaClass, List ignorePackages) {
44         PackageVisitor pVisitor = new PackageVisitor(javaClass);
45         DescendingVisitor dVisitor = new DescendingVisitor(javaClass, pVisitor);
46         javaClass.accept(dVisitor);
47         return pVisitor.getImports(ignorePackages);
48
49         //return pVisitor.getNonJavaImports();
50
}
51
52     /*private List getPublicMethods(JavaClass javaClass) {
53         ArrayList arraylist = new ArrayList();
54         Method methods[] = javaClass.getMethods();
55         for(int i = 0; i < methods.length; i++) {
56             if (methods[i].isPublic()) {
57                 arraylist.add(new BCELPublicMethod(methods[i]));
58             }
59         }
60         return arraylist;
61     }*/

62
63     public boolean isPublic() {
64         return this.isPublic;
65     }
66
67     public boolean isAbstract() {
68         return this.isAbstract;
69     }
70
71     public List getImportedPackageNames() {
72         return this.importedPackages;
73     }
74
75     public String JavaDoc getPackageName() {
76         return this.packageName;
77     }
78
79     public String JavaDoc getLongName() {
80         return this.longName;
81     }
82
83    /*public List getPublicMethods() {
84         return this.publicMethods;
85     }*/

86
87     public boolean isInterface() {
88         return this.isInterface;
89     }
90
91 }
92
Popular Tags