/** * Find a class within the given namespace that has the given identifier. * * @param identifier the class identifier * @param ns namespace to look in * @return the class if found, null otherwise */ private static Object findClass(String identifier, Object ns) { Collection classes = getCoreHelper().getAllClasses(ns); Iterator it = classes.iterator(); while (it.hasNext()) { Object candidateClass = it.next(); if (Model.getFacade().getName(candidateClass).equals(identifier)) { return candidateClass; } } return null; }
/** * Find a class in a package. If it does not exist, a new class is * created. * * @param mPackage Look in this package. * @param name The name of the class. * @return The class found or created. */ private Object getClass(Object mPackage, String name) { Object mClass = null; for (Object c : Model.getCoreHelper().getAllClasses(mPackage)) { if (name.equals(Model.getFacade().getName(c))) { mClass = c; break; } } if (mClass == null) { mClass = Model.getCoreFactory().buildClass(name, mPackage); newElements.add(mClass); } return mClass; }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml-cpp/src/org/argouml/language/cpp/reveng/ModelerImpl.java File path: /ArgoUML-0.34-src/argouml-java/src/org/argouml/language/java/reveng/Modeller.java
Method name: Object findClass(String, Object) Method name: Object getClass(Object, String)
Number of AST nodes: 4 Number of AST nodes: 4
1
/**
1
/**
2
     * Find a class within the given namespace that has the given identifier.
2
     * Find a class in a package. If it does not exist, a new class is
3
     *
3
     * created.
4
     * @param identifier the class identifier
4
     * 
5
     * @param ns namespace to look in
5
     * @param mPackage Look in this package.
6
     * @return the class if found, null otherwise
6
     * @param name The name of the class.
7
     */
7
     * @return The class found or created.
8
    private static Object findClass(String identifier, Object ns) {
8
     */
9
        Collection classes = getCoreHelper().getAllClasses(ns);
9
    private Object getClass(Object mPackage, String name) {
10
        Iterator it = classes.iterator();
10
        Object mClass = null;
11
        while (it.hasNext()) {
11
        for (Object c : Model.getCoreHelper().getAllClasses(mPackage)) {
12
            Object candidateClass = it.next();
12
            if (name.equals(Model.getFacade().getName(c))) {
13
            if (Model.getFacade().getName(candidateClass).equals(identifier)) {
13
                mClass = c;
14
                return candidateClass;
14
                break;
15
            }
15
            }
16
        }
16
        }
17
        return null;
17
        if (mClass == null) {
18
    }
18
            mClass = Model.getCoreFactory().buildClass(name, mPackage);
19
            newElements.add(mClass);
20
        }
21
        return mClass;
22
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)0.0
    Similarity Score1.000
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    3
    while (it.hasNext())
    3
    while (it.hasNext())
    2
    for (Object c : Model.getCoreHelper().getAllClasses(mPackage))
    Differences
    Expression1Expression2Difference
    candidateClasscVARIABLE_NAME_MISMATCH
    classesModel.getCoreHelper().getAllClasses(mPackage)TYPE_COMPATIBLE_REPLACEMENT
    2
    for (Object c : Model.getCoreHelper().getAllClasses(mPackage))
    4
    Object candidateClass = it.next();
    4
    Object candidateClass = it.next();
    Differences
    Expression1Expression2Difference
    candidateClasscVARIABLE_NAME_MISMATCH
                                                                          
    5
    if (Model.getFacade().getName(candidateClass).equals(identifier))
    5
    if (Model.getFacade().getName(candidateClass).equals(identifier))
    3
    if (name.equals(Model.getFacade().getName(c)))
    Differences
    Expression1Expression2Difference
    identifierModel.getFacade().getName(c)TYPE_COMPATIBLE_REPLACEMENT
    Model.getFacade().getName(candidateClass)nameTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression Model.getFacade().getName(c) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    if (name.equals(Model.getFacade().getName(c)))
                            
    4
    mClass = c;
    Preondition Violations
    Unmatched statement mClass=c; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    mClass = c;
                      
    5
    break;
    Preondition Violations
    Unmatched break;
    5
    break;
    6
    return candidateClass;
    6
    return candidateClass;
    Preondition Violations
    Unmatched statement return candidateClass; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched return candidateClass;
                                                      
    Precondition Violations (5)
    Row Violation
    1Expression Model.getFacade().getName(c) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Unmatched statement mClass=c; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched break;
    4Unmatched statement return candidateClass; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched return candidateClass;