1 18 package org.apache.tools.ant.taskdefs.optional.native2ascii; 19 20 import org.apache.tools.ant.BuildException; 21 import org.apache.tools.ant.ProjectComponent; 22 import org.apache.tools.ant.taskdefs.ExecuteJava; 23 import org.apache.tools.ant.taskdefs.optional.Native2Ascii; 24 import org.apache.tools.ant.types.Commandline; 25 26 31 public final class KaffeNative2Ascii extends DefaultNative2Ascii { 32 33 private static final String [] N2A_CLASSNAMES = new String [] { 35 "gnu.classpath.tools.native2ascii.Native2Ascii", 36 "kaffe.tools.native2ascii.Native2Ascii", 38 }; 39 40 43 public static final String IMPLEMENTATION_NAME = "kaffe"; 44 45 46 protected void setup(Commandline cmd, Native2Ascii args) 47 throws BuildException { 48 if (args.getReverse()) { 49 throw new BuildException("-reverse is not supported by Kaffe"); 50 } 51 super.setup(cmd, args); 52 } 53 54 55 protected boolean run(Commandline cmd, ProjectComponent log) 56 throws BuildException { 57 ExecuteJava ej = new ExecuteJava(); 58 Class c = getN2aClass(); 59 if (c == null) { 60 throw new BuildException("Couldn't load Kaffe's Native2Ascii" 61 + " class"); 62 } 63 64 cmd.setExecutable(c.getName()); 65 ej.setJavaCommand(cmd); 66 ej.execute(log.getProject()); 67 return true; 69 } 70 71 77 private static Class getN2aClass() { 78 for (int i = 0; i < N2A_CLASSNAMES.length; i++) { 79 try { 80 return Class.forName(N2A_CLASSNAMES[i]); 81 } catch (ClassNotFoundException cnfe) { 82 } 84 } 85 return null; 86 } 87 88 } 89 | Popular Tags |