IStructureValue value = context.getValue(); if ( value == null ) return; Iterator<IStructureValue> it = value.getChildIterator( ISemanticContext.CONTEXT_NODE_IDENTITY, ISemanticContext.CONTEXT_NAMESPACE_CORE); // can be only one IStructureValue identity = it.next(); if (identity == null) return; String emailAddress = identity.getString( ISemanticContext.CONTEXT_ATTR_EMAIL_ADDRESS, ISemanticContext.CONTEXT_NAMESPACE_CORE); String displayname = identity.getString( ISemanticContext.CONTEXT_ATTR_DISPLAY_NAME, ISemanticContext.CONTEXT_NAMESPACE_CORE); if (emailAddress == null && displayname == null) return; List<ISearchResult> temp; if (emailAddress != null) { temp = searchProvider.query(emailAddress, ContactSearchProvider.CRITERIA_EMAIL_CONTAINS, false, 0, 5); result.addAll(temp); } if (displayname != null) { temp = searchProvider.query(displayname, ContactSearchProvider.CRITERIA_DISPLAYNAME_CONTAINS, false, 0, 5); result.addAll(temp); }
IStructureValue value = context.getValue(); if (value == null) return; Iterator<IStructureValue> it = value.getChildIterator( ISemanticContext.CONTEXT_NODE_IDENTITY, ISemanticContext.CONTEXT_NAMESPACE_CORE); if (it.hasNext()) { // can be only one IStructureValue identity = it.next(); if (identity == null) return; String emailAddress = identity.getString( ISemanticContext.CONTEXT_ATTR_EMAIL_ADDRESS, ISemanticContext.CONTEXT_NAMESPACE_CORE); String displayname = identity.getString( ISemanticContext.CONTEXT_ATTR_DISPLAY_NAME, ISemanticContext.CONTEXT_NAMESPACE_CORE); if (emailAddress == null && displayname == null) return; List<ISearchResult> temp; if (emailAddress != null) { temp = searchProvider.query(emailAddress, ContactSearchProvider.CRITERIA_EMAIL_CONTAINS, false, 0, 5); result.addAll(temp); } if (displayname != null) { temp = searchProvider.query(displayname, ContactSearchProvider.CRITERIA_DISPLAYNAME_CONTAINS, false, 0, 5); result.addAll(temp); } }
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/contact/src/main/java/org/columba/addressbook/gui/context/ContactContextualProvider.java File path: /columba-1.4-src/contact/src/main/java/org/columba/addressbook/gui/context/ContactDetailsContextualProvider.java
Method name: void search(ISemanticContext, int, int) Method name: void search(ISemanticContext, int, int)
Number of AST nodes: 18 Number of AST nodes: 19
1
IStructureValue value = context.getValue();
1
IStructureValue value = context.getValue();
2
		if ( value == null ) 
2
		if (value == null)
3
return;
3
			return;
4
		
5
		Iterator<IStructureValue> it = value.getChildIterator(
4
		Iterator<IStructureValue> it = value.getChildIterator(
6
				ISemanticContext.CONTEXT_NODE_IDENTITY,
5
				ISemanticContext.CONTEXT_NODE_IDENTITY,
7
				ISemanticContext.CONTEXT_NAMESPACE_CORE);
6
				ISemanticContext.CONTEXT_NAMESPACE_CORE);
8
		
7
		if (it.hasNext()) {
9
// can be only one
8
			// can be only one
10
		IStructureValue identity = it.next();
9
			IStructureValue identity = it.next();
11
		if (identity == null)
10
			if (identity == null)
12
			return;
11
				return;
13
		String emailAddress = identity.getString(
12
			String emailAddress = identity.getString(
14
				ISemanticContext.CONTEXT_ATTR_EMAIL_ADDRESS,
13
					ISemanticContext.CONTEXT_ATTR_EMAIL_ADDRESS,
15
				ISemanticContext.CONTEXT_NAMESPACE_CORE);
14
					ISemanticContext.CONTEXT_NAMESPACE_CORE);
16
		String displayname = identity.getString(
15
			String displayname = identity.getString(
17
				ISemanticContext.CONTEXT_ATTR_DISPLAY_NAME,
16
					ISemanticContext.CONTEXT_ATTR_DISPLAY_NAME,
18
				ISemanticContext.CONTEXT_NAMESPACE_CORE);
17
					ISemanticContext.CONTEXT_NAMESPACE_CORE);
19
		if (emailAddress == null && displayname == null)
18
			if (emailAddress == null && displayname == null)
20
			return;
19
				return;
21
		List<ISearchResult> temp;
20
			List<ISearchResult> temp;
22
		if (emailAddress != null) {
21
			if (emailAddress != null) {
23
			temp = searchProvider.query(emailAddress,
22
				temp = searchProvider.query(emailAddress,
24
					ContactSearchProvider.CRITERIA_EMAIL_CONTAINS, false, 
23
						ContactSearchProvider.CRITERIA_EMAIL_CONTAINS, false,
25
0, 5);
24
						0, 5);
26
			result.addAll(temp);
25
				result.addAll(temp);
27
		}
26
			}
28
		if (displayname != null) {
27
			if (displayname != null) {
29
			temp = searchProvider.query(displayname,
28
				temp = searchProvider.query(displayname,
30
			ContactSearchProvider.CRITERIA_DISPLAYNAME_CONTAINS, 
29
						ContactSearchProvider.CRITERIA_DISPLAYNAME_CONTAINS,
31
false, 0, 5);
30
						false, 0, 5);
32
			result.addAll(temp);
31
				result.addAll(temp);
33
		
32
			}
34
}
33
		}
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)1.2
Clones locationClones are in different classes
Number of node comparisons97
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements14
    Number of unmapped statements in the first code fragment4
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)44.7
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    IStructureValue value = context.getValue();
                                                                                            
    2
    if (value == null)
    2
    if (value == null)
    7
    if (identity == null)
    Differences
    Expression1Expression2Difference
    valueidentityVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression identity cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7
    if (identity == null)
    3
    return;
    3
    return;
    8
    return;
    Preondition Violations
    Conditional return;
    Conditional return;
    8
    return;
    4
    Iterator<IStructureValue> it = value.getChildIterator(ISemanticContext.CONTEXT_NODE_IDENTITY, ISemanticContext.CONTEXT_NAMESPACE_CORE);
                                                                                                                                                                                                                                                                                  
    5
    IStructureValue identity = it.next();
    6
    IStructureValue identity = it.next();
    6
    if (identity == null)
                                                  
    7
    return;
    7
    return;
    Preondition Violations
    Unmatched return;
                        
    8
    String emailAddress = identity.getString(ISemanticContext.CONTEXT_ATTR_EMAIL_ADDRESS, ISemanticContext.CONTEXT_NAMESPACE_CORE);
    9
    String emailAddress = identity.getString(ISemanticContext.CONTEXT_ATTR_EMAIL_ADDRESS, ISemanticContext.CONTEXT_NAMESPACE_CORE);
    9
    String displayname = identity.getString(ISemanticContext.CONTEXT_ATTR_DISPLAY_NAME, ISemanticContext.CONTEXT_NAMESPACE_CORE);
    10
    String displayname = identity.getString(ISemanticContext.CONTEXT_ATTR_DISPLAY_NAME, ISemanticContext.CONTEXT_NAMESPACE_CORE);
    10
    if (emailAddress == null && displayname == null)
    11
    if (emailAddress == null && displayname == null)
    11
    return;
    11
    return;
    12
    return;
    Preondition Violations
    Conditional return;
    Conditional return;
    12
    return;
    12
    List<ISearchResult> temp;
    13
    List<ISearchResult> temp;
    13
    if (emailAddress != null)
    14
    if (emailAddress != null)
    14
    temp = searchProvider.query(emailAddress, ContactSearchProvider.CRITERIA_EMAIL_CONTAINS, false, 0, 5);
    15
    temp = searchProvider.query(emailAddress, ContactSearchProvider.CRITERIA_EMAIL_CONTAINS, false, 0, 5);
    15
    result.addAll(temp);
    16
    result.addAll(temp);
    16
    if (displayname != null)
    17
    if (displayname != null)
    17
    temp = searchProvider.query(displayname, ContactSearchProvider.CRITERIA_DISPLAYNAME_CONTAINS, false, 0, 5);
    18
    temp = searchProvider.query(displayname, ContactSearchProvider.CRITERIA_DISPLAYNAME_CONTAINS, false, 0, 5);
    18
    result.addAll(temp);
    19
    result.addAll(temp);
    Precondition Violations (7)
    Row Violation
    1Expression identity cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Conditional return;
    3Conditional return;
    4Unmatched return;
    5Conditional return;
    6Conditional return;
    7Clone fragment #1 returns variables identity , while Clone fragment #2 returns variables