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.util.ClasspathUtils; 23 import org.apache.tools.ant.util.JavaEnvUtils; 24 25 31 public class Native2AsciiAdapterFactory { 32 33 40 public static String getDefault() { 41 if (JavaEnvUtils.isKaffe()) { 42 return KaffeNative2Ascii.IMPLEMENTATION_NAME; 43 } 44 return SunNative2Ascii.IMPLEMENTATION_NAME; 45 } 46 47 57 public static Native2AsciiAdapter getAdapter(String choice, 58 ProjectComponent log) 59 throws BuildException { 60 if ((JavaEnvUtils.isKaffe() && choice == null) 61 || KaffeNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) { 62 return new KaffeNative2Ascii(); 63 } else if (SunNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) { 64 return new SunNative2Ascii(); 65 } else if (choice != null) { 66 return resolveClassName(choice); 67 } 68 69 return new SunNative2Ascii(); 72 } 73 74 82 private static Native2AsciiAdapter resolveClassName(String className) 83 throws BuildException { 84 return (Native2AsciiAdapter) ClasspathUtils.newInstance(className, 85 Native2AsciiAdapterFactory.class.getClassLoader(), 86 Native2AsciiAdapter.class); 87 } 88 } 89 | Popular Tags |