/** * 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; }
/** * Helper method that gets a stereotype for the given model * element with the given name. * * TODO: this might be a performance bottleneck. If so, caching of * stereotypes for model elements by their stereotypes names could fix it. * * @param modelElement The model element for which to look for the * stereotype with the given name * @param stereotypeName The name of the stereotype. * @return the stereotype model element or null if not found. */ private Object getStereotype(Object modelElement, String stereotypeName) { Object stereotype = null; Collection stereotypes = StereotypeUtility.getAvailableStereotypes( modelElement); for (Iterator it = stereotypes.iterator(); it.hasNext();) { Object candidateStereotype = it.next(); if (getFacade().getName(candidateStereotype).equals( stereotypeName)) { stereotype = candidateStereotype; break; } } return stereotype; }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml-java/src/org/argouml/language/java/reveng/Modeller.java File path: /ArgoUML-0.34-src/argouml-cpp/src/org/argouml/language/cpp/reveng/XtorModeler.java
Method name: Object getClass(Object, String) Method name: Object getStereotype(Object, String)
Number of AST nodes: 4 Number of AST nodes: 5
1
/**
1
/**
2
     * Find a class in a package. If it does not exist, a new class is
2
     * Helper method that gets a stereotype for the given model
3
     * created.
3
     * element with the given name.
4
     * 
4
     *
5
     * @param mPackage Look in this package.
5
     * TODO: this might be a performance bottleneck. If so, caching of
6
     * @param name The name of the class.
6
     * stereotypes for model elements by their stereotypes names could fix it.
7
     * @return The class found or created.
7
     *
8
     */
8
     * @param modelElement The model element for which to look for the
9
    private Object getClass(Object mPackage, String name) {
9
     *            stereotype with the given name
10
        Object mClass = null;
10
     * @param stereotypeName The name of the stereotype.
11
        for (Object c : Model.getCoreHelper().getAllClasses(mPackage)) {
11
     * @return the stereotype model element or null if not found.
12
            if (name.equals(Model.getFacade().getName(c))) {
12
     */
13
                mClass = c;
13
    private Object getStereotype(Object modelElement, String stereotypeName) {
14
                break;
14
        Object stereotype = null;
15
            }
15
        Collection stereotypes = StereotypeUtility.getAvailableStereotypes(
16
        }
16
                modelElement);
17
        if (mClass == null) {
17
        for (Iterator it = stereotypes.iterator(); it.hasNext();) {
18
            mClass = Model.getCoreFactory().buildClass(name, mPackage);
18
            Object candidateStereotype = it.next();
19
            newElements.add(mClass);
19
            if (getFacade().getName(candidateStereotype).equals(
20
        }
20
                stereotypeName)) {
21
        return mClass;
21
                stereotype = candidateStereotype;
22
    }
22
                break;
23
            }
24
        }
25
        return stereotype;
26
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.833
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    2
    for (Object c : Model.getCoreHelper().getAllClasses(mPackage))
    2
    for (Object c : Model.getCoreHelper().getAllClasses(mPackage))
    3
    for (Iterator it = stereotypes.iterator(); it.hasNext(); )
    Differences
    Expression1Expression2Difference
    ccandidateStereotypeVARIABLE_NAME_MISMATCH
    Model.getCoreHelper().getAllClasses(mPackage)stereotypesTYPE_COMPATIBLE_REPLACEMENT
    3
    for (Iterator it = stereotypes.iterator(); it.hasNext(); )
                                                                                    
    4
    Object candidateStereotype = it.next();
    Differences
    Expression1Expression2Difference
    ccandidateStereotypeVARIABLE_NAME_MISMATCH
    4
    Object candidateStereotype = it.next();
    3
    if (name.equals(Model.getFacade().getName(c)))
    3
    if (name.equals(Model.getFacade().getName(c)))
    5
    if (getFacade().getName(candidateStereotype).equals(stereotypeName))
    Differences
    Expression1Expression2Difference
    Model.getFacade().getName(c)stereotypeNameTYPE_COMPATIBLE_REPLACEMENT
    namegetFacade().getName(candidateStereotype)TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression Model.getFacade().getName(c) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    if (getFacade().getName(candidateStereotype).equals(stereotypeName))
    4
    mClass = c;
    4
    mClass = c;
    6
    stereotype = candidateStereotype;
    Differences
    Expression1Expression2Difference
    mClassstereotypeVARIABLE_NAME_MISMATCH
    ccandidateStereotypeVARIABLE_NAME_MISMATCH
    6
    stereotype = candidateStereotype;
    5
    break;
    7
    break;
    Precondition Violations (1)
    Row Violation
    1Expression Model.getFacade().getName(c) cannot be parameterized, because it has dependencies to/from statements that will be extracted