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;
while (index < end) { testChar = p_uriSpec.charAt(index); if (testChar == '#') { break; } if (testChar == '%') { if (index+2 >= end || !isHex(p_uriSpec.charAt(index+1)) || !isHex(p_uriSpec.charAt(index+2))) { throw new MalformedURIException( "Query string contains invalid escape sequence!"); } index += 2; } else if (!isURICharacter(testChar)) { throw new MalformedURIException( "Query string 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: 10 Number of AST nodes: 11
1
while (index < end) {
1
testChar = p_uriSpec.charAt(index);
2
        testChar = p_uriSpec.charAt(index);
2
            
3
        
3
                if (testChar == '?' || testChar == '#') {
4
if (testChar == '#') {
4
                    break;
5
          break;
5
                }
6
        }
6
                
7
                // check for valid escape sequence
8
                if (testChar == '%') {
7
        if (testChar == '%') {
9
                    if (index+2 >= end ||
8
           if (index+2 >= end ||
10
                    !isHex(p_uriSpec.charAt(index+1)) ||
9
              !isHex(p_uriSpec.charAt(index+1)) ||
11
                    !isHex(p_uriSpec.charAt(index+2))) {
10
              !isHex(p_uriSpec.charAt(index+2))) {
12
                        throw new MalformedURIException(
11
            throw new MalformedURIException(
13
                            "Opaque part contains invalid escape sequence!");
12
                    "Query string contains invalid escape sequence!");
14
                    }
13
           }
15
                    index += 2;
14
           index += 2;
16
                }
15
        
17
                // If the scheme specific part is opaque, it can contain '['
18
                // and ']'. uric_no_slash wasn't modified by RFC 2732, which
19
                // I've interpreted as an error in the spec, since the 
20
                // production should be equivalent to (uric - '/'), and uric
21
                // contains '[' and ']'. - mrglavas
22
        
16
}
23
        else if (!isURICharacter(testChar)) {
17
        else if (!isURICharacter(testChar)) {
24
                    throw new MalformedURIException(
18
          throw new MalformedURIException(
25
                        "Opaque part contains invalid character: " + testChar);
19
                "Query string contains invalid character: " + testChar);
26
                }
20
        
27
      
21
}
28
          ++index;
22
        index++;
23
      }
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.9
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 fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)4.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    21
    testChar = p_uriSpec.charAt(index);
    36
    testChar = p_uriSpec.charAt(index);
    22
    if (testChar == '?' || testChar == '#')
    22
    if (testChar == '?' || testChar == '#')
    37
    if (testChar == '#')
    Differences
    Expression1Expression2Difference
    ||==OPERATOR_MISMATCH
    testChar == '?'testCharINFIX_LEFT_OPERAND_MISMATCH
    testChar == '#''#'INFIX_RIGHT_OPERAND_MISMATCH
    Preondition Violations
    Expression testChar == '?' || testChar == '#' cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression testChar == '#' cannot be parameterized, because it has dependencies to/from statements that will be extracted
    37
    if (testChar == '#')
    23
    break;
    23
    break;
    38
    break;
    Preondition Violations
    Statement break; without innermost loop
    Statement break; without innermost loop
    38
    break;
    24
    if (testChar == '%')
    39
    if (testChar == '%')
    25
    if (index + 2 >= end || !isHex(p_uriSpec.charAt(index + 1)) || !isHex(p_uriSpec.charAt(index + 2)))
    40
    if (index + 2 >= end || !isHex(p_uriSpec.charAt(index + 1)) || !isHex(p_uriSpec.charAt(index + 2)))
    26
    throw new MalformedURIException("Opaque part contains invalid escape sequence!");
    26
    throw new MalformedURIException("Opaque part contains invalid escape sequence!");
    41
    throw new MalformedURIException("Query string contains invalid escape sequence!");
    Differences
    Expression1Expression2Difference
    "Opaque part contains invalid escape sequence!""Query string contains invalid escape sequence!"LITERAL_VALUE_MISMATCH
    41
    throw new MalformedURIException("Query string contains invalid escape sequence!");
    27
    index += 2;
    42
    index += 2;
    28
    else if (!isURICharacter(testChar))
    43
    else if (!isURICharacter(testChar))
    29
    throw new MalformedURIException("Opaque part contains invalid character: " + testChar);
    29
    throw new MalformedURIException("Opaque part contains invalid character: " + testChar);
    44
    throw new MalformedURIException("Query string contains invalid character: " + testChar);
    Differences
    Expression1Expression2Difference
    "Opaque part contains invalid character: ""Query string contains invalid character: "LITERAL_VALUE_MISMATCH
    44
    throw new MalformedURIException("Query string contains invalid character: " + testChar);
    30
    ++index;
    30
    ++index;
    Preondition Violations
    Unmatched statement ++index; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                            
                            
    45
    index++;
    Preondition Violations
    Unmatched statement index++; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    45
    index++;
    Precondition Violations (7)
    Row Violation
    1Expression testChar == '?' || testChar == '#' cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression testChar == '#' cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Statement break; without innermost loop
    4Statement break; without innermost loop
    5Unmatched statement ++index; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement index++; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Clone fragment #1 returns variables index, testChar , while Clone fragment #2 returns variables index, testChar