FileDocCategorySizeDatePackage
Native2AsciiAdapterFactory.javaAPI DocApache Ant 1.703262Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.taskdefs.optional.native2ascii

Native2AsciiAdapterFactory

public class Native2AsciiAdapterFactory extends Object
Creates the Native2AsciiAdapter based on the user choice and potentially the VM vendor.
since
Ant 1.6.3

Fields Summary
Constructors Summary
Methods Summary
public static Native2AsciiAdaptergetAdapter(java.lang.String choice, org.apache.tools.ant.ProjectComponent log)
Creates the Native2AsciiAdapter based on the user choice and * potentially the VM vendor.

param
choice the user choice (if any).
param
log a ProjectComponent instance used to access Ant's logging system.
return
The adapter to use.
throws
BuildException if there was a problem.

        if ((JavaEnvUtils.isKaffe() && choice == null)
            || KaffeNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) {
            return new KaffeNative2Ascii();
        } else if (SunNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) {
            return new SunNative2Ascii();
        } else if (choice != null) {
            return resolveClassName(choice);
        }

        // This default has been good enough until Ant 1.6.3, so stick
        // with it
        return new SunNative2Ascii();
    
public static java.lang.StringgetDefault()
Determines the default choice of adapter based on the VM vendor.

return
the default choice of adapter based on the VM vendor

        if (JavaEnvUtils.isKaffe()) {
            return KaffeNative2Ascii.IMPLEMENTATION_NAME;
        }
        return SunNative2Ascii.IMPLEMENTATION_NAME;
    
private static Native2AsciiAdapterresolveClassName(java.lang.String className)
Tries to resolve the given classname into a native2ascii adapter. Throws a fit if it can't.

param
className The fully qualified classname to be created.
throws
BuildException This is the fit that is thrown if className isn't an instance of Native2AsciiAdapter.

        return (Native2AsciiAdapter) ClasspathUtils.newInstance(className,
            Native2AsciiAdapterFactory.class.getClassLoader(),
            Native2AsciiAdapter.class);