/** * Returns additional display text for the AST node. * * @return String - The additional display text. */ public String getDisplayText() { StringBuffer buf = new StringBuffer(); if ( getWalker().getQuerySpaces().size() > 0 ) { buf.append( " querySpaces (" ); for ( Iterator iterator = getWalker().getQuerySpaces().iterator(); iterator.hasNext(); ) { buf.append( iterator.next() ); if ( iterator.hasNext() ) { buf.append( "," ); } } buf.append( ")" ); } return buf.toString(); }
public String toStatementString() { StringBuffer buf = new StringBuffer( columns.size()*15 + tableName.length() + 10 ); if ( comment != null ) { buf.append( "/* " ).append( comment ).append( " */ " ); } buf.append("insert into ") .append(tableName); if ( columns.size()==0 ) { buf.append(' ').append( dialect.getNoColumnsInsertString() ); } else { buf.append(" ("); Iterator iter = columns.keySet().iterator(); while ( iter.hasNext() ) { buf.append( iter.next() ); if ( iter.hasNext() ) { buf.append( ", " ); } } buf.append(") values ("); iter = columns.values().iterator(); while ( iter.hasNext() ) { buf.append( iter.next() ); if ( iter.hasNext() ) { buf.append( ", " ); } } buf.append(')'); } return buf.toString(); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/hql/ast/tree/AbstractStatement.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/sql/Insert.java
Method name: String getDisplayText() Method name: String toStatementString()
Number of AST nodes: 4 Number of AST nodes: 4
1
/**
1
public String toStatementString() {
2
	 * Returns additional display text for the AST node.
2
		StringBuffer buf = new StringBuffer( columns.size()*15 + tableName.length() + 10 );
3
	 *
3
		if ( comment != null ) {
4
	 * @return String - The additional display text.
4
			buf.append( "/* " ).append( comment ).append( " */ " );
5
	 */
5
		}
6
	public String getDisplayText() {
6
		buf.append("insert into ")
7
		StringBuffer buf = new StringBuffer();
7
			.append(tableName);
8
		if ( getWalker().getQuerySpaces().size() > 0 ) {
8
		if ( columns.size()==0 ) {
9
			buf.append( " querySpaces (" );
9
			buf.append(' ').append( dialect.getNoColumnsInsertString() );
10
			for ( Iterator iterator = getWalker().getQuerySpaces().iterator(); iterator.hasNext(); ) {
10
		}
11
				buf.append( iterator.next() );
11
		else {
12
				if ( iterator.hasNext() ) {
12
			buf.append(" (");
13
					buf.append( "," );
13
			Iterator iter = columns.keySet().iterator();
14
				}
14
			while ( iter.hasNext() ) {
15
			}
15
				buf.append( iter.next() );
16
			buf.append( ")" );
16
				if ( iter.hasNext() ) {
17
		}
17
					buf.append( ", " );
18
		return buf.toString();
18
				}
19
	}
19
			}
20
			buf.append(") values (");
21
			iter = columns.values().iterator();
22
			while ( iter.hasNext() ) {
23
				buf.append( iter.next() );
24
				if ( iter.hasNext() ) {
25
					buf.append( ", " );
26
				}
27
			}
28
			buf.append(')');
29
		}
30
		return buf.toString();
31
	}
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Similarity Score1.000
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    4
    for (Iterator iterator = getWalker().getQuerySpaces().iterator(); iterator.hasNext(); )
    4
    for (Iterator iterator = getWalker().getQuerySpaces().iterator(); iterator.hasNext(); )
    9
    while (iter.hasNext())
    Differences
    Expression1Expression2Difference
    iteratoriterVARIABLE_NAME_MISMATCH
    getQuerySpaceskeySetMETHOD_INVOCATION_NAME_MISMATCH
    getWalker()columnsAST_TYPE_MISMATCH
    9
    while (iter.hasNext())
    5
    buf.append(iterator.next());
    5
    buf.append(iterator.next());
    10
    buf.append(iter.next());
    Differences
    Expression1Expression2Difference
    iteratoriterVARIABLE_NAME_MISMATCH
    10
    buf.append(iter.next());
    6
    if (iterator.hasNext())
    6
    if (iterator.hasNext())
    11
    if (iter.hasNext())
    Differences
    Expression1Expression2Difference
    iteratoriterVARIABLE_NAME_MISMATCH
    11
    if (iter.hasNext())
    7
    buf.append(",");
    7
    buf.append(",");
    12
    buf.append(", ");
    Differences
    Expression1Expression2Difference
    ","", "LITERAL_VALUE_MISMATCH
    12
    buf.append(", ");
    Precondition Violations (0)
    Row Violation