1 20 21 package com.tonicsystems.jarjar; 22 23 import com.tonicsystems.jarjar.util.*; 24 import java.io.*; 25 import java.util.*; 26 import java.util.zip.ZipEntry ; 27 import org.objectweb.asm.ClassReader; 28 import org.objectweb.asm.ClassVisitor; 29 30 public class DepFind 31 { 32 private File curDir = new File(System.getProperty("user.dir")); 33 34 public void setCurrentDirectory(File curDir) { 35 this.curDir = curDir; 36 } 37 38 public void run(String from, String to, DepHandler handler) throws IOException { 39 try { 40 ClassHeaderReader header = new ClassHeaderReader(); 41 Map classes = new HashMap(); 42 ClassPathIterator cp = new ClassPathIterator(curDir, to); 43 while (cp.hasNext()) { 44 Object cls = cp.next(); 45 header.read(cp.getInputStream(cls)); 46 classes.put(header.getClassName(), cp.getSource(cls)); 47 } 48 cp.close(); 49 50 handler.handleStart(); 51 cp = new ClassPathIterator(curDir, from); 52 while (cp.hasNext()) { 53 Object cls = cp.next(); 54 Object source = cp.getSource(cls); 55 new ClassReader(cp.getInputStream(cls)).accept(new DepFindVisitor(classes, source, handler), true); 56 } 57 cp.close(); 58 handler.handleEnd(); 59 } catch (RuntimeIOException e) { 60 throw (IOException)e.getCause(); 61 } 62 } 63 } 64 | Popular Tags |