List types = new ArrayList( getLength() ); for ( int i=0; i<getLength(); i++ ) { Type[] elemTypes = getProjection(i).getTypes(criteria, criteriaQuery); ArrayHelper.addAll(types, elemTypes); } return ArrayHelper.toTypeArray(types);
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/criterion/ProjectionList.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/criterion/ProjectionList.java
Method name: Type[] getTypes(Criteria, CriteriaQuery) Method name: String[] getColumnAliases(int)
Number of AST nodes: 5 Number of AST nodes: 6
1
List types = new ArrayList( getLength() );
1
List result = new ArrayList( getLength() );
2
		for ( int i=0; i<getLength(); i++ ) {
2
		for ( int i=0; i<getLength(); i++ ) {
3
			Type[] elemTypes = getProjection(i).getTypes(criteria, criteriaQuery);
3
			String[] colAliases = getProjection(i).get
4
			ArrayHelper.addAll(types, elemTypes)
4
ColumnAliases(loc);
5
			ArrayHelper.addAll(result, colAliases);
5
;
6
			loc+=colAliases.length;
6
		}
7
		}
7
		return ArrayHelper.toTypeArray(types);
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.1
Clones locationClones are declared in the same class
Number of node comparisons14
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)4.4
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    List types = new ArrayList(getLength());
    1
    List types = new ArrayList(getLength());
    1
    List result = new ArrayList(getLength());
    Differences
    Expression1Expression2Difference
    typesresultVARIABLE_NAME_MISMATCH
    1
    List result = new ArrayList(getLength());
    2
    for (int i = 0; i < getLength(); i++)
    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);
    3
    Type[] elemTypes = getProjection(i).getTypes(criteria, criteriaQuery);
    3
    Type[] elemTypes = getProjection(i).getTypes(criteria, criteriaQuery);
    Preondition Violations
    Unmatched statement Type[] elemTypes=getProjection(i).getTypes(criteria,criteriaQuery); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement Type[] elemTypes=getProjection(i).getTypes(criteria,criteriaQuery); 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
                                                                                                                                                
    4
    ArrayHelper.addAll(types, elemTypes);
    4
    ArrayHelper.addAll(types, elemTypes);
    4
    ArrayHelper.addAll(result, colAliases);
    Differences
    Expression1Expression2Difference
    typesresultVARIABLE_NAME_MISMATCH
    elemTypescolAliasesVARIABLE_NAME_MISMATCH
    org.hibernate.type.Type[]java.lang.String[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.type.Type[] of variable elemTypes does not match with type java.lang.String[] of variable colAliases
    • Make classes org.hibernate.type.Type[] and java.lang.String[] extend a common superclass
    4
    ArrayHelper.addAll(result, colAliases);
                                                        
    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 ArrayHelper.toTypeArray(types);
    5
    return ArrayHelper.toTypeArray(types);
    Preondition Violations
    Unmatched statement return ArrayHelper.toTypeArray(types); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched return ArrayHelper.toTypeArray(types);
                                                                                      
                                                                                            
    6
    return ArrayHelper.toStringArray(result);
    Preondition Violations
    Unmatched statement return ArrayHelper.toStringArray(result); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched return ArrayHelper.toStringArray(result);
    6
    return ArrayHelper.toStringArray(result);
    Precondition Violations (10)
    Row Violation
    1Unmatched 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
    2Unmatched statement Type[] elemTypes=getProjection(i).getTypes(criteria,criteriaQuery); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement Type[] elemTypes=getProjection(i).getTypes(criteria,criteriaQuery); 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
    4Type org.hibernate.type.Type[] of variable elemTypes does not match with type java.lang.String[] of variable colAliases
    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 statement return ArrayHelper.toTypeArray(types); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched return ArrayHelper.toTypeArray(types);
    8Unmatched statement return ArrayHelper.toStringArray(result); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched return ArrayHelper.toStringArray(result);
    10Clone fragment #1 returns variables i, types , while Clone fragment #2 returns variables i, result