default: { if (!XMLChar.isValid(ch)) { if (XMLChar.isHighSurrogate(ch)) { char high = ch; if (inputLength-- > 0) { ch = input.charAt(inputPos++); if (XMLChar.isLowSurrogate(ch)) { if (mappableLimit == MAX_UTF_MAPPABLE_CODEPOINT) { // Every codepoint is supported! value[outputPos++] = high; value[outputPos++] = ch; } else { // Produce the supplemental character as an entity outputPos = replaceChars(outputPos, ("&#x" + Integer.toHexString(XMLChar.supplemental(high, ch)) + ";").toCharArray(), inputLength); changed = true; } break; } throw new RuntimeException("An invalid low surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input); } else { throw new RuntimeException("An unpaired high surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input); } } else { throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input); } } else { // Normal (BMP) unicode code point. See if we know for a fact that the encoding supports it: if (ch <= mappableLimit) { value[outputPos++] = ch; } else { // We not sure the encoding supports this code point, so we write it as a character entity reference. outputPos = replaceChars(outputPos, ("&#x" + Integer.toHexString(ch) + ";").toCharArray(), inputLength); changed = true; } } break;
default: { if (!XMLChar.isValid(ch)) { if (XMLChar.isHighSurrogate(ch)) { char high = ch; if (inputLength-- > 0) { ch = input.charAt(inputPos++); if (XMLChar.isLowSurrogate(ch)) { if (mappableLimit == MAX_UTF_MAPPABLE_CODEPOINT) { // Every codepoint is supported! value[outputPos++] = high; value[outputPos++] = ch; } else { // Produce the supplemental character as an entity outputPos = replaceChars(outputPos, ("&#x" + Integer.toHexString(XMLChar.supplemental(high, ch)) + ";").toCharArray(), inputLength); changed = true; } break; } throw new RuntimeException("An invalid low surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input); } else { throw new RuntimeException("An unpaired high surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input); } } else { throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input); } } else { // Normal (BMP) unicode code point. See if we know for a fact that the encoding supports it: if (ch <= mappableLimit) { value[outputPos++] = ch; } else { // We not sure the encoding supports this code point, so we write it as a character entity reference. outputPos = replaceChars(outputPos, ("&#x" + Integer.toHexString(ch) + ";").toCharArray(), inputLength); changed = true; } } break;
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/xmi/impl/XMLSaveImpl.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/xmi/impl/XMLSaveImpl.java
Method name: String convert(String) Method name: String convertText(String)
Number of AST nodes: 21 Number of AST nodes: 21
1
default:
1
default:
2
          {
2
          {
3
            if (!XMLChar.isValid(ch))
3
            if (!XMLChar.isValid(ch))
4
            {
4
            {
5
              if (XMLChar.isHighSurrogate(ch))
5
              if (XMLChar.isHighSurrogate(ch))
6
              {
6
              {
7
                char high = ch;
7
                char high = ch;
8
                if (inputLength-- > 0)
8
                if (inputLength-- > 0)
9
                {
9
                {
10
                  ch = input.charAt(inputPos++); 
10
                  ch = input.charAt(inputPos++); 
11
                  if (XMLChar.isLowSurrogate(ch))
11
                  if (XMLChar.isLowSurrogate(ch))
12
                  {
12
                  {
13
                    if (mappableLimit == MAX_UTF_MAPPABLE_CODEPOINT)
13
                    if (mappableLimit == MAX_UTF_MAPPABLE_CODEPOINT)
14
                    {
14
                    {
15
                      // Every codepoint is supported! 
15
                      // Every codepoint is supported! 
16
                      value[outputPos++] = high;
16
                      value[outputPos++] = high;
17
                      value[outputPos++] = ch;
17
                      value[outputPos++] = ch;
18
                    }
18
                    }
19
                    else
19
                    else
20
                    {
20
                    {
21
                      // Produce the supplemental character as an entity
21
                      // Produce the supplemental character as an entity
22
                      outputPos = replaceChars(outputPos, ("&#x" + Integer.toHexString(XMLChar.supplemental(high, ch)) + ";").toCharArray(), inputLength);
22
                      outputPos = replaceChars(outputPos, ("&#x" + Integer.toHexString(XMLChar.supplemental(high, ch)) + ";").toCharArray(), inputLength);
23
                      changed = true;
23
                      changed = true;
24
                    }
24
                    }
25
                    break;
25
                    break;
26
                  }
26
                  }
27
                  throw new RuntimeException("An invalid low surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
27
                  throw new RuntimeException("An invalid low surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
28
                }
28
                }
29
                else
29
                else
30
                {
30
                {
31
                  throw new RuntimeException("An unpaired high surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
31
                  throw new RuntimeException("An unpaired high surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
32
                }
32
                }
33
              }
33
              }
34
              else
34
              else
35
              {
35
              {
36
                throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
36
                throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
37
              }
37
              }
38
            }
38
            }
39
            else
39
            else
40
            {
40
            {
41
              // Normal (BMP) unicode code point. See if we know for a fact that the encoding supports it:
41
              // Normal (BMP) unicode code point. See if we know for a fact that the encoding supports it:
42
              if (ch <= mappableLimit)
42
              if (ch <= mappableLimit)
43
              {
43
              {
44
                value[outputPos++] = ch;
44
                value[outputPos++] = ch;
45
              }
45
              }
46
              else
46
              else
47
              {
47
              {
48
                // We not sure the encoding supports this code point, so we write it as a character entity reference.
48
                // We not sure the encoding supports this code point, so we write it as a character entity reference.
49
                outputPos = replaceChars(outputPos, ("&#x" + Integer.toHexString(ch) + ";").toCharArray(), inputLength);
49
                outputPos = replaceChars(outputPos, ("&#x" + Integer.toHexString(ch) + ";").toCharArray(), inputLength);
50
                changed = true;
50
                changed = true;
51
              }
51
              }
52
            }
52
            }
53
            break;
53
            break;
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.2
Clones locationClones are declared in the same class
Number of node comparisons79
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements21
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)13.3
    Clone typeType 1
    Mapped Statements
    ID Statement ID Statement
    67
    default:
    70
    default:
    68
    if (!XMLChar.isValid(ch))
    71
    if (!XMLChar.isValid(ch))
    69
    if (XMLChar.isHighSurrogate(ch))
    72
    if (XMLChar.isHighSurrogate(ch))
    70
    char high = ch;
    73
    char high = ch;
    71
    if (inputLength-- > 0)
    74
    if (inputLength-- > 0)
    72
    ch = input.charAt(inputPos++);
    75
    ch = input.charAt(inputPos++);
    73
    if (XMLChar.isLowSurrogate(ch))
    76
    if (XMLChar.isLowSurrogate(ch))
    74
    if (mappableLimit == MAX_UTF_MAPPABLE_CODEPOINT)
    77
    if (mappableLimit == MAX_UTF_MAPPABLE_CODEPOINT)
    75
    value[outputPos++] = high;
    78
    value[outputPos++] = high;
    76
    value[outputPos++] = ch;
    79
    value[outputPos++] = ch;
    else
    else
    77
    outputPos = replaceChars(outputPos, ("&#x" + Integer.toHexString(XMLChar.supplemental(high, ch)) + ";").toCharArray(), inputLength);
    80
    outputPos = replaceChars(outputPos, ("&#x" + Integer.toHexString(XMLChar.supplemental(high, ch)) + ";").toCharArray(), inputLength);
    78
    changed = true;
    81
    changed = true;
    79
    break;
    82
    break;
    80
    throw new RuntimeException("An invalid low surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
    83
    throw new RuntimeException("An invalid low surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
    else
    else
    81
    throw new RuntimeException("An unpaired high surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
    84
    throw new RuntimeException("An unpaired high surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
    else
    else
    82
    throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
    85
    throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
    else
    else
    83
    if (ch <= mappableLimit)
    86
    if (ch <= mappableLimit)
    84
    value[outputPos++] = ch;
    87
    value[outputPos++] = ch;
    else
    else
    85
    outputPos = replaceChars(outputPos, ("&#x" + Integer.toHexString(ch) + ";").toCharArray(), inputLength);
    88
    outputPos = replaceChars(outputPos, ("&#x" + Integer.toHexString(ch) + ";").toCharArray(), inputLength);
    86
    changed = true;
    89
    changed = true;
    87
    break;
    90
    break;
    Precondition Violations (1)
    Row Violation
    1Clone fragment #1 returns variables inputLength, inputPos, outputPos, changed , while Clone fragment #2 returns variables inputLength, inputPos, outputPos, changed