01: package com.kirkk.analyzer.framework.bcelbundle;
02:
03: import java.util.*;
04: import com.kirkk.analyzer.framework.*;
05: import com.kirkk.analyzer.framework.jar.JarFile;
06: import com.kirkk.analyzer.framework.bcel.*;
07: import java.io.*;
08: import java.util.zip.ZipException;
09:
10: public class JarBuilderImpl implements JarBuilder {
11:
12: public Jar buildJar(JarFile jarFile, List ignorePackages)
13: throws Exception {
14: Jar jar = new JarImpl(jarFile.getFileName());
15: while (jarFile.hasMoreClasses()) {
16: String className = jarFile.nextClass();
17: try {
18: BCELPublicClass javaClass = new BCELPublicClass(jarFile
19: .getFileName(), className, ignorePackages);
20: String packageName = javaClass.getPackageName();
21: JarPackage javaPackage = null;
22: if (jar.containsPackage(packageName)) {
23: javaPackage = jar.getPackage(packageName);
24: } else {
25: javaPackage = new JarPackageImpl(packageName);
26: jar.addPackage(javaPackage);
27: }
28: javaPackage.addClass(javaClass);
29: } catch (IOException e) {
30: e.printStackTrace();
31: }
32: }
33: jarFile.close();
34: return jar;
35: }
36:
37: }
|