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 == '#') { 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
                // check for valid escape sequence
4
if (testChar == '#') {
5
          break;
4
        
6
        }
5
        if (testChar == '%') {
7
        if (testChar == '%') {
6
                    if (index+2 >= end ||
8
           if (index+2 >= end ||
7
                    !isHex(p_uriSpec.charAt(index+1)) ||
9
              !isHex(p_uriSpec.charAt(index+1)) ||
8
                    !isHex(p_uriSpec.charAt(index+2))) {
10
              !isHex(p_uriSpec.charAt(index+2))) {
9
                        throw new MalformedURIException(
11
            throw new MalformedURIException(
10
                            "Path contains invalid escape sequence!");
12
                    "Query string contains invalid escape sequence!");
11
                    }
13
           
12
         
14
}
13
           index += 2;
15
           index += 2;
14
                }
16
        }
15
                // Path segments cannot contain '[' or ']' since pchar
16
                // production was not changed by RFC 2732.
17
                else if (!isPathCharacter(testChar)) {
17
        else if (!isURICharacter(testChar)) {
18
                    if (testChar == '?' || testChar == '#') {
19
                        break;
20
                    }
21
                    throw new MalformedURIException(
18
          throw new MalformedURIException(
22
                        "Path contains invalid character: " + testChar);
19
                "Query string contains invalid character: " + testChar);
23
                }
20
        
24
      
21
}
25
          ++index;
22
        index++;
23
      }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)1.3
Clones locationClones are in the same method
Number of node comparisons9
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)1.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    12
    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)))
    13
    throw new MalformedURIException("Path contains invalid escape sequence!");
    13
    throw new MalformedURIException("Path contains invalid escape sequence!");
    41
    throw new MalformedURIException("Query string contains invalid escape sequence!");
    Differences
    Expression1Expression2Difference
    "Path contains invalid escape sequence!""Query string contains invalid escape sequence!"LITERAL_VALUE_MISMATCH
    41
    throw new MalformedURIException("Query string contains invalid escape sequence!");
    Precondition Violations (0)
    Row Violation