/** * 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; }
/** * Get a feature from the current classifier not yet modeled. * * @param name The name of the feature. * @return The found feature, null if not found. */ public Object getFeature(String name) { for (Object mFeature : obsoleteFeatures) { if (name.equals(Model.getFacade().getName(mFeature))) { return mFeature; } } return null; }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml-sql/src/org/argouml/language/sql/Utils.java File path: /ArgoUML-0.34-src/argouml-java/src/org/argouml/language/java/reveng/classfile/ParseState.java
Method name: Object getAttributeForName(Object, String) Method name: Object getFeature(String)
Number of AST nodes: 5 Number of AST nodes: 3
1
/**
1
/**
2
     * Search the attribute named <code>attributeName</code> in the given
2
     * Get a feature from the current classifier not yet modeled.
3
     * relation. If there exist more than one attribute the first one is
3
     *
4
     * returned.
4
     * @param name The name of the feature.
5
     * 
5
     * @return The found feature, null if not found.
6
     * @param relation
6
     */
7
     *            The relation in which to search the attribute.
7
    public Object getFeature(String name) {
8
     * @param attributeName
8
        for (Object mFeature : obsoleteFeatures) {
9
     *            The name of the attribute to search.
9
	    if (name.equals(Model.getFacade().getName(mFeature))) {
10
     * @return The attribute if found, <code>null</code> else.
10
		return mFeature;
11
     */
11
	    }
12
    public static Object getAttributeForName(Object relation,
12
	}
13
            String attributeName) {
13
	return null;
14
        Object attribute = null;
14
    }
15
16
        Collection attributes = Model.getFacade().getAttributes(relation);
17
        for (Iterator it = attributes.iterator(); it.hasNext();) {
18
            Object attr = it.next();
19
            if (Model.getFacade().getName(attr).equals(attributeName)) {
20
                attribute = attr;
21
                break;
22
            }
23
        }
24
25
        return attribute;
26
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Similarity Score1.000
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    3
    for (Iterator it = attributes.iterator(); it.hasNext(); )
    3
    for (Iterator it = attributes.iterator(); it.hasNext(); )
    1
    for (Object mFeature : obsoleteFeatures)
    Differences
    Expression1Expression2Difference
    attrmFeatureVARIABLE_NAME_MISMATCH
    attributesobsoleteFeaturesVARIABLE_NAME_MISMATCH
    1
    for (Object mFeature : obsoleteFeatures)
    4
    Object attr = it.next();
    4
    Object attr = it.next();
    Differences
    Expression1Expression2Difference
    attrmFeatureVARIABLE_NAME_MISMATCH
                                                      
    5
    if (Model.getFacade().getName(attr).equals(attributeName))
    5
    if (Model.getFacade().getName(attr).equals(attributeName))
    2
    if (name.equals(Model.getFacade().getName(mFeature)))
    Differences
    Expression1Expression2Difference
    attributeNameModel.getFacade().getName(mFeature)TYPE_COMPATIBLE_REPLACEMENT
    Model.getFacade().getName(attr)nameTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression Model.getFacade().getName(mFeature) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2
    if (name.equals(Model.getFacade().getName(mFeature)))
                                          
    3
    return mFeature;
    Preondition Violations
    Unmatched statement return mFeature; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched return mFeature;
    3
    return mFeature;
    6
    attribute = attr;
    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
                                        
    7
    break;
    7
    break;
    Preondition Violations
    Unmatched break;
                      
    Precondition Violations (5)
    Row Violation
    1Expression Model.getFacade().getName(mFeature) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Unmatched statement return mFeature; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched return mFeature;
    4Unmatched statement attribute=attr; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched break;