if (!matches(input, options)) { return null; } Vector v = new Vector(); MatchResult mr = matcher.getMatch(); int cnt = mr.groups(); for (int i = 0; i < cnt; i++) { String match = mr.group(i); // treat non-matching groups as empty matches if (match == null) { match = ""; } v.addElement(match); } return v;
RE reg = getCompiledPattern(options); if (!matches(input, reg)) { return null; } Vector v = new Vector(); int cnt = reg.getParenCount(); for (int i = 0; i < cnt; i++) { String match = reg.getParen(i); // treat non-matching groups as empty matches if (match == null) { match = ""; } v.addElement(match); } return v;
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.java
Method name: Vector getGroups(String, int) Method name: Vector getGroups(String, int)
Number of AST nodes: 11 Number of AST nodes: 11
1
RE reg = getCompiledPattern(options);
1
if (!matches(input, options)) {
2
        if (!matches(input, reg)) {
2
            return null;
3
            return null;
3
        }
4
        }
4
        Vector v = new Vector();
5
        Vector v = new Vector();
5
        MatchResult mr = matcher.getMatch();
6
        
6
        int cnt = mr.groups();
7
int cnt = reg.getParenCount();
7
        for (int i = 0; i < cnt; i++) {
8
        for (int i = 0; i < cnt; i++) {
8
            String match = mr.group(i);
9
            String match = reg.getParen(i);
9
            // treat non-matching groups as empty matches
10
            // treat non-matching groups as empty matches
10
            if (match == null) {
11
            if (match == null) {
11
                match = "";
12
                match = "";
12
            }
13
            }
13
            v.addElement(match);
14
            v.addElement(match);
14
        }
15
        }
15
        return v;
16
        return v;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are in different classes
Number of node comparisons27
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)1.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                
    1
    RE reg = getCompiledPattern(options);
    1
    if (!matches(input, options))
    1
    if (!matches(input, options))
    2
    if (!matches(input, reg))
    Differences
    Expression1Expression2Difference
    optionsregVARIABLE_NAME_MISMATCH
    intorg.apache.regexp.REVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type int of variable options does not match with type org.apache.regexp.RE of variable reg
    2
    if (!matches(input, reg))
    2
    return null;
    3
    return null;
    3
    Vector v = new Vector();
    4
    Vector v = new Vector();
    4
    MatchResult mr = matcher.getMatch();
                                                                              
                                                                  
    5
    int cnt = reg.getParenCount();
    5
    int cnt = mr.groups();
                                                  
    6
    for (int i = 0; i < cnt; i++)
    6
    for (int i = 0; i < cnt; i++)
                                                                    
    7
    String match = reg.getParen(i);
    Preondition Violations
    Unmatched statement String match=reg.getParen(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    String match = reg.getParen(i);
    7
    String match = mr.group(i);
    7
    String match = mr.group(i);
    Preondition Violations
    Unmatched statement String match=mr.group(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                            
    8
    if (match == null)
    8
    if (match == null)
    9
    match = "";
    9
    match = "";
    10
    v.addElement(match);
    10
    v.addElement(match);
    11
    return v;
    11
    return v;
    Precondition Violations (3)
    Row Violation
    1Type int of variable options does not match with type org.apache.regexp.RE of variable reg
    2Unmatched statement String match=reg.getParen(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement String match=mr.group(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted