class JavahAdapterFactory { /** * Determines the default choice of adapter based on the VM * vendor. * * @return the default choice of adapter based on the VM * vendor */ public static String getDefault() { if (JavaEnvUtils.isKaffe()) { return Kaffeh.IMPLEMENTATION_NAME; } return SunJavah.IMPLEMENTATION_NAME; } /** * Creates the JavahAdapter 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 is an error. */ public static JavahAdapter getAdapter(String choice, ProjectComponent log) throws BuildException { if ((JavaEnvUtils.isKaffe() && choice == null) || Kaffeh.IMPLEMENTATION_NAME.equals(choice)) { return new Kaffeh(); } else if (SunJavah.IMPLEMENTATION_NAME.equals(choice)) { return new SunJavah(); } else if (choice != null) { return resolveClassName(choice); } // This default has been good enough until Ant 1.6.3, so stick // with it return new SunJavah(); } /** * Tries to resolve the given classname into a javah 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 JavahAdapter. */ private static JavahAdapter resolveClassName(String className) throws BuildException { return (JavahAdapter) ClasspathUtils.newInstance(className, JavahAdapterFactory.class.getClassLoader(), JavahAdapter.class); }
class Native2AsciiAdapterFactory { /** * Determines the default choice of adapter based on the VM * vendor. * * @return the default choice of adapter based on the VM * vendor */ public static String getDefault() { if (JavaEnvUtils.isKaffe()) { return KaffeNative2Ascii.IMPLEMENTATION_NAME; } return SunNative2Ascii.IMPLEMENTATION_NAME; } /** * 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. */ public static Native2AsciiAdapter getAdapter(String choice, ProjectComponent log) throws BuildException { 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(); } /** * 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. */ private static Native2AsciiAdapter resolveClassName(String className) throws BuildException { return (Native2AsciiAdapter) ClasspathUtils.newInstance(className, Native2AsciiAdapterFactory.class.getClassLoader(), Native2AsciiAdapter.class); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
class JavahAdapterFactory {
1
class Native2AsciiAdapterFactory {
2
    /**
2
    /**
3
     * Determines the default choice of adapter based on the VM
3
     * Determines the default choice of adapter based on the VM
4
     * vendor.
4
     * vendor.
5
     *
5
     *
6
     * @return the default choice of adapter based on the VM
6
     * @return the default choice of adapter based on the VM
7
     * vendor
7
     * vendor
8
     */
8
     */
9
    public static String getDefault() {
9
    public static String getDefault() {
10
        if (JavaEnvUtils.isKaffe()) {
10
        if (JavaEnvUtils.isKaffe()) {
11
            return Kaffeh.IMPLEMENTATION_NAME;
11
            return KaffeNative2Ascii.IMPLEMENTATION_NAME;
12
        }
12
        }
13
        return SunJavah.IMPLEMENTATION_NAME;
13
        return SunNative2Ascii.IMPLEMENTATION_NAME;
14
    }
14
    }
15
    /**
15
    /**
16
     * Creates the JavahAdapter based on the user choice and
16
     * Creates the Native2AsciiAdapter based on the user choice and *
17
     * potentially the VM vendor.
17
     * potentially the VM vendor.
18
     *
18
     *
19
     * @param choice the user choice (if any).
19
     * @param choice the user choice (if any).
20
     * @param log a ProjectComponent instance used to access Ant's
20
     * @param log a ProjectComponent instance used to access Ant's
21
     * logging system.
21
     * logging system.
22
     * @return The adapter to use.
22
     * @return The adapter to use.
23
     * @throws BuildException if there is an error.
23
     * @throws BuildException if there was a problem.
24
     */
24
     */
25
    public static JavahAdapter getAdapter(String choice,
25
    public static Native2AsciiAdapter getAdapter(String choice,
26
                                          ProjectComponent log)
26
                                                 ProjectComponent log)
27
        throws BuildException {
27
        throws BuildException {
28
        if ((JavaEnvUtils.isKaffe() && choice == null)
28
        if ((JavaEnvUtils.isKaffe() && choice == null)
29
            || Kaffeh.IMPLEMENTATION_NAME.equals(choice)) {
29
            || KaffeNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) {
30
            return new Kaffeh();
30
            return new KaffeNative2Ascii();
31
        } else if (SunJavah.IMPLEMENTATION_NAME.equals(choice)) {
31
        } else if (SunNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) {
32
            return new SunJavah();
32
            return new SunNative2Ascii();
33
        } else if (choice != null) {
33
        } else if (choice != null) {
34
            return resolveClassName(choice);
34
            return resolveClassName(choice);
35
        }
35
        }
36
        // This default has been good enough until Ant 1.6.3, so stick
36
        // This default has been good enough until Ant 1.6.3, so stick
37
        // with it
37
        // with it
38
        return new SunJavah();
38
        return new SunNative2Ascii();
39
    }
39
    }
40
    /**
40
    /**
41
     * Tries to resolve the given classname into a javah adapter.
41
     * Tries to resolve the given classname into a native2ascii adapter.
42
     * Throws a fit if it can't.
42
     * Throws a fit if it can't.
43
     *
43
     *
44
     * @param className The fully qualified classname to be created.
44
     * @param className The fully qualified classname to be created.
45
     * @throws BuildException This is the fit that is thrown if className
45
     * @throws BuildException This is the fit that is thrown if className
46
     * isn't an instance of JavahAdapter.
46
     * isn't an instance of Native2AsciiAdapter.
47
     */
47
     */
48
    private static JavahAdapter resolveClassName(String className)
48
    private static Native2AsciiAdapter resolveClassName(String className)
49
            throws BuildException {
49
        throws BuildException {
50
        return (JavahAdapter) ClasspathUtils.newInstance(className,
50
        return (Native2AsciiAdapter) ClasspathUtils.newInstance(className,
51
                JavahAdapterFactory.class.getClassLoader(), Javah
51
            Native2AsciiAdapterFactory.class.getClassLoader(),
52
Adapter.class);
52
            Native2AsciiAdapter.class);
53
    }
53
    }
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0