/** * This is a patternset nested element. * * @param p a configured patternset nested element. */ public void addConfiguredPatternset(PatternSet p) { if (isReference()) { throw noChildrenAllowed(); } String[] nestedIncludes = p.getIncludePatterns(getProject()); String[] nestedExcludes = p.getExcludePatterns(getProject()); if (nestedIncludes != null) { for (int i = 0; i < nestedIncludes.length; i++) { createInclude().setName(nestedIncludes[i]); } } if (nestedExcludes != null) { for (int i = 0; i < nestedExcludes.length; i++) { createExclude().setName(nestedExcludes[i]); } } }
/** * Appends <code>excludes</code> to the current list of exclude patterns. * Patterns may be separated by a comma or a space. * * @param excludes the string containing the exclude patterns */ public void setExcludes(String excludes) { if (isReference()) { throw tooManyAttributes(); } if (excludes != null && excludes.length() > 0) { StringTokenizer tok = new StringTokenizer(excludes, ", ", false); while (tok.hasMoreTokens()) { createExclude().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 addConfiguredPatternset(PatternSet) Method name: void setExcludes(String)
Number of AST nodes: 2 Number of AST nodes: 2
1
/**
1
/**
2
     * This is a patternset nested element.
2
     * Appends <code>excludes</code> to the current list of exclude patterns.
3
     *
3
     * Patterns may be separated by a comma or a space.
4
     * @param p a configured patternset nested element.
4
     *
5
     */
5
     * @param excludes the string containing the exclude patterns
6
    public void addConfiguredPatternset(PatternSet p) {
6
     */
7
        if (isReference()) {
7
    public void setExcludes(String excludes) {
8
            throw noChildrenAllowed();
8
        if (isReference()) {
9
        }
9
            throw tooManyAttributes();
10
10
        }
11
        String[] nestedIncludes = p.getIncludePatterns(getProject());
11
        if (excludes != null && excludes.length() > 0) {
12
        String[] nestedExcludes = p.getExcludePatterns(getProject());
12
            StringTokenizer tok = new StringTokenizer(excludes, ", ", false);
13
13
            while (tok.hasMoreTokens()) {
14
        if (nestedIncludes != null) {
14
                createExclude().setName(tok.nextToken());
15
            for (int i = 0; i < nestedIncludes.length; i++) {
15
            }
16
                createInclude().setName(nestedIncludes[i]);
16
        }
17
            }
17
    }
18
        }
19
20
        if (nestedExcludes != null) {
21
            for (int i = 0; i < nestedExcludes.length; i++) {
22
                createExclude().setName(nestedExcludes[i]);
23
            }
24
        }
25
    }
  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
    9
    for (int i = 0; i < nestedExcludes.length; i++)
    9
    for (int i = 0; i < nestedExcludes.length; i++)
    5
    while (tok.hasMoreTokens())
    Differences
    Expression1Expression2Difference
    i < nestedExcludes.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 nestedExcludes does not match with type java.lang.String of variable excludes
    • Make classes java.lang.String[] and java.lang.String extend a common superclass
    Type java.lang.String[] of variable nestedExcludes does not match with type java.lang.String of variable excludes
    • Make classes java.lang.String[] and java.lang.String extend a common superclass
    5
    while (tok.hasMoreTokens())
    10
    createExclude().setName(nestedExcludes[i]);
    10
    createExclude().setName(nestedExcludes[i]);
    6
    createExclude().setName(tok.nextToken());
    Differences
    Expression1Expression2Difference
    nestedExcludes[i]tok.nextToken()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression nestedExcludes[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    createExclude().setName(tok.nextToken());
    Precondition Violations (3)
    Row Violation
    1Type java.lang.String[] of variable nestedExcludes does not match with type java.lang.String of variable excludes
    2Type java.lang.String[] of variable nestedExcludes does not match with type java.lang.String of variable excludes
    3Expression nestedExcludes[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted