for ( int indx = 0; indx < stringLength; indx++ ) { char c = string.charAt( indx ); if ( inQuote ) { if ( '\'' == c ) { inQuote = false; } } else if ( '\'' == c ) { inQuote = true; } else if ( c == character ) { count++; } }
for ( int indx = 0; indx < stringLength; indx++ ) { char c = string.charAt( indx ); if ( inQuote ) { if ( '\'' == c ) { inQuote = false; } } else if ( '\'' == c ) { inQuote = true; } else if ( c == character ) { locations.add( new Integer( indx ) ); } }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/util/StringHelper.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/util/StringHelper.java
Method name: int countUnquoted(String, char) Method name: int[] locateUnquoted(String, char)
Number of AST nodes: 9 Number of AST nodes: 9
1
for ( int indx = 0; indx < stringLength; indx++ ) {
1
for ( int indx = 0; indx < stringLength; indx++ ) {
2
			char c = string.charAt( indx );
2
			char c = string.charAt( indx );
3
			if ( inQuote ) {
3
			if ( inQuote ) {
4
				if ( '\'' == c ) {
4
				if ( '\'' == c ) {
5
					inQuote = false;
5
					inQuote = false;
6
				}
6
				}
7
			}
7
			}
8
			else if ( '\'' == c ) {
8
			else if ( '\'' == c ) {
9
				inQuote = true;
9
				inQuote = true;
10
			}
10
			}
11
			else if ( c == character ) {
11
			else if ( c == character ) {
12
				count++;
12
				locations.add( new Integer( indx ) );
13
			}
13
			}
14
		}
14
		}
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.6
Clones locationClones are declared in the same class
Number of node comparisons22
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    8
    for (int indx = 0; indx < stringLength; indx++)
    8
    for (int indx = 0; indx < stringLength; indx++)
    9
    char c = string.charAt(indx);
    9
    char c = string.charAt(indx);
    10
    if (inQuote)
    10
    if (inQuote)
    11
    if ('\'' == c)
    11
    if ('\'' == c)
    12
    inQuote = false;
    12
    inQuote = false;
    13
    else if ('\'' == c)
    13
    else if ('\'' == c)
    14
    inQuote = true;
    14
    inQuote = true;
    15
    else if (c == character)
    15
    else if (c == character)
                                                                              
    16
    locations.add(new Integer(indx));
    Preondition Violations
    Unmatched statement locations.add(new Integer(indx)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16
    locations.add(new Integer(indx));
    16
    count++;
    16
    count++;
    Preondition Violations
    Unmatched statement count++; 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
    1Unmatched statement locations.add(new Integer(indx)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement count++; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Clone fragment #1 returns variables , while Clone fragment #2 returns variables indx