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); }
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); }
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: 14 Number of AST nodes: 14
1
if (XMLChar.isHighSurrogate(ch))
1
if (XMLChar.isHighSurrogate(ch))
2
              {
2
              {
3
                char high = ch;
3
                char high = ch;
4
                if (inputLength-- > 0)
4
                if (inputLength-- > 0)
5
                {
5
                {
6
                  ch = input.charAt(inputPos++); 
6
                  ch = input.charAt(inputPos++); 
7
                  if (XMLChar.isLowSurrogate(ch))
7
                  if (XMLChar.isLowSurrogate(ch))
8
                  {
8
                  {
9
                    if (mappableLimit == MAX_UTF_MAPPABLE_CODEPOINT)
9
                    if (mappableLimit == MAX_UTF_MAPPABLE_CODEPOINT)
10
                    {
10
                    {
11
                      // Every codepoint is supported! 
11
                      // Every codepoint is supported! 
12
                      value[outputPos++] = high;
12
                      value[outputPos++] = high;
13
                      value[outputPos++] = ch;
13
                      value[outputPos++] = ch;
14
                    }
14
                    }
15
                    else
15
                    else
16
                    {
16
                    {
17
                      // Produce the supplemental character as an entity
17
                      // Produce the supplemental character as an entity
18
                      outputPos = replaceChars(outputPos, ("&#x" + Integer.toHexString(XMLChar.supplemental(high, ch)) + ";").toCharArray(), inputLength);
18
                      outputPos = replaceChars(outputPos, ("&#x" + Integer.toHexString(XMLChar.supplemental(high, ch)) + ";").toCharArray(), inputLength);
19
                      changed = true;
19
                      changed = true;
20
                    }
20
                    }
21
                    break;
21
                    break;
22
                  }
22
                  }
23
                  throw new RuntimeException("An invalid low surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
23
                  throw new RuntimeException("An invalid low surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
24
                }
24
                }
25
                else
25
                else
26
                {
26
                {
27
                  throw new RuntimeException("An unpaired high surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
27
                  throw new RuntimeException("An unpaired high surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
28
                }
28
                }
29
              }
29
              }
30
              else
30
              else
31
              {
31
              {
32
                throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
32
                throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
33
              }
33
              }
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.6
Clones locationClones are declared in the same class
Number of node comparisons56
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements14
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)9.7
    Clone typeType 1
    Mapped Statements
    ID Statement ID Statement
    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);
    Precondition Violations (1)
    Row Violation
    1Clone fragment #1 returns variables inputLength, inputPos, outputPos, changed , while Clone fragment #2 returns variables inputLength, inputPos, outputPos, changed