1 package com.kirkk.analyzer.framework.bcelbundle; 2 3 import com.kirkk.analyzer.framework.JarPackage; 4 import com.kirkk.analyzer.framework.JarClass; 5 import java.util.*; 6 7 public class JarPackageImpl implements JarPackage { 8 9 private String packageName; 10 private List classes; 11 12 public JarPackageImpl(String packageName) { 13 if(packageName== null) { 14 throw new NullPointerException ("Package name cannot be null"); 15 } else { 16 this.packageName = packageName; 17 } 18 } 19 20 public void addClass(JarClass jarClass) { 21 if(classes == null) { 22 classes = new ArrayList(); 23 } 24 classes.add(jarClass); 25 } 26 27 public List getClasses() { 28 return this.classes; 29 38 } 39 40 public int getClassCount() { 41 return this.classes.size(); 42 } 43 44 public String getLongName() { 45 return this.packageName; 46 } 47 48 public boolean equals(Object obj) { 49 if(obj instanceof JarPackage) { 50 JarPackage javapackage = (JarPackage)obj; 51 if(getLongName().equals(javapackage.getLongName())) { 52 return true; 53 } 54 } 55 return false; 56 } 57 58 public int hashCode() { 59 return packageName.hashCode(); 60 } 61 62 public List getImportedPackageNames() { 63 List importedPackages = new ArrayList(); 64 Iterator classes = this.classes.iterator(); 65 while (classes.hasNext()) { 66 JarClass cls = (JarClass) classes.next(); 67 Iterator packages = cls.getImportedPackageNames().iterator(); 68 while (packages.hasNext()) { 69 String packageName = (String ) packages.next(); 70 if (!importedPackages.contains(packageName)) { 71 importedPackages.add(packageName); 72 } 73 } 74 } 75 return importedPackages; 76 } 77 } 78 | Popular Tags |