KickJava   Java API By Example, From Geeks To Geeks.

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


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