10771-2-3

char charValue = 0; try { Integer value = new Integer(initialValue); charValue = (char) value.intValue(); } catch (NumberFormatException e) { char[] carray = initialValue.toCharArray(); charValue = carray[0]; } return new Character(charValue);
char charValue = 0; try { Integer value = new Integer(stringValue); charValue = (char) value.intValue(); } catch (NumberFormatException e) { char[] carray = stringValue.toCharArray(); charValue = carray[0]; } return new Character(charValue);

Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/impl/EcoreFactoryImpl.java |  | File path: /emf-2.4.1/src/org/eclipse/emf/ecore/impl/EFactoryImpl.java
Method name: `Character createECharFromString(EDataType, String)` |  | Method name: `Object createFromString(EDataType, String)`
Number of AST nodes: 5 |  | Number of AST nodes: 5

1

    char charValue = 0;↵

1

    char charValue = 0;↵

2

        try↵

2

          try↵

3

        {↵

3

        ↵

4

      {↵

4

          Integer value = new Integer(initialValue);↵

5

            Integer value = new Integer(stringValue);↵

5

          charValue = (char) value.intValue();↵

6

            charValue = (char) value.intValue();↵

6

        }↵

7

        ↵

8

      }↵

7

        catch (NumberFormatException e)↵

9

          catch (NumberFormatException e)↵

8

        {↵

10

        ↵

11

      {↵

9

          char[] carray = initialValue.toCharArray();↵

12

            char[] carray = stringValue.toCharArray();↵

10

          charValue = carray[0];↵

13

            charValue = carray[0];↵

11

        }↵

14

        ↵

15

      }↵

12

        return new Character(charValue);

16

          return new Character(charValue);

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 1
Number of non-refactorable cases | 0
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.2
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 13

1. {Refactorable}

   Mapping Summary
   Number of mapped statements | 5
   Number of unmapped statements in the first code fragment | 0
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 0.6
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   3

       char charValue = 0;

   39

       char charValue = 0;

   4

       try

   4 | try
   40 | try

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   initialValue | stringValue | VARIABLE_NAME_MISMATCH

   40

       try

   5

       Integer value = new Integer(initialValue);

   5 | Integer value = new Integer(initialValue);
   41 | Integer value = new Integer(stringValue);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   initialValue | stringValue | VARIABLE_NAME_MISMATCH

   41

       Integer value = new Integer(stringValue);

   6

       charValue = (char)value.intValue();

   42

       charValue = (char)value.intValue();

   7

       return new Character(charValue);

   43

       return new Character(charValue);

   Precondition Violations (0)
   Row | Violation
   --- | ---