1 20 21 package com.tonicsystems.jarjar.util; 22 23 import com.tonicsystems.jarjar.util.*; 24 import java.io.File ; 25 import java.io.IOException ; 26 import java.io.InputStream ; 27 import org.apache.tools.ant.BuildException; 28 import org.apache.tools.ant.taskdefs.Jar; 29 import org.apache.tools.zip.ZipOutputStream; 30 31 abstract public class AntJarProcessor extends Jar 32 { 33 private EntryStruct struct = new EntryStruct(); 34 private JarProcessor proc; 35 protected boolean verbose; 36 37 abstract protected JarProcessor getJarProcessor(); 38 39 public void setVerbose(boolean verbose) { 40 this.verbose = verbose; 41 } 42 43 public void execute() throws BuildException { 44 setFilesonly(true); 45 proc = getJarProcessor(); 46 super.execute(); 47 } 48 49 protected void zipDir(File dir, ZipOutputStream zOut, String vPath, int mode) throws IOException { 50 } 52 53 protected void zipFile(InputStream is, ZipOutputStream zOut, String vPath, 54 long lastModified, File fromArchive, int mode) throws IOException { 55 struct.in = is; 56 struct.name = vPath; 57 struct.time = lastModified; 58 struct.file = fromArchive; 59 if (proc.process(struct)) 60 super.zipFile(struct.in, zOut, struct.name, struct.time, struct.file, mode); 61 } 62 63 public void reset() { 64 super.reset(); 65 cleanHelper(); 66 } 67 68 protected void cleanUp() { 69 super.cleanUp(); 70 cleanHelper(); 71 } 72 73 protected void cleanHelper() { 74 verbose = false; 75 } 76 } 77 | Popular Tags |