/** This */ private String[] getCompileOptionsAsArray() { Vector options = new Vector(); options.addElement(binary ? "-binary" : "-nobinary"); options.addElement(comments ? "-comments" : "-nocomments"); options.addElement(compile ? "-compile" : "-nocompile"); options.addElement(compact ? "-compact" : "-nocompact"); options.addElement(console ? "-console" : "-noconsole"); options.addElement(crossref ? "-crossref" : "-nocrossref"); options.addElement(decimal ? "-decimal" : "-nodecimal"); options.addElement(diag ? "-diag" : "-nodiag"); options.addElement(explicit ? "-explicit" : "-noexplicit"); options.addElement(format ? "-format" : "-noformat"); options.addElement(keep ? "-keep" : "-nokeep"); options.addElement(logo ? "-logo" : "-nologo"); options.addElement(replace ? "-replace" : "-noreplace"); options.addElement(savelog ? "-savelog" : "-nosavelog"); options.addElement(sourcedir ? "-sourcedir" : "-nosourcedir"); options.addElement(strictargs ? "-strictargs" : "-nostrictargs"); options.addElement(strictassign ? "-strictassign" : "-nostrictassign"); options.addElement(strictcase ? "-strictcase" : "-nostrictcase"); options.addElement(strictimport ? "-strictimport" : "-nostrictimport"); options.addElement(strictprops ? "-strictprops" : "-nostrictprops"); options.addElement(strictsignal ? "-strictsignal" : "-nostrictsignal"); options.addElement(symbols ? "-symbols" : "-nosymbols"); options.addElement(time ? "-time" : "-notime"); options.addElement("-" + trace); options.addElement(utf8 ? "-utf8" : "-noutf8"); options.addElement("-" + verbose); String[] results = new String[options.size()]; options.copyInto(results); return results; }
/** * Scan for files which match at least one include pattern and don't match * any exclude patterns. If there are selectors then the files must pass * muster there, as well. Scans under basedir, if set; otherwise the * include patterns without leading wildcards specify the absolute paths of * the files that may be included. * * @exception IllegalStateException if the base directory was set * incorrectly (i.e. if it doesn't exist or isn't a directory). */ public void scan() throws IllegalStateException { synchronized (scanLock) { if (scanning) { while (scanning) { try { scanLock.wait(); } catch (InterruptedException e) { continue; } } if (illegal != null) { throw illegal; } return; } scanning = true; } try { synchronized (this) { illegal = null; clearResults(); // set in/excludes to reasonable defaults if needed: boolean nullIncludes = (includes == null); includes = nullIncludes ? new String[] {"**"} : includes; boolean nullExcludes = (excludes == null); excludes = nullExcludes ? new String[0] : excludes; if (basedir == null) { // if no basedir and no includes, nothing to do: if (nullIncludes) { return; } } else { if (!basedir.exists()) { illegal = new IllegalStateException("basedir " + basedir + " does not exist"); } if (!basedir.isDirectory()) { illegal = new IllegalStateException("basedir " + basedir + " is not a directory"); } if (illegal != null) { throw illegal; } } if (isIncluded("")) { if (!isExcluded("")) { if (isSelected("", basedir)) { dirsIncluded.addElement(""); } else { dirsDeselected.addElement(""); } } else { dirsExcluded.addElement(""); } } else { dirsNotIncluded.addElement(""); } checkIncludePatterns(); clearCaches(); includes = nullIncludes ? null : includes; excludes = nullExcludes ? null : excludes; } } finally { synchronized (scanLock) { scanning = false; scanLock.notifyAll(); } } }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/NetRexxC.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/DirectoryScanner.java
Method name: String[] getCompileOptionsAsArray() Method name: void scan()
Number of AST nodes: 1 Number of AST nodes: 3
1
/** This  */
1
/**
2
    private String[] getCompileOptionsAsArray() {
2
     * Scan for files which match at least one include pattern and don't match
3
        Vector options = new Vector();
3
     * any exclude patterns. If there are selectors then the files must pass
4
4
     * muster there, as well.  Scans under basedir, if set; otherwise the
5
        options.addElement(binary ? "-binary" : "-nobinary");
5
     * include patterns without leading wildcards specify the absolute paths of
6
        options.addElement(comments ? "-comments" : "-nocomments");
6
     * the files that may be included.
7
        options.addElement(compile ? "-compile" : "-nocompile");
7
     *
8
        options.addElement(compact ? "-compact" : "-nocompact");
8
     * @exception IllegalStateException if the base directory was set
9
        options.addElement(console ? "-console" : "-noconsole");
9
     *            incorrectly (i.e. if it doesn't exist or isn't a directory).
10
        options.addElement(crossref ? "-crossref" : "-nocrossref");
10
     */
11
        options.addElement(decimal ? "-decimal" : "-nodecimal");
11
    public void scan() throws IllegalStateException {
12
        options.addElement(diag ? "-diag" : "-nodiag");
12
        synchronized (scanLock) {
13
        options.addElement(explicit ? "-explicit" : "-noexplicit");
13
            if (scanning) {
14
        options.addElement(format ? "-format" : "-noformat");
14
                while (scanning) {
15
        options.addElement(keep ? "-keep" : "-nokeep");
15
                    try {
16
        options.addElement(logo ? "-logo" : "-nologo");
16
                        scanLock.wait();
17
        options.addElement(replace ? "-replace" : "-noreplace");
17
                    } catch (InterruptedException e) {
18
        options.addElement(savelog ? "-savelog" : "-nosavelog");
18
                        continue;
19
        options.addElement(sourcedir ? "-sourcedir" : "-nosourcedir");
19
                    }
20
        options.addElement(strictargs ? "-strictargs" : "-nostrictargs");
20
                }
21
        options.addElement(strictassign ? "-strictassign" : "-nostrictassign");
21
                if (illegal != null) {
22
        options.addElement(strictcase ? "-strictcase" : "-nostrictcase");
22
                    throw illegal;
23
        options.addElement(strictimport ? "-strictimport" : "-nostrictimport");
23
                }
24
        options.addElement(strictprops ? "-strictprops" : "-nostrictprops");
24
                return;
25
        options.addElement(strictsignal ? "-strictsignal" : "-nostrictsignal");
25
            }
26
        options.addElement(symbols ? "-symbols" : "-nosymbols");
26
            scanning = true;
27
        options.addElement(time ? "-time" : "-notime");
27
        }
28
        options.addElement("-" + trace);
28
        try {
29
        options.addElement(utf8 ? "-utf8" : "-noutf8");
29
            synchronized (this) {
30
        options.addElement("-" + verbose);
30
                illegal = null;
31
31
                clearResults();
32
        String[] results = new String[options.size()];
32
33
33
                // set in/excludes to reasonable defaults if needed:
34
        options.copyInto(results);
34
                boolean nullIncludes = (includes == null);
35
        return results;
35
                includes = nullIncludes ? new String[] {"**"} : includes;
36
    }
36
                boolean nullExcludes = (excludes == null);
37
                excludes = nullExcludes ? new String[0] : excludes;
38
39
                if (basedir == null) {
40
                    // if no basedir and no includes, nothing to do:
41
                    if (nullIncludes) {
42
                        return;
43
                    }
44
                } else {
45
                    if (!basedir.exists()) {
46
                        illegal = new IllegalStateException("basedir " + basedir
47
                                                            + " does not exist");
48
                    }
49
                    if (!basedir.isDirectory()) {
50
                        illegal = new IllegalStateException("basedir " + basedir
51
                                                            + " is not a directory");
52
                    }
53
                    if (illegal != null) {
54
                        throw illegal;
55
                    }
56
                }
57
                if (isIncluded("")) {
58
                    if (!isExcluded("")) {
59
                        if (isSelected("", basedir)) {
60
                            dirsIncluded.addElement("");
61
                        } else {
62
                            dirsDeselected.addElement("");
63
                        }
64
                    } else {
65
                        dirsExcluded.addElement("");
66
                    }
67
                } else {
68
                    dirsNotIncluded.addElement("");
69
                }
70
                checkIncludePatterns();
71
                clearCaches();
72
                includes = nullIncludes ? null : includes;
73
                excludes = nullExcludes ? null : excludes;
74
            }
75
        } finally {
76
            synchronized (scanLock) {
77
                scanning = false;
78
                scanLock.notifyAll();
79
            }
80
        }
81
    }
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.500
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    2
    options.addElement(binary ? "-binary" : "-nobinary");
    2
    options.addElement(binary ? "-binary" : "-nobinary");
    29
    if (isSelected("", basedir))
    Differences
    Expression1Expression2Difference
    binaryisSelected("",basedir)TYPE_COMPATIBLE_REPLACEMENT
    optionsdirsIncludedVARIABLE_NAME_MISMATCH
    optionsdirsDeselectedVARIABLE_NAME_MISMATCH
    "-binary"""LITERAL_VALUE_MISMATCH
    "-nobinary"""LITERAL_VALUE_MISMATCH
    29
    if (isSelected("", basedir))
                                                                    
    30
    dirsIncluded.addElement("");
    Differences
    Expression1Expression2Difference
    optionsdirsIncludedVARIABLE_NAME_MISMATCH
    "-binary"""LITERAL_VALUE_MISMATCH
    30
    dirsIncluded.addElement("");
            
    else
                                                                        
    31
    dirsDeselected.addElement("");
    Differences
    Expression1Expression2Difference
    optionsdirsDeselectedVARIABLE_NAME_MISMATCH
    "-nobinary"""LITERAL_VALUE_MISMATCH
    31
    dirsDeselected.addElement("");
    Precondition Violations (0)
    Row Violation