Element child = getParentElement().getChild(VCARD.TEL); if (child == null) { child = new Element(VCARD.TEL); getParentElement().addContent(child); } Element prefixchild = new Element(m.getTypeString()); child.addContent(prefixchild); prefixchild.setText(m.getNumber());
Element child = getParentElement().getChild(VCARD.EMAIL); if (child == null) { child = new Element(VCARD.EMAIL); getParentElement().addContent(child); } // create <type> element Element prefixchild = new Element(model.getTypeString()); child.addContent(prefixchild); prefixchild.setText(model.getAddress());
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/contact/src/main/java/org/columba/addressbook/parser/XMLContactDocumentParser.java File path: /columba-1.4-src/contact/src/main/java/org/columba/addressbook/parser/XMLContactDocumentParser.java
Method name: void addPhone(PhoneModel) Method name: void addEmail(IEmailModel)
Number of AST nodes: 7 Number of AST nodes: 7
1
Element child = getParentElement().getChild(VCARD.TEL);
1
Element child = getParentElement().getChild(VCARD.EMAIL);
2
		if (child == null) {
2
		if (child == null) {
3
			child = new Element(VCARD.TEL);
3
			child = new Element(VCARD.EMAIL);
4
			getParentElement().addContent(child);
4
			getParentElement().addContent(child);
5
		}
5
		}
6
		// create <type> element
6
		Element prefixchild = new Element(m.getTypeString());
7
		Element prefixchild = new Element(model.getTypeString());
7
		child.addContent(prefixchild);
8
		child.addContent(prefixchild);
8
		prefixchild.setText(m.getNumber());
9
		prefixchild.setText(model.getAddress());
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.1
Clones locationClones are declared in the same class
Number of node comparisons19
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)2.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Element child = getParentElement().getChild(VCARD.TEL);
    1
    Element child = getParentElement().getChild(VCARD.TEL);
    1
    Element child = getParentElement().getChild(VCARD.EMAIL);
    Differences
    Expression1Expression2Difference
    TELEMAILVARIABLE_NAME_MISMATCH
    1
    Element child = getParentElement().getChild(VCARD.EMAIL);
    2
    if (child == null)
    2
    if (child == null)
    3
    child = new Element(VCARD.TEL);
    3
    child = new Element(VCARD.TEL);
    3
    child = new Element(VCARD.EMAIL);
    Differences
    Expression1Expression2Difference
    TELEMAILVARIABLE_NAME_MISMATCH
    3
    child = new Element(VCARD.EMAIL);
    4
    getParentElement().addContent(child);
    4
    getParentElement().addContent(child);
    5
    Element prefixchild = new Element(m.getTypeString());
    5
    Element prefixchild = new Element(m.getTypeString());
    5
    Element prefixchild = new Element(model.getTypeString());
    Differences
    Expression1Expression2Difference
    mmodelVARIABLE_NAME_MISMATCH
    org.columba.addressbook.model.PhoneModelorg.columba.addressbook.model.IEmailModelVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.columba.addressbook.model.PhoneModel of variable m does not match with type org.columba.addressbook.model.IEmailModel of variable model
    • Make classes org.columba.addressbook.model.PhoneModel and org.columba.addressbook.model.IEmailModel extend a common superclass
    5
    Element prefixchild = new Element(model.getTypeString());
    6
    child.addContent(prefixchild);
    6
    child.addContent(prefixchild);
                                                                                          
    7
    prefixchild.setText(model.getAddress());
    Preondition Violations
    Unmatched statement prefixchild.setText(model.getAddress()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    prefixchild.setText(model.getAddress());
    7
    prefixchild.setText(m.getNumber());
    7
    prefixchild.setText(m.getNumber());
    Preondition Violations
    Unmatched statement prefixchild.setText(m.getNumber()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                
    Precondition Violations (3)
    Row Violation
    1Type org.columba.addressbook.model.PhoneModel of variable m does not match with type org.columba.addressbook.model.IEmailModel of variable model
    2Unmatched statement prefixchild.setText(model.getAddress()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement prefixchild.setText(m.getNumber()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted