int length = bag.size(); Serializable[] result = new Serializable[length]; for ( int i=0; i<length; i++ ) { result[i] = persister.getElementType().disassemble( bag.get(i), getSession(), null ); } return result;
List result = new ArrayList( getLength() ); for ( int i=0; i<getLength(); i++ ) { String[] colAliases = getProjection(i).getColumnAliases(loc); ArrayHelper.addAll(result, colAliases); loc+=colAliases.length; } return ArrayHelper.toStringArray(result);
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/collection/PersistentBag.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/criterion/ProjectionList.java
Method name: Serializable disassemble(CollectionPersister) Method name: String[] getColumnAliases(int)
Number of AST nodes: 5 Number of AST nodes: 6
1
int length = bag.size();
2
		Serializable[] result = new Serializable[length];
1
List result = new ArrayList( getLength() );
3
		for ( int i=0; i<length; i++ ) {
2
		for ( int i=0; i<getLength(); i++ ) {
4
			result[i] = persister.getElementType().disassemble( bag.get(i), getSession(), null );
3
			
5
		}
6
		return 
4
String[] colAliases = getProjection(i).getColumnAliases(loc);
5
			ArrayHelper.addAll(result, colAliases);
6
			loc+=colAliases.length;
7
		}
7
result;
8
		return ArrayHelper.toStringArray(result);
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.2
Clones locationClones are in different classes
Number of node comparisons14
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment4
    Number of unmapped statements in the second code fragment5
    Time elapsed for statement mapping (ms)1.4
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                        
    1
    List result = new ArrayList(getLength());
    1
    int length = bag.size();
                                                      
    2
    Serializable[] result = new Serializable[length];
                                                                                                        
    3
    for (int i = 0; i < length; i++)
    3
    for (int i = 0; i < length; i++)
    2
    for (int i = 0; i < getLength(); i++)
    Differences
    Expression1Expression2Difference
    lengthgetLength()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression length cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2
    for (int i = 0; i < getLength(); i++)
                                                                                                                                
    3
    String[] colAliases = getProjection(i).getColumnAliases(loc);
    Preondition Violations
    Unmatched statement String[] colAliases=getProjection(i).getColumnAliases(loc); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    String[] colAliases = getProjection(i).getColumnAliases(loc);
                                                                                      
    4
    ArrayHelper.addAll(result, colAliases);
    4
    result[i] = persister.getElementType().disassemble(bag.get(i), getSession(), null);
    4
    result[i] = persister.getElementType().disassemble(bag.get(i), getSession(), null);
    Preondition Violations
    Unmatched statement result[i]=persister.getElementType().disassemble(bag.get(i),getSession(),null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement result[i]=persister.getElementType().disassemble(bag.get(i),getSession(),null); 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
                                                                                                                                                                        
                                                        
    5
    loc += colAliases.length;
    Preondition Violations
    Unmatched statement loc+=colAliases.length; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    loc += colAliases.length;
    5
    return result;
    5
    return result;
    Preondition Violations
    Unmatched return result;
                                      
                                                                                            
    6
    return ArrayHelper.toStringArray(result);
    Preondition Violations
    Unmatched return ArrayHelper.toStringArray(result);
    6
    return ArrayHelper.toStringArray(result);
    Precondition Violations (8)
    Row Violation
    1Expression length cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Unmatched statement String[] colAliases=getProjection(i).getColumnAliases(loc); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement result[i]=persister.getElementType().disassemble(bag.get(i),getSession(),null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement result[i]=persister.getElementType().disassemble(bag.get(i),getSession(),null); 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
    5Unmatched statement loc+=colAliases.length; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched return result;
    7Unmatched return ArrayHelper.toStringArray(result);
    8The refactoring of the clones is infeasible, because the number of macthed statements is equal to zero