while (it.hasNext()) { BasicModelPartial headerItem = (BasicModelPartial) it.next(); if (headerItem.isContact()) { // contacts item ContactModelPartial item = (ContactModelPartial) headerItem; addAddress(item.getName(), item); addAddress(item.getLastname(), item); addAddress(item.getFirstname(), item); addAddress(item.getAddress(), item); } else { if (includeGroup) { // group item GroupModelPartial item = (GroupModelPartial) headerItem; addAddress(item.getName(), item); } } }
while (it.hasNext()) { IHeaderItem headerItem = it.next(); if (headerItem.isContact()) { // contacts item IContactItem item = (IContactItem) headerItem; addAddress(item.getName(), item); addAddress(item.getFirstName(), item); addAddress(item.getLastName(), item); addAddress(item.getEmailAddress(), item); } else { if (includeGroup) { // group item IGroupItem item = (IGroupItem) headerItem; addAddress(item.getName(), item); } } }
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/contact/src/main/java/org/columba/addressbook/gui/autocomplete/AddressCollector.java File path: /columba-1.4-src/mail/src/main/java/org/columba/mail/gui/composer/util/AddressCollector.java
Method name: void addAllContacts(String, boolean) Method name: void addAllContacts(List, boolean)
Number of AST nodes: 11 Number of AST nodes: 11
1
while (it.hasNext()) {
1
while (it.hasNext()) {
2
			BasicModelPartial headerItem = (BasicModelPartial) it.next();
2
			IHeaderItem headerItem = it.next();
3
			if (headerItem.isContact()) {
3
			if (headerItem.isContact()) {
4
				// contacts item
4
				// contacts item
5
				ContactModelPartial item = (ContactModelPartial) headerItem;
5
				IContactItem item = (IContactItem) headerItem;
6
				addAddress(item.getName(), item);
6
				addAddress(item.getName(), item);
7
				addAddress(item.getLastname(), item);
7
				addAddress(item.getFirstName(), item);
8
				addAddress(item.getFirstname(), item);
8
				addAddress(item.getLastName(), item);
9
				addAddress(item.getAddress(), item);
9
				addAddress(item.getEmailAddress(), item);
10
			} else {
10
			} else {
11
				if (includeGroup) {
11
				if (includeGroup) {
12
					// group item
12
					// group item
13
					GroupModelPartial item = (GroupModelPartial) headerItem;
13
					IGroupItem item = (IGroupItem) headerItem;
14
					addAddress(item.getName(), item);
14
					addAddress(item.getName(), item);
15
				}
15
				}
16
			}
16
			}
17
		}
17
		}
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)0.5
Clones locationClones are in different classes
Number of node comparisons49
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)26.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    16
    while (it.hasNext())
    16
    while (it.hasNext())
    4
    while (it.hasNext())
    Differences
    Expression1Expression2Difference
    java.util.Iteratorjava.util.IteratorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Iterator of variable it does not match with type java.util.Iterator<org.columba.addressbook.facade.IHeaderItem> of variable it
    • Make classes java.util.Iterator and java.util.Iterator extend a common superclass
    4
    while (it.hasNext())
                                                                            
    5
    IHeaderItem headerItem = it.next();
    Preondition Violations
    Unmatched statement IHeaderItem headerItem=it.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    IHeaderItem headerItem = it.next();
    17
    BasicModelPartial headerItem = (BasicModelPartial)it.next();
    17
    BasicModelPartial headerItem = (BasicModelPartial)it.next();
    Preondition Violations
    Unmatched statement BasicModelPartial headerItem=(BasicModelPartial)it.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                
    18
    if (headerItem.isContact())
    18
    if (headerItem.isContact())
    6
    if (headerItem.isContact())
    Differences
    Expression1Expression2Difference
    org.columba.addressbook.model.BasicModelPartialorg.columba.addressbook.facade.IHeaderItemVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.columba.addressbook.model.BasicModelPartial of variable headerItem does not match with type org.columba.addressbook.facade.IHeaderItem of variable headerItem
    • Make classes org.columba.addressbook.model.BasicModelPartial and org.columba.addressbook.facade.IHeaderItem extend a common superclass
    6
    if (headerItem.isContact())
                                                                                                
    7
    IContactItem item = (IContactItem)headerItem;
    Preondition Violations
    Unmatched statement IContactItem item=(IContactItem)headerItem; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    IContactItem item = (IContactItem)headerItem;
    19
    ContactModelPartial item = (ContactModelPartial)headerItem;
    19
    ContactModelPartial item = (ContactModelPartial)headerItem;
    Preondition Violations
    Unmatched statement ContactModelPartial item=(ContactModelPartial)headerItem; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                              
    20
    addAddress(item.getName(), item);
    20
    addAddress(item.getName(), item);
    8
    addAddress(item.getName(), item);
    Differences
    Expression1Expression2Difference
    org.columba.addressbook.model.ContactModelPartialorg.columba.addressbook.facade.IContactItemVARIABLE_TYPE_MISMATCH
    org.columba.addressbook.model.ContactModelPartialorg.columba.addressbook.facade.IContactItemVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.columba.addressbook.model.ContactModelPartial of variable item does not match with type org.columba.addressbook.facade.IContactItem of variable item
    • Make classes org.columba.addressbook.model.ContactModelPartial and org.columba.addressbook.facade.IContactItem extend a common superclass
    Type org.columba.addressbook.model.ContactModelPartial of variable item does not match with type org.columba.addressbook.facade.IContactItem of variable item
    • Make classes org.columba.addressbook.model.ContactModelPartial and org.columba.addressbook.facade.IContactItem extend a common superclass
    8
    addAddress(item.getName(), item);
    21
    addAddress(item.getLastname(), item);
    21
    addAddress(item.getLastname(), item);
    9
    addAddress(item.getFirstName(), item);
    Differences
    Expression1Expression2Difference
    getLastnamegetFirstNameMETHOD_INVOCATION_NAME_MISMATCH
    org.columba.addressbook.model.ContactModelPartialorg.columba.addressbook.facade.IContactItemVARIABLE_TYPE_MISMATCH
    org.columba.addressbook.model.ContactModelPartialorg.columba.addressbook.facade.IContactItemVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression item.getLastname() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression item.getFirstName() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.columba.addressbook.model.ContactModelPartial of variable item does not match with type org.columba.addressbook.facade.IContactItem of variable item
    • Make classes org.columba.addressbook.model.ContactModelPartial and org.columba.addressbook.facade.IContactItem extend a common superclass
    Type org.columba.addressbook.model.ContactModelPartial of variable item does not match with type org.columba.addressbook.facade.IContactItem of variable item
    • Make classes org.columba.addressbook.model.ContactModelPartial and org.columba.addressbook.facade.IContactItem extend a common superclass
    9
    addAddress(item.getFirstName(), item);
    22
    addAddress(item.getFirstname(), item);
    22
    addAddress(item.getFirstname(), item);
    10
    addAddress(item.getLastName(), item);
    Differences
    Expression1Expression2Difference
    getFirstnamegetLastNameMETHOD_INVOCATION_NAME_MISMATCH
    org.columba.addressbook.model.ContactModelPartialorg.columba.addressbook.facade.IContactItemVARIABLE_TYPE_MISMATCH
    org.columba.addressbook.model.ContactModelPartialorg.columba.addressbook.facade.IContactItemVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression item.getFirstname() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression item.getLastName() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.columba.addressbook.model.ContactModelPartial of variable item does not match with type org.columba.addressbook.facade.IContactItem of variable item
    • Make classes org.columba.addressbook.model.ContactModelPartial and org.columba.addressbook.facade.IContactItem extend a common superclass
    Type org.columba.addressbook.model.ContactModelPartial of variable item does not match with type org.columba.addressbook.facade.IContactItem of variable item
    • Make classes org.columba.addressbook.model.ContactModelPartial and org.columba.addressbook.facade.IContactItem extend a common superclass
    10
    addAddress(item.getLastName(), item);
    23
    addAddress(item.getAddress(), item);
    23
    addAddress(item.getAddress(), item);
    11
    addAddress(item.getEmailAddress(), item);
    Differences
    Expression1Expression2Difference
    getAddressgetEmailAddressMETHOD_INVOCATION_NAME_MISMATCH
    org.columba.addressbook.model.ContactModelPartialorg.columba.addressbook.facade.IContactItemVARIABLE_TYPE_MISMATCH
    org.columba.addressbook.model.ContactModelPartialorg.columba.addressbook.facade.IContactItemVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression item.getAddress() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression item.getEmailAddress() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.columba.addressbook.model.ContactModelPartial of variable item does not match with type org.columba.addressbook.facade.IContactItem of variable item
    • Make classes org.columba.addressbook.model.ContactModelPartial and org.columba.addressbook.facade.IContactItem extend a common superclass
    Type org.columba.addressbook.model.ContactModelPartial of variable item does not match with type org.columba.addressbook.facade.IContactItem of variable item
    • Make classes org.columba.addressbook.model.ContactModelPartial and org.columba.addressbook.facade.IContactItem extend a common superclass
    11
    addAddress(item.getEmailAddress(), item);
    else
    else
    24
    if (includeGroup)
    12
    if (includeGroup)
                                                                                          
    13
    IGroupItem item = (IGroupItem)headerItem;
    Preondition Violations
    Unmatched statement IGroupItem item=(IGroupItem)headerItem; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13
    IGroupItem item = (IGroupItem)headerItem;
    25
    GroupModelPartial item = (GroupModelPartial)headerItem;
    25
    GroupModelPartial item = (GroupModelPartial)headerItem;
    Preondition Violations
    Unmatched statement GroupModelPartial item=(GroupModelPartial)headerItem; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                      
    26
    addAddress(item.getName(), item);
    26
    addAddress(item.getName(), item);
    14
    addAddress(item.getName(), item);
    Differences
    Expression1Expression2Difference
    org.columba.addressbook.model.GroupModelPartialorg.columba.addressbook.facade.IGroupItemVARIABLE_TYPE_MISMATCH
    org.columba.addressbook.model.GroupModelPartialorg.columba.addressbook.facade.IGroupItemVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.columba.addressbook.model.GroupModelPartial of variable item does not match with type org.columba.addressbook.facade.IGroupItem of variable item
    • Make classes org.columba.addressbook.model.GroupModelPartial and org.columba.addressbook.facade.IGroupItem extend a common superclass
    Type org.columba.addressbook.model.GroupModelPartial of variable item does not match with type org.columba.addressbook.facade.IGroupItem of variable item
    • Make classes org.columba.addressbook.model.GroupModelPartial and org.columba.addressbook.facade.IGroupItem extend a common superclass
    14
    addAddress(item.getName(), item);
    Precondition Violations (24)
    Row Violation
    1Type java.util.Iterator of variable it does not match with type java.util.Iterator<org.columba.addressbook.facade.IHeaderItem> of variable it
    2Unmatched statement IHeaderItem headerItem=it.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement BasicModelPartial headerItem=(BasicModelPartial)it.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Type org.columba.addressbook.model.BasicModelPartial of variable headerItem does not match with type org.columba.addressbook.facade.IHeaderItem of variable headerItem
    5Unmatched statement IContactItem item=(IContactItem)headerItem; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement ContactModelPartial item=(ContactModelPartial)headerItem; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Type org.columba.addressbook.model.ContactModelPartial of variable item does not match with type org.columba.addressbook.facade.IContactItem of variable item
    8Type org.columba.addressbook.model.ContactModelPartial of variable item does not match with type org.columba.addressbook.facade.IContactItem of variable item
    9Expression item.getLastname() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression item.getFirstName() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Type org.columba.addressbook.model.ContactModelPartial of variable item does not match with type org.columba.addressbook.facade.IContactItem of variable item
    12Type org.columba.addressbook.model.ContactModelPartial of variable item does not match with type org.columba.addressbook.facade.IContactItem of variable item
    13Expression item.getFirstname() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression item.getLastName() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Type org.columba.addressbook.model.ContactModelPartial of variable item does not match with type org.columba.addressbook.facade.IContactItem of variable item
    16Type org.columba.addressbook.model.ContactModelPartial of variable item does not match with type org.columba.addressbook.facade.IContactItem of variable item
    17Expression item.getAddress() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression item.getEmailAddress() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Type org.columba.addressbook.model.ContactModelPartial of variable item does not match with type org.columba.addressbook.facade.IContactItem of variable item
    20Type org.columba.addressbook.model.ContactModelPartial of variable item does not match with type org.columba.addressbook.facade.IContactItem of variable item
    21Unmatched statement IGroupItem item=(IGroupItem)headerItem; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22Unmatched statement GroupModelPartial item=(GroupModelPartial)headerItem; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    23Type org.columba.addressbook.model.GroupModelPartial of variable item does not match with type org.columba.addressbook.facade.IGroupItem of variable item
    24Type org.columba.addressbook.model.GroupModelPartial of variable item does not match with type org.columba.addressbook.facade.IGroupItem of variable item