for (int i = 1; i < length; i++) { c = ianaEncoding.charAt(i); if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9') && c != '.' && c != '_' && c != '-') { return false; } } return true;
for (int i = 1; i < length; i++) { char c = javaEncoding.charAt(i); if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9') && c != '.' && c != '_' && c != '-') { return false; } } return true;
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/xml/type/internal/DataValue.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/xml/type/internal/DataValue.java
Method name: boolean isValidIANAEncoding(String) Method name: boolean isValidJavaEncoding(String)
Number of AST nodes: 5 Number of AST nodes: 5
1
for (int i = 1; i < length; i++) {
1
for (int i = 1; i < length; i++) {
2
                         c = ianaEncoding.charAt(i);
2
                     char c = javaEncoding.charAt(i);
3
                         if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') &&
3
                     if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') &&
4
                             (c < '0' || c > '9') && c != '.' && c != '_' &&
4
                         (c < '0' || c > '9') && c != '.' && c != '_' &&
5
                             c != '-') {
5
                         c != '-') {
6
                             return false;
6
                         return false;
7
                         }
7
                     
8
    
8
}
9
                 }
9
                 }
10
                     return true;
10
                 return true;
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.7
Clones locationClones are declared in the same class
Number of node comparisons10
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    6
    for (int i = 1; i < length; i++)
    4
    for (int i = 1; i < length; i++)
                                                                      
    5
    char c = javaEncoding.charAt(i);
    Preondition Violations
    Unmatched statement char c=javaEncoding.charAt(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    char c = javaEncoding.charAt(i);
    7
    c = ianaEncoding.charAt(i);
    7
    c = ianaEncoding.charAt(i);
    Preondition Violations
    Unmatched statement c=ianaEncoding.charAt(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                            
    8
    if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9') && c != '.' && c != '_' && c != '-')
    6
    if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9') && c != '.' && c != '_' && c != '-')
    9
    return false;
    7
    return false;
    10
    return true;
    8
    return true;
    Precondition Violations (2)
    Row Violation
    1Unmatched statement char c=javaEncoding.charAt(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement c=ianaEncoding.charAt(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted