1 18 package org.apache.tools.ant.taskdefs.optional.native2ascii; 19 20 import java.io.File ; 21 import org.apache.tools.ant.BuildException; 22 import org.apache.tools.ant.ProjectComponent; 23 import org.apache.tools.ant.taskdefs.optional.Native2Ascii; 24 import org.apache.tools.ant.types.Commandline; 25 26 32 public abstract class DefaultNative2Ascii implements Native2AsciiAdapter { 33 34 35 public DefaultNative2Ascii() { 36 } 37 38 49 public final boolean convert(Native2Ascii args, File srcFile, 50 File destFile) throws BuildException { 51 Commandline cmd = new Commandline(); 52 setup(cmd, args); 53 addFiles(cmd, args, srcFile, destFile); 54 return run(cmd, args); 55 } 56 57 68 protected void setup(Commandline cmd, Native2Ascii args) 69 throws BuildException { 70 if (args.getEncoding() != null) { 71 cmd.createArgument().setValue("-encoding"); 72 cmd.createArgument().setValue(args.getEncoding()); 73 } 74 cmd.addArguments(args.getCurrentArgs()); 75 } 76 77 89 protected void addFiles(Commandline cmd, ProjectComponent log, File src, 90 File dest) throws BuildException { 91 cmd.createArgument().setFile(src); 92 cmd.createArgument().setFile(dest); 93 } 94 95 103 protected abstract boolean run(Commandline cmd, ProjectComponent log) 104 throws BuildException; 105 } 106 | Popular Tags |