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.8
Clones locationClones are in different classes
Number of node comparisons71
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements12
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)25.8
    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 value cannot be parameterized, because it has dependencies to/from statements that will be extracted
    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);
    4
    Iterator<IStructureValue> it = value.getChildIterator(ISemanticContext.CONTEXT_NODE_IDENTITY, ISemanticContext.CONTEXT_NAMESPACE_CORE);
    Preondition Violations
    Unmatched statement Iterator<IStructureValue> it=value.getChildIterator(ISemanticContext.CONTEXT_NODE_IDENTITY,ISemanticContext.CONTEXT_NAMESPACE_CORE); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                                                                                                                                                                  
    5
    IStructureValue identity = it.next();
    6
    IStructureValue identity = it.next();
    6
    if (identity == null)
    6
    if (identity == null)
    11
    if (emailAddress == null && displayname == null)
    Differences
    Expression1Expression2Difference
    ==&&OPERATOR_MISMATCH
    identityemailAddress == nullINFIX_LEFT_OPERAND_MISMATCH
    nulldisplayname == nullINFIX_RIGHT_OPERAND_MISMATCH
    Preondition Violations
    Expression identity == null cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression emailAddress == null && displayname == null cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11
    if (emailAddress == null && displayname == null)
    7
    return;
    7
    return;
    12
    return;
    Preondition Violations
    Conditional return;
    Conditional return;
    12
    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)
    10
    if (emailAddress == null && displayname == null)
    14
    if (emailAddress != null)
    Differences
    Expression1Expression2Difference
    &&!=OPERATOR_MISMATCH
    emailAddress == nullemailAddressINFIX_LEFT_OPERAND_MISMATCH
    displayname == nullnullINFIX_RIGHT_OPERAND_MISMATCH
    Preondition Violations
    Expression emailAddress == null && displayname == null cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression emailAddress != null cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14
    if (emailAddress != null)
    11
    return;
    11
    return;
    Preondition Violations
    Unmatched return;
                          
                                                                                                                                                                                                            
    15
    temp = searchProvider.query(emailAddress, ContactSearchProvider.CRITERIA_EMAIL_CONTAINS, false, 0, 5);
    Preondition Violations
    Unmatched statement temp=searchProvider.query(emailAddress,ContactSearchProvider.CRITERIA_EMAIL_CONTAINS,false,0,5); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement temp=searchProvider.query(emailAddress,ContactSearchProvider.CRITERIA_EMAIL_CONTAINS,false,0,5); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    15
    temp = searchProvider.query(emailAddress, ContactSearchProvider.CRITERIA_EMAIL_CONTAINS, false, 0, 5);
                                                    
    16
    result.addAll(temp);
    Preondition Violations
    Unmatched statement result.addAll(temp); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    16
    result.addAll(temp);
    12
    List<ISearchResult> temp;
    13
    List<ISearchResult> temp;
    13
    if (emailAddress != null)
    13
    if (emailAddress != null)
    17
    if (displayname != null)
    Differences
    Expression1Expression2Difference
    emailAddressdisplaynameVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression emailAddress cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression displayname cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17
    if (displayname != null)
    14
    temp = searchProvider.query(emailAddress, ContactSearchProvider.CRITERIA_EMAIL_CONTAINS, false, 0, 5);
    14
    temp = searchProvider.query(emailAddress, ContactSearchProvider.CRITERIA_EMAIL_CONTAINS, false, 0, 5);
    18
    temp = searchProvider.query(displayname, ContactSearchProvider.CRITERIA_DISPLAYNAME_CONTAINS, false, 0, 5);
    Differences
    Expression1Expression2Difference
    emailAddressdisplaynameVARIABLE_NAME_MISMATCH
    CRITERIA_EMAIL_CONTAINSCRITERIA_DISPLAYNAME_CONTAINSVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression emailAddress cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression displayname cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18
    temp = searchProvider.query(displayname, ContactSearchProvider.CRITERIA_DISPLAYNAME_CONTAINS, false, 0, 5);
    15
    result.addAll(temp);
    19
    result.addAll(temp);
    Precondition Violations (20)
    Row Violation
    1Expression value cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression identity cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Conditional return;
    4Conditional return;
    5Unmatched statement Iterator<IStructureValue> it=value.getChildIterator(ISemanticContext.CONTEXT_NODE_IDENTITY,ISemanticContext.CONTEXT_NAMESPACE_CORE); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Expression identity == null cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression emailAddress == null && displayname == null cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Conditional return;
    9Conditional return;
    10Expression emailAddress == null && displayname == null cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression emailAddress != null cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Unmatched return;
    13Unmatched statement temp=searchProvider.query(emailAddress,ContactSearchProvider.CRITERIA_EMAIL_CONTAINS,false,0,5); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Unmatched statement temp=searchProvider.query(emailAddress,ContactSearchProvider.CRITERIA_EMAIL_CONTAINS,false,0,5); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    15Unmatched statement result.addAll(temp); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    16Expression emailAddress cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression displayname cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression emailAddress cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression displayname cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Clone fragment #1 returns variables displayname, temp , while Clone fragment #2 returns variables