01: package com.kirkk.analyzer.framework.bcelbundle;
02:
03: import com.kirkk.analyzer.framework.JarPackage;
04: import com.kirkk.analyzer.framework.JarClass;
05: import java.util.*;
06:
07: public class JarPackageImpl implements JarPackage {
08:
09: private String packageName;
10: private List classes;
11:
12: public JarPackageImpl(String packageName) {
13: if (packageName == null) {
14: throw new NullPointerException(
15: "Package name cannot be null");
16: } else {
17: this .packageName = packageName;
18: }
19: }
20:
21: public void addClass(JarClass jarClass) {
22: if (classes == null) {
23: classes = new ArrayList();
24: }
25: classes.add(jarClass);
26: }
27:
28: public List getClasses() {
29: return this .classes;
30: /*Iterator classIterator = this.publicClasses.iterator();
31: List publicList = new ArrayList();
32: while (classIterator.hasNext()) {
33: PublicClass cls = (PublicClass) classIterator.next();
34: if (cls.isPublic()) {
35: publicList.add(cls);
36: }
37: }
38: return publicList;*/
39: }
40:
41: public int getClassCount() {
42: return this .classes.size();
43: }
44:
45: public String getLongName() {
46: return this .packageName;
47: }
48:
49: public boolean equals(Object obj) {
50: if (obj instanceof JarPackage) {
51: JarPackage javapackage = (JarPackage) obj;
52: if (getLongName().equals(javapackage.getLongName())) {
53: return true;
54: }
55: }
56: return false;
57: }
58:
59: public int hashCode() {
60: return packageName.hashCode();
61: }
62:
63: public List getImportedPackageNames() {
64: List importedPackages = new ArrayList();
65: Iterator classes = this .classes.iterator();
66: while (classes.hasNext()) {
67: JarClass cls = (JarClass) classes.next();
68: Iterator packages = cls.getImportedPackageNames()
69: .iterator();
70: while (packages.hasNext()) {
71: String packageName = (String) packages.next();
72: if (!importedPackages.contains(packageName)) {
73: importedPackages.add(packageName);
74: }
75: }
76: }
77: return importedPackages;
78: }
79: }
|