TreeMap clonedMap = new TreeMap(comparator); Iterator iter = map.entrySet().iterator(); while ( iter.hasNext() ) { Map.Entry e = (Map.Entry) iter.next(); clonedMap.put( e.getKey(), persister.getElementType().deepCopy( e.getValue(), entityMode, persister.getFactory() ) ); } return clonedMap;
Map result = new HashMap(); Iterator iter = namedTypedValues.entrySet().iterator(); while ( iter.hasNext() ) { Map.Entry me = (Map.Entry) iter.next(); TypedValue tv = (TypedValue) me.getValue(); result.put( me.getKey(), tv.getType().toLoggableString( tv.getValue(), factory ) ); } return result.toString();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/collection/PersistentSortedMap.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/pretty/Printer.java
Method name: Serializable snapshot(BasicCollectionPersister, EntityMode) Method name: String toString(Map)
Number of AST nodes: 6 Number of AST nodes: 7
1
TreeMap clonedMap = new TreeMap(comparator);
1
Map result = new HashMap();
2
		Iterator iter = map.entrySet().iterator();
2
		Iterator iter = namedTypedValues.entrySet().iterator();
3
		while ( iter.hasNext() ) {
3
		while ( iter.hasNext() ) {
4
			Map.Entry e = (Map.Entry) iter.next();
4
			Map.Entry me = (Map.Entry) iter.next();
5
			clonedMap
5
			TypedValue tv = (TypedValue) me.getValue();
6
.put( e.getKey(), persister.getElementType().deepCopy( e.getValue(), entityMode, persister.getFactory() ) );
6
			result.put( me.getKey(), tv.getType().toLoggableString( tv.getValue(), factory ) );
7
		}
7
		}
8
		return clonedMap;
8
		return result.toString();
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 in different classes
Number of node comparisons17
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)15.7
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    TreeMap clonedMap = new TreeMap(comparator);
    1
    TreeMap clonedMap = new TreeMap(comparator);
    1
    Map result = new HashMap();
    Differences
    Expression1Expression2Difference
    java.util.TreeMapjava.util.MapSUBCLASS_TYPE_MISMATCH
    clonedMapresultVARIABLE_NAME_MISMATCH
    java.util.TreeMapjava.util.MapSUBCLASS_TYPE_MISMATCH
    java.util.TreeMapjava.util.HashMapSUBCLASS_TYPE_MISMATCH
    new TreeMap(comparator)new HashMap()ARGUMENT_NUMBER_MISMATCH
    1
    Map result = new HashMap();
    2
    Iterator iter = map.entrySet().iterator();
    2
    Iterator iter = map.entrySet().iterator();
    2
    Iterator iter = namedTypedValues.entrySet().iterator();
    Differences
    Expression1Expression2Difference
    mapnamedTypedValuesVARIABLE_NAME_MISMATCH
    2
    Iterator iter = namedTypedValues.entrySet().iterator();
    3
    while (iter.hasNext())
    3
    while (iter.hasNext())
    4
    Map.Entry e = (Map.Entry)iter.next();
    4
    Map.Entry e = (Map.Entry)iter.next();
    4
    Map.Entry me = (Map.Entry)iter.next();
    Differences
    Expression1Expression2Difference
    emeVARIABLE_NAME_MISMATCH
    4
    Map.Entry me = (Map.Entry)iter.next();
                                                                                          
    5
    TypedValue tv = (TypedValue)me.getValue();
    Preondition Violations
    Unmatched statement TypedValue tv=(TypedValue)me.getValue(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    TypedValue tv = (TypedValue)me.getValue();
    5
    clonedMap.put(e.getKey(), persister.getElementType().deepCopy(e.getValue(), entityMode, persister.getFactory()));
    5
    clonedMap.put(e.getKey(), persister.getElementType().deepCopy(e.getValue(), entityMode, persister.getFactory()));
    Preondition Violations
    Unmatched statement clonedMap.put(e.getKey(),persister.getElementType().deepCopy(e.getValue(),entityMode,persister.getFactory())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement clonedMap.put(e.getKey(),persister.getElementType().deepCopy(e.getValue(),entityMode,persister.getFactory())); 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
                                                                                                                                                                                                                                      
                                                                                                                                                                    
    6
    result.put(me.getKey(), tv.getType().toLoggableString(tv.getValue(), factory));
    Preondition Violations
    Unmatched statement result.put(me.getKey(),tv.getType().toLoggableString(tv.getValue(),factory)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement result.put(me.getKey(),tv.getType().toLoggableString(tv.getValue(),factory)); 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
    6
    result.put(me.getKey(), tv.getType().toLoggableString(tv.getValue(), factory));
    6
    return clonedMap;
    6
    return clonedMap;
    Preondition Violations
    Unmatched statement return clonedMap; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched return clonedMap;
                                            
                                                            
    7
    return result.toString();
    Preondition Violations
    Unmatched statement return result.toString(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched return result.toString();
    7
    return result.toString();
    Precondition Violations (10)
    Row Violation
    1Unmatched statement TypedValue tv=(TypedValue)me.getValue(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement clonedMap.put(e.getKey(),persister.getElementType().deepCopy(e.getValue(),entityMode,persister.getFactory())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement clonedMap.put(e.getKey(),persister.getElementType().deepCopy(e.getValue(),entityMode,persister.getFactory())); 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
    4Unmatched statement result.put(me.getKey(),tv.getType().toLoggableString(tv.getValue(),factory)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement result.put(me.getKey(),tv.getType().toLoggableString(tv.getValue(),factory)); 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
    6Unmatched statement return clonedMap; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched return clonedMap;
    8Unmatched statement return result.toString(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched return result.toString();
    10Clone fragment #1 returns variables clonedMap, e , while Clone fragment #2 returns variables me, result