private Object buildImport(Object element, Object srcFile) { // TODO: add <<javaImport>> stereotype to Java profile - thn Collection dependencies = Model.getCoreHelper().getDependencies( element, srcFile); for (Object dep : dependencies) { for (Object stereotype : Model.getFacade().getStereotypes(dep)) { if ("javaImport".equals( Model.getFacade().getName(stereotype))) { return dep; } } } // Didn't find it. Let's create one. Object pkgImport = Model.getCoreFactory().buildDependency(srcFile, element); if (Model.getFacade().getUmlVersion().charAt(0) == '1') { // TODO: support for stereotypes in eUML Model.getCoreHelper().addStereotype(pkgImport, getUML1Stereotype("javaImport")); ProjectManager.getManager().updateRoots(); } String newName = makeDependencyName(srcFile, element); Model.getCoreHelper().setName(pkgImport, newName); newElements.add(pkgImport); return pkgImport; }
/** * Search the attribute named <code>attributeName</code> in the given * relation. If there exist more than one attribute the first one is * returned. * * @param relation * The relation in which to search the attribute. * @param attributeName * The name of the attribute to search. * @return The attribute if found, <code>null</code> else. */ public static Object getAttributeForName(Object relation, String attributeName) { Object attribute = null; Collection attributes = Model.getFacade().getAttributes(relation); for (Iterator it = attributes.iterator(); it.hasNext();) { Object attr = it.next(); if (Model.getFacade().getName(attr).equals(attributeName)) { attribute = attr; break; } } return attribute; }
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-sql/src/org/argouml/language/sql/Utils.java
Method name: Object buildImport(Object, Object) Method name: Object getAttributeForName(Object, String)
Number of AST nodes: 3 Number of AST nodes: 5
1
private Object buildImport(Object element, Object srcFile) {
1
/**
2
        // TODO: add <<javaImport>> stereotype to Java profile - thn
2
     * Search the attribute named <code>attributeName</code> in the given
3
        Collection dependencies = Model.getCoreHelper().getDependencies(
3
     * relation. If there exist more than one attribute the first one is
4
                element, srcFile);
4
     * returned.
5
        for (Object dep : dependencies) {
5
     * 
6
            for (Object stereotype : Model.getFacade().getStereotypes(dep)) {
6
     * @param relation
7
                if ("javaImport".equals(
7
     *            The relation in which to search the attribute.
8
                        Model.getFacade().getName(stereotype))) {
8
     * @param attributeName
9
                    return dep;
9
     *            The name of the attribute to search.
10
                }
10
     * @return The attribute if found, <code>null</code> else.
11
            }
11
     */
12
        }
12
    public static Object getAttributeForName(Object relation,
13
13
            String attributeName) {
14
        // Didn't find it. Let's create one.
14
        Object attribute = null;
15
        Object pkgImport = Model.getCoreFactory().buildDependency(srcFile,
15
16
                element);
16
        Collection attributes = Model.getFacade().getAttributes(relation);
17
        if (Model.getFacade().getUmlVersion().charAt(0) == '1') {
17
        for (Iterator it = attributes.iterator(); it.hasNext();) {
18
            // TODO: support for stereotypes in eUML
18
            Object attr = it.next();
19
            Model.getCoreHelper().addStereotype(pkgImport,
19
            if (Model.getFacade().getName(attr).equals(attributeName)) {
20
                    getUML1Stereotype("javaImport"));
20
                attribute = attr;
21
            ProjectManager.getManager().updateRoots();
21
                break;
22
        }
22
            }
23
        String newName = makeDependencyName(srcFile, element);
23
        }
24
        Model.getCoreHelper().setName(pkgImport, newName);
24
25
        newElements.add(pkgImport);
25
        return attribute;
26
        return pkgImport;
26
    }
27
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    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
    for (Object stereotype : Model.getFacade().getStereotypes(dep))
    3
    for (Object stereotype : Model.getFacade().getStereotypes(dep))
    3
    for (Iterator it = attributes.iterator(); it.hasNext(); )
    Differences
    Expression1Expression2Difference
    stereotypeattrVARIABLE_NAME_MISMATCH
    Model.getFacade().getStereotypes(dep)attributesTYPE_COMPATIBLE_REPLACEMENT
    3
    for (Iterator it = attributes.iterator(); it.hasNext(); )
                                                      
    4
    Object attr = it.next();
    Differences
    Expression1Expression2Difference
    stereotypeattrVARIABLE_NAME_MISMATCH
    4
    Object attr = it.next();
    4
    if ("javaImport".equals(Model.getFacade().getName(stereotype)))
    4
    if ("javaImport".equals(Model.getFacade().getName(stereotype)))
    5
    if (Model.getFacade().getName(attr).equals(attributeName))
    Differences
    Expression1Expression2Difference
    Model.getFacade().getName(stereotype)attributeNameTYPE_COMPATIBLE_REPLACEMENT
    "javaImport"Model.getFacade().getName(attr)TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression Model.getFacade().getName(stereotype) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    if (Model.getFacade().getName(attr).equals(attributeName))
    5
    return dep;
    5
    return dep;
    Preondition Violations
    Unmatched return dep;
                                
                                        
    6
    attribute = attr;
    Preondition Violations
    Unmatched statement attribute=attr; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    attribute = attr;
                      
    7
    break;
    Preondition Violations
    Unmatched break;
    7
    break;
    Precondition Violations (5)
    Row Violation
    1Expression Model.getFacade().getName(stereotype) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Unmatched return dep;
    3Unmatched statement attribute=attr; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched break;
    5Clone fragment #1 returns variables , while Clone fragment #2 returns variables attr