/** * Adds the patterns of the other instance to this set. * @param other the other PatternSet instance. * @param p the current project. */ public void append(PatternSet other, Project p) { if (isReference()) { throw new BuildException("Cannot append to a reference"); } String[] incl = other.getIncludePatterns(p); if (incl != null) { for (int i = 0; i < incl.length; i++) { createInclude().setName(incl[i]); } } String[] excl = other.getExcludePatterns(p); if (excl != null) { for (int i = 0; i < excl.length; i++) { createExclude().setName(excl[i]); } } }
/** * Appends <code>includes</code> to the current list of include patterns. * Patterns may be separated by a comma or a space. * * @param includes the string containing the include patterns */ public void setIncludes(String includes) { if (isReference()) { throw tooManyAttributes(); } if (includes != null && includes.length() > 0) { StringTokenizer tok = new StringTokenizer(includes, ", ", false); while (tok.hasMoreTokens()) { createInclude().setName(tok.nextToken()); } } }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/PatternSet.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/PatternSet.java
Method name: void append(PatternSet, Project) Method name: void setIncludes(String)
Number of AST nodes: 2 Number of AST nodes: 2
1
/**
1
/**
2
     * Adds the patterns of the other instance to this set.
2
     * Appends <code>includes</code> to the current list of include patterns.
3
     * @param other the other PatternSet instance.
3
     * Patterns may be separated by a comma or a space.
4
     * @param p the current project.
4
     *
5
     */
5
     * @param includes the string containing the include patterns
6
    public void append(PatternSet other, Project p) {
6
     */
7
        if (isReference()) {
7
    public void setIncludes(String includes) {
8
            throw new BuildException("Cannot append to a reference");
8
        if (isReference()) {
9
        }
9
            throw tooManyAttributes();
10
10
        }
11
        String[] incl = other.getIncludePatterns(p);
11
        if (includes != null && includes.length() > 0) {
12
        if (incl != null) {
12
            StringTokenizer tok = new StringTokenizer(includes, ", ", false);
13
            for (int i = 0; i < incl.length; i++) {
13
            while (tok.hasMoreTokens()) {
14
                createInclude().setName(incl[i]);
14
                createInclude().setName(tok.nextToken());
15
            }
15
            }
16
        }
16
        }
17
17
    }
18
        String[] excl = other.getExcludePatterns(p);
19
        if (excl != null) {
20
            for (int i = 0; i < excl.length; i++) {
21
                createExclude().setName(excl[i]);
22
            }
23
        }
24
    }
  1. {Non-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.667
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    5
    for (int i = 0; i < incl.length; i++)
    5
    for (int i = 0; i < incl.length; i++)
    5
    while (tok.hasMoreTokens())
    Differences
    Expression1Expression2Difference
    i < incl.lengthtok.hasMoreTokens()TYPE_COMPATIBLE_REPLACEMENT
    java.lang.String[]java.lang.StringVARIABLE_TYPE_MISMATCH
    java.lang.String[]java.lang.StringVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.String[] of variable incl does not match with type java.lang.String of variable includes
    • Make classes java.lang.String[] and java.lang.String extend a common superclass
    Type java.lang.String[] of variable incl does not match with type java.lang.String of variable includes
    • Make classes java.lang.String[] and java.lang.String extend a common superclass
    5
    while (tok.hasMoreTokens())
    6
    createInclude().setName(incl[i]);
    6
    createInclude().setName(incl[i]);
    6
    createInclude().setName(tok.nextToken());
    Differences
    Expression1Expression2Difference
    incl[i]tok.nextToken()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression incl[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    createInclude().setName(tok.nextToken());
    Precondition Violations (3)
    Row Violation
    1Type java.lang.String[] of variable incl does not match with type java.lang.String of variable includes
    2Type java.lang.String[] of variable incl does not match with type java.lang.String of variable includes
    3Expression incl[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted