KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > kirkk > analyzer > framework > bcelbundle > JarPackageImpl


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 JavaDoc packageName;
10     private List classes;
11
12     public JarPackageImpl(String JavaDoc packageName) {
13         if(packageName== null) {
14             throw new NullPointerException JavaDoc("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         /*Iterator classIterator = this.publicClasses.iterator();
30         List publicList = new ArrayList();
31         while (classIterator.hasNext()) {
32             PublicClass cls = (PublicClass) classIterator.next();
33             if (cls.isPublic()) {
34                 publicList.add(cls);
35             }
36         }
37         return publicList;*/

38     }
39
40     public int getClassCount() {
41         return this.classes.size();
42     }
43
44     public String JavaDoc getLongName() {
45         return this.packageName;
46     }
47
48     public boolean equals(Object JavaDoc 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 JavaDoc packageName = (String JavaDoc) packages.next();
70                 if (!importedPackages.contains(packageName)) {
71                     importedPackages.add(packageName);
72                 }
73             }
74         }
75         return importedPackages;
76     }
77 }
78
Popular Tags