1 8 9 import com.izforge.izpress.*; 10 11 import java.io.InputStream ; 12 import java.io.FileInputStream ; 13 import java.io.BufferedInputStream ; 14 import java.io.OutputStream ; 15 import java.io.FileOutputStream ; 16 import java.io.Writer ; 17 import java.io.PrintWriter ; 18 import java.io.FileWriter ; 19 import java.io.BufferedWriter ; 20 import java.io.FileWriter ; 21 import java.io.IOException ; 22 23 import java.util.ArrayList ; 24 25 import org.w3c.dom.NodeList ; 26 import org.w3c.dom.Node ; 27 import org.w3c.dom.Element ; 28 import org.w3c.dom.Attr ; 29 import org.w3c.dom.Document ; 30 import org.w3c.dom.NamedNodeMap ; 31 32 import org.w3c.tidy.Tidy; 33 34 import org.apache.tools.ant.BuildException; 35 import org.apache.tools.ant.taskdefs.Property; 36 37 43 public class IZPressHtmlCompressTask extends org.apache.tools.ant.Task { 44 45 private String src; 46 private String dest; 47 private Compressor compressor; 48 private CompressorConfig conf; 49 private String wipeComments = "true"; 50 private String wipeBorders = "true"; 51 private String wipeReturns = "true"; 52 private String wipeSpaces = "true"; 53 54 PrintWriter pw; 55 58 public IZPressHtmlCompressTask() { 59 super(); 60 } 61 62 65 public void init() { 66 super.init(); 67 conf = 69 new CompressorConfig(false,false,true,true); 70 } 71 72 76 public void execute() throws org.apache.tools.ant.BuildException { 77 78 try{ 79 80 FileInputStream in = new FileInputStream (src); 81 FileOutputStream out = new FileOutputStream (dest); 82 83 compressor = new Compressor(in,out,conf); 84 85 compressor.compress(); 86 87 out.flush(); 88 in.close(); 89 out.close(); 90 91 } 92 catch(IOException ioe) 93 { 94 throw new BuildException(ioe); 95 } 96 } 97 98 public void setSrc(String src) { 99 this.src = src; 100 } 101 102 public void setDest(String dest) { 103 this.dest = dest; 104 } 105 106 107 public void setWipeComments(String wipeComments) { 108 this.wipeComments = wipeComments; 109 } 110 111 112 public void setWipeBorders(String wipeBorders) { 113 this.wipeBorders = wipeBorders; 114 } 115 116 public void setWipeReturns(String wipeReturns) { 117 this.wipeReturns = wipeReturns; 118 } 119 120 121 public void setWipeSpaces(String wipeSpaces) { 122 this.wipeSpaces = wipeSpaces; 123 } 124 125 } 126 127 180
| Popular Tags
|