StringBuffer result = new StringBuffer( 60 ).append( "\n " ); StringTokenizer tokens = new StringTokenizer( sql, " '[]\"", true ); boolean quoted = false; while ( tokens.hasMoreTokens() ) { String token = tokens.nextToken(); result.append( token ); if ( isQuote( token ) ) { quoted = !quoted; } else if ( !quoted ) { if ( "is".equals( token ) ) { result.append( "\n " ); } } } return result.toString();
StringBuffer result = new StringBuffer( 60 ).append( "\n " ); StringTokenizer tokens = new StringTokenizer( sql, " (,)'[]\"", true ); boolean quoted = false; while ( tokens.hasMoreTokens() ) { String token = tokens.nextToken(); if ( isQuote( token ) ) { quoted = !quoted; } else if ( !quoted ) { if ( isBreak( token ) ) { result.append( "\n " ); } } result.append( token ); } 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/jdbc/util/DDLFormatterImpl.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/jdbc/util/DDLFormatterImpl.java
Method name: String formatCommentOn(String) Method name: String formatAlterTable(String)
Number of AST nodes: 12 Number of AST nodes: 12
1
StringBuffer result = new StringBuffer( 60 ).append( "\n    " );
1
StringBuffer result = new StringBuffer( 60 ).append( "\n    " );
2
		StringTokenizer tokens = new StringTokenizer( sql, " '[]\"", true );
2
		StringTokenizer tokens = new StringTokenizer( sql, " (,)'[]\"", true );
3
		boolean quoted = false;
3
		boolean quoted = false;
4
		while ( tokens.hasMoreTokens() ) {
4
		while ( tokens.hasMoreTokens() ) {
5
			String token = tokens.nextToken();
5
			String token = tokens.nextToken();
6
			result.append( token );
6
			
7
			if ( isQuote( token ) ) {
7
if ( isQuote( token ) ) {
8
				quoted = !quoted;
8
				quoted = !quoted;
9
			}
9
			}
10
			else if ( !quoted ) {
10
			else if ( !quoted ) {
11
				if ( "is".equals( token ) ) {
11
				if ( isBreak( token ) ) {
12
					result.append( "\n       " );
12
					result.append( "\n        " );
13
				}
13
				}
14
			}
14
			}
15
		
15
			result.append( token );
16
}
16
		}
17
		return result.toString();
17
		return result.toString();
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.1
Clones locationClones are declared in the same class
Number of node comparisons23
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)2.7
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    StringBuffer result = new StringBuffer(60).append("\n    ");
    1
    StringBuffer result = new StringBuffer(60).append("\n    ");
    2
    StringTokenizer tokens = new StringTokenizer(sql, " '[]\"", true);
    2
    StringTokenizer tokens = new StringTokenizer(sql, " '[]\"", true);
    2
    StringTokenizer tokens = new StringTokenizer(sql, " (,)'[]\"", true);
    Differences
    Expression1Expression2Difference
    " '[]\""" (,)'[]\""LITERAL_VALUE_MISMATCH
    2
    StringTokenizer tokens = new StringTokenizer(sql, " (,)'[]\"", true);
    3
    boolean quoted = false;
    3
    boolean quoted = false;
    4
    while (tokens.hasMoreTokens())
    4
    while (tokens.hasMoreTokens())
    5
    String token = tokens.nextToken();
    5
    String token = tokens.nextToken();
    6
    result.append(token);
    11
    result.append(token);
    7
    if (isQuote(token))
    6
    if (isQuote(token))
    8
    quoted = !quoted;
    7
    quoted = !quoted;
                                
    8
    else if (!quoted)
    Preondition Violations
    Unmatched statement if(!quoted) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8
    else if (!quoted)
                                              
    9
    if (isBreak(token))
    Preondition Violations
    Unmatched statement if(isBreak(token)) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9
    if (isBreak(token))
                                                                    
    10
    result.append("\n ");
    Preondition Violations
    Unmatched statement result.append("\n "); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10
    result.append("\n        ");
    9
    else if (!quoted)
    9
    else if (!quoted)
    Preondition Violations
    Unmatched statement if(!quoted) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                
    10
    if ("is".equals(token))
    10
    if ("is".equals(token))
    Preondition Violations
    Unmatched statement if("is".equals(token)) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                        
    11
    result.append("\n       ");
    11
    result.append("\n ");
    Preondition Violations
    Unmatched statement result.append("\n "); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                  
    12
    return result.toString();
    12
    return result.toString();
    Precondition Violations (6)
    Row Violation
    1Unmatched statement if(!quoted) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement if(isBreak(token)) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement result.append("\n "); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement if(!quoted) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement if("is".equals(token)) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement result.append("\n "); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted