01: package com.kirkk.analyzer.framework.bcel;
02:
03: import com.kirkk.analyzer.framework.JarClass;
04: import java.util.*;
05: import org.apache.bcel.classfile.JavaClass;
06: import org.apache.bcel.classfile.Method;
07: import org.apache.bcel.classfile.ConstantPool;
08: import org.apache.bcel.classfile.ConstantUtf8;
09: 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 packageName;
18: private String longName;
19: private boolean isAbstract;
20: private boolean isPublic;
21: private boolean isInterface;
22:
23: public BCELPublicClass(String fileName, String className)
24: throws Exception {
25: this (fileName, className, new ArrayList());
26: }
27:
28: public BCELPublicClass(String fileName, String className,
29: List ignorePackages) throws Exception {
30: this (BCELClassFactory.getClass(fileName, className),
31: ignorePackages);
32: }
33:
34: private BCELPublicClass(JavaClass javaClass, List ignorePackages) {
35: this .importedPackages = this .getImportedPackages(javaClass,
36: ignorePackages);
37: //this.publicMethods = this.getPublicMethods(javaClass);
38: this .packageName = javaClass.getPackageName();
39: this .isAbstract = javaClass.isAbstract();
40: this .isPublic = javaClass.isPublic();
41: this .longName = javaClass.getClassName();
42: this .isInterface = javaClass.isInterface();
43: //this.javaClass = javaClass;
44: }
45:
46: private List getImportedPackages(JavaClass javaClass,
47: List ignorePackages) {
48: PackageVisitor pVisitor = new PackageVisitor(javaClass);
49: DescendingVisitor dVisitor = new DescendingVisitor(javaClass,
50: pVisitor);
51: javaClass.accept(dVisitor);
52: return pVisitor.getImports(ignorePackages);
53:
54: //return pVisitor.getNonJavaImports();
55: }
56:
57: /*private List getPublicMethods(JavaClass javaClass) {
58: ArrayList arraylist = new ArrayList();
59: Method methods[] = javaClass.getMethods();
60: for(int i = 0; i < methods.length; i++) {
61: if (methods[i].isPublic()) {
62: arraylist.add(new BCELPublicMethod(methods[i]));
63: }
64: }
65: return arraylist;
66: }*/
67:
68: public boolean isPublic() {
69: return this .isPublic;
70: }
71:
72: public boolean isAbstract() {
73: return this .isAbstract;
74: }
75:
76: public List getImportedPackageNames() {
77: return this .importedPackages;
78: }
79:
80: public String getPackageName() {
81: return this .packageName;
82: }
83:
84: public String getLongName() {
85: return this .longName;
86: }
87:
88: /*public List getPublicMethods() {
89: return this.publicMethods;
90: }*/
91:
92: public boolean isInterface() {
93: return this.isInterface;
94: }
95:
96: }
|