ResourceSet resourceSet = createResourceSet(); XMLResource resource = (XMLResource)resourceSet.createResource(XML_URI); if (options != null) { Map<Object, Object> mergedOptions = new HashMap<Object, Object>(loadOptions); mergedOptions.putAll(options); resource.load(node, mergedOptions); } else { resource.load(node, loadOptions); } resourceSet.getPackageRegistry().putAll(registry); return resource;
ResourceSet resourceSet = createResourceSet(); Resource resource = resourceSet.createResource(XML_URI); if (options != null) { Map<Object, Object> mergedOptions = new HashMap<Object, Object>(loadOptions); mergedOptions.putAll(options); resource.load(is, mergedOptions); } else { resource.load(is, loadOptions); } resourceSet.getPackageRegistry().putAll(registry); return resource;
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/xmi/util/XMLProcessor.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/xmi/util/XMLProcessor.java
Method name: Resource load(Node, Map) Method name: Resource load(InputStream, Map)
Number of AST nodes: 9 Number of AST nodes: 9
1
ResourceSet resourceSet = createResourceSet();
1
ResourceSet resourceSet = createResourceSet();
2
    XMLResource resource = (XMLResource)resourceSet.createResource(XML_URI);
2
    Resource resource = resourceSet.createResource(XML_URI);
3
    if (options != null)
3
    if (options != null)
4
    {
4
    {
5
      Map<Object, Object> mergedOptions = new HashMap<Object, Object>(loadOptions);
5
      Map<Object, Object> mergedOptions = new HashMap<Object, Object>(loadOptions);
6
      mergedOptions.putAll(options);
6
      mergedOptions.putAll(options);
7
      resource.load(node, mergedOptions);
7
      resource.load(is, mergedOptions);
8
    }
8
    }
9
    else
9
    else
10
    {
10
    {
11
      resource.load(node, loadOptions);
11
      resource.load(is, loadOptions);
12
    }
12
    }
13
    resourceSet.getPackageRegistry().putAll(registry);
13
    resourceSet.getPackageRegistry().putAll(registry);
14
    return resource;
14
    return resource;
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.2
Clones locationClones are declared in the same class
Number of node comparisons37
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)1.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    ResourceSet resourceSet = createResourceSet();
    1
    ResourceSet resourceSet = createResourceSet();
                                                                                                                      
    2
    Resource resource = resourceSet.createResource(XML_URI);
    Preondition Violations
    Unmatched statement Resource resource=resourceSet.createResource(XML_URI); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2
    Resource resource = resourceSet.createResource(XML_URI);
    2
    XMLResource resource = (XMLResource)resourceSet.createResource(XML_URI);
    2
    XMLResource resource = (XMLResource)resourceSet.createResource(XML_URI);
    Preondition Violations
    Unmatched statement XMLResource resource=(XMLResource)resourceSet.createResource(XML_URI); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                      
    3
    if (options != null)
    3
    if (options != null)
    3
    if (options != null)
    Differences
    Expression1Expression2Difference
    java.util.Map<,>java.util.Map<,>VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Map<,> of variable options does not match with type java.util.Map<,> of variable options
    • Make classes java.util.Map<,> and java.util.Map<,> extend a common superclass
    3
    if (options != null)
    4
    Map<Object, Object> mergedOptions = new HashMap<Object, Object>(loadOptions);
    4
    Map<Object, Object> mergedOptions = new HashMap<Object, Object>(loadOptions);
    5
    mergedOptions.putAll(options);
    5
    mergedOptions.putAll(options);
    5
    mergedOptions.putAll(options);
    Differences
    Expression1Expression2Difference
    java.util.Map<,>java.util.Map<,>VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Map<,> of variable options does not match with type java.util.Map<,> of variable options
    • Make classes java.util.Map<,> and java.util.Map<,> extend a common superclass
    5
    mergedOptions.putAll(options);
    6
    resource.load(node, mergedOptions);
    6
    resource.load(node, mergedOptions);
    6
    resource.load(is, mergedOptions);
    Differences
    Expression1Expression2Difference
    nodeisVARIABLE_NAME_MISMATCH
    org.w3c.dom.Nodejava.io.InputStreamVARIABLE_TYPE_MISMATCH
    org.eclipse.emf.ecore.xmi.XMLResourceorg.eclipse.emf.ecore.resource.ResourceVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.w3c.dom.Node of variable node does not match with type java.io.InputStream of variable is
    • Make classes org.w3c.dom.Node and java.io.InputStream extend a common superclass
    Type org.eclipse.emf.ecore.xmi.XMLResource of variable resource does not match with type org.eclipse.emf.ecore.resource.Resource of variable resource
    • Make classes org.eclipse.emf.ecore.xmi.XMLResource and org.eclipse.emf.ecore.resource.Resource extend a common superclass
    6
    resource.load(is, mergedOptions);
    else
    else
    7
    resource.load(node, loadOptions);
    7
    resource.load(node, loadOptions);
    7
    resource.load(is, loadOptions);
    Differences
    Expression1Expression2Difference
    nodeisVARIABLE_NAME_MISMATCH
    org.w3c.dom.Nodejava.io.InputStreamVARIABLE_TYPE_MISMATCH
    org.eclipse.emf.ecore.xmi.XMLResourceorg.eclipse.emf.ecore.resource.ResourceVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.w3c.dom.Node of variable node does not match with type java.io.InputStream of variable is
    • Make classes org.w3c.dom.Node and java.io.InputStream extend a common superclass
    Type org.eclipse.emf.ecore.xmi.XMLResource of variable resource does not match with type org.eclipse.emf.ecore.resource.Resource of variable resource
    • Make classes org.eclipse.emf.ecore.xmi.XMLResource and org.eclipse.emf.ecore.resource.Resource extend a common superclass
    7
    resource.load(is, loadOptions);
    8
    resourceSet.getPackageRegistry().putAll(registry);
    8
    resourceSet.getPackageRegistry().putAll(registry);
                                          
    9
    return resource;
    Preondition Violations
    Unmatched return resource;
    9
    return resource;
    9
    return resource;
    9
    return resource;
    Preondition Violations
    Unmatched return resource;
                                          
    Precondition Violations (10)
    Row Violation
    1Unmatched statement Resource resource=resourceSet.createResource(XML_URI); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement XMLResource resource=(XMLResource)resourceSet.createResource(XML_URI); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Type java.util.Map<,> of variable options does not match with type java.util.Map<,> of variable options
    4Type java.util.Map<,> of variable options does not match with type java.util.Map<,> of variable options
    5Type org.w3c.dom.Node of variable node does not match with type java.io.InputStream of variable is
    6Type org.eclipse.emf.ecore.xmi.XMLResource of variable resource does not match with type org.eclipse.emf.ecore.resource.Resource of variable resource
    7Type org.w3c.dom.Node of variable node does not match with type java.io.InputStream of variable is
    8Type org.eclipse.emf.ecore.xmi.XMLResource of variable resource does not match with type org.eclipse.emf.ecore.resource.Resource of variable resource
    9Unmatched return resource;
    10Unmatched return resource;