while (index < end) { testChar = p_uriSpec.charAt(index); // check for valid escape sequence if (testChar == '%') { if (index+2 >= end || !isHex(p_uriSpec.charAt(index+1)) || !isHex(p_uriSpec.charAt(index+2))) { throw new MalformedURIException( "Path contains invalid escape sequence!"); } index += 2; } // Path segments cannot contain '[' or ']' since pchar // production was not changed by RFC 2732. else if (!isPathCharacter(testChar)) { if (testChar == '?' || testChar == '#') { break; } throw new MalformedURIException( "Path contains invalid character: " + testChar); } ++index; }
while (index < end) { testChar = p_uriSpec.charAt(index); if (testChar == '?' || testChar == '#') { break; } // check for valid escape sequence if (testChar == '%') { if (index+2 >= end || !isHex(p_uriSpec.charAt(index+1)) || !isHex(p_uriSpec.charAt(index+2))) { throw new MalformedURIException( "Opaque part contains invalid escape sequence!"); } index += 2; } // If the scheme specific part is opaque, it can contain '[' // and ']'. uric_no_slash wasn't modified by RFC 2732, which // I've interpreted as an error in the spec, since the // production should be equivalent to (uric - '/'), and uric // contains '[' and ']'. - mrglavas else if (!isURICharacter(testChar)) { throw new MalformedURIException( "Opaque part contains invalid character: " + testChar); } ++index; }
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: void initializePath(String, int) Method name: void initializePath(String, int)
Number of AST nodes: 11 Number of AST nodes: 11
1
while (index < end) {
1
while (index < end) {
2
                testChar = p_uriSpec.charAt(index);
2
                testChar = p_uriSpec.charAt(index);
3
            
3
            
4
                if (testChar == '?' || testChar == '#') {
5
                    break;
6
                }
7
                
4
                // check for valid escape sequence
8
                // check for valid escape sequence
5
                if (testChar == '%') {
9
                if (testChar == '%') {
6
                    if (index+2 >= end ||
10
                    if (index+2 >= end ||
7
                    !isHex(p_uriSpec.charAt(index+1)) ||
11
                    !isHex(p_uriSpec.charAt(index+1)) ||
8
                    !isHex(p_uriSpec.charAt(index+2))) {
12
                    !isHex(p_uriSpec.charAt(index+2))) {
9
                        throw new MalformedURIException(
13
                        throw new MalformedURIException(
10
                            "Path contains invalid escape sequence!");
14
                            "Opaque part contains invalid escape sequence!");
11
                    }
15
                    }
12
                    index += 2;
16
                    index += 2;
13
                }
17
                }
14
                // Path segments cannot contain '[' or ']' since pchar
18
                // If the scheme specific part is opaque, it can contain '['
15
                // production was not changed by RFC 2732.
19
                // and ']'. uric_no_slash wasn't modified by RFC 2732, which
16
                else if (!isPathCharacter(testChar)) {
20
                
17
                    if (testChar == '?' || testChar ==
21
// I've interpreted as an error in the spec, since the 
18
 '#') {
22
                // production should be equivalent to (uric - '/'), and uric
19
                        break;
23
                
20
                    }
24
// contains '[' and ']'. - mrglavas
25
                else if (!isURICharacter(testChar)) {
21
                    throw new MalformedURIException(
26
                    throw new MalformedURIException(
22
                        "Path contains invalid character: " + testChar);
27
                        "Opaque part contains invalid character: " + testChar);
23
                }
28
                }
24
                ++index;
29
                ++index;
25
            }
30
            }
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)1.3
Clones locationClones are in the same method
Number of node comparisons24
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)5.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    9
    while (index < end)
    20
    while (index < end)
    10
    testChar = p_uriSpec.charAt(index);
    21
    testChar = p_uriSpec.charAt(index);
                                                                                        
    22
    if (testChar == '?' || testChar == '#')
    Preondition Violations
    Unmatched statement if(testChar == '?' || testChar == '#') cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22
    if (testChar == '?' || testChar == '#')
                        
    23
    break;
    Preondition Violations
    Unmatched break;
    23
    break;
    11
    if (testChar == '%')
    24
    if (testChar == '%')
    12
    if (index + 2 >= end || !isHex(p_uriSpec.charAt(index + 1)) || !isHex(p_uriSpec.charAt(index + 2)))
    25
    if (index + 2 >= end || !isHex(p_uriSpec.charAt(index + 1)) || !isHex(p_uriSpec.charAt(index + 2)))
    13
    throw new MalformedURIException("Path contains invalid escape sequence!");
    13
    throw new MalformedURIException("Path contains invalid escape sequence!");
    26
    throw new MalformedURIException("Opaque part contains invalid escape sequence!");
    Differences
    Expression1Expression2Difference
    "Path contains invalid escape sequence!""Opaque part contains invalid escape sequence!"LITERAL_VALUE_MISMATCH
    26
    throw new MalformedURIException("Opaque part contains invalid escape sequence!");
    14
    index += 2;
    27
    index += 2;
    15
    else if (!isPathCharacter(testChar))
    15
    else if (!isPathCharacter(testChar))
    28
    else if (!isURICharacter(testChar))
    Differences
    Expression1Expression2Difference
    isPathCharacterisURICharacterMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression isPathCharacter(testChar) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method isPathCharacter
    Expression isURICharacter(testChar) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method isURICharacter
    28
    else if (!isURICharacter(testChar))
    16
    if (testChar == '?' || testChar == '#')
    16
    if (testChar == '?' || testChar == '#')
    Preondition Violations
    Unmatched statement if(testChar == '?' || testChar == '#') cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                        
    17
    break;
    17
    break;
    Preondition Violations
    Unmatched break;
                        
    18
    throw new MalformedURIException("Path contains invalid character: " + testChar);
    18
    throw new MalformedURIException("Path contains invalid character: " + testChar);
    29
    throw new MalformedURIException("Opaque part contains invalid character: " + testChar);
    Differences
    Expression1Expression2Difference
    "Path contains invalid character: ""Opaque part contains invalid character: "LITERAL_VALUE_MISMATCH
    29
    throw new MalformedURIException("Opaque part contains invalid character: " + testChar);
    19
    ++index;
    30
    ++index;
    Precondition Violations (7)
    Row Violation
    1Unmatched statement if(testChar == '?' || testChar == '#') cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched break;
    3Expression isPathCharacter(testChar) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression isURICharacter(testChar) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Unmatched statement if(testChar == '?' || testChar == '#') cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched break;
    7Clone fragment #1 returns variables testChar, index , while Clone fragment #2 returns variables testChar, index