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 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) throws Exception { 24 this(fileName, className, new ArrayList()); 25 } 26 27 public BCELPublicClass(String fileName, String className, List ignorePackages) throws Exception { 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.packageName = javaClass.getPackageName(); 36 this.isAbstract = javaClass.isAbstract(); 37 this.isPublic = javaClass.isPublic(); 38 this.longName = javaClass.getClassName(); 39 this.isInterface = javaClass.isInterface(); 40 } 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 } 51 52 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 getPackageName() { 76 return this.packageName; 77 } 78 79 public String getLongName() { 80 return this.longName; 81 } 82 83 86 87 public boolean isInterface() { 88 return this.isInterface; 89 } 90 91 } 92 | Popular Tags |