StringBuffer buf = new StringBuffer(); for (int colIdx = 0; colIdx < nbrSelCols; ++colIdx) { TableColumn col = _table.getColumnModel().getColumn(selCols[colIdx]); ColumnDisplayDefinition colDef = null; if(col instanceof ExtTableColumn) { colDef = ((ExtTableColumn) col).getColumnDisplayDefinition(); } int lastLength = buf.length(); buf.append("("); for (int rowIdx = 0; rowIdx < nbrSelRows; ++rowIdx) { if(0 < rowIdx) { buf.append(","); if(100 < buf.length() - lastLength) { lastLength = buf.length(); buf.append("\n"); } } final Object cellObj = _table.getValueAt(selRows[rowIdx], selCols[colIdx]); buf.append(getData(colDef, cellObj, StatType.IN)); } buf.append(")\n"); } final StringSelection ss = new StringSelection(buf.toString()); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, ss);
if (selRows.length != 0 && selCols.length != 0) { StringBuffer buf = new StringBuffer(); for (int rowIdx = 0; rowIdx < nbrSelRows; ++rowIdx) { buf.append("UPDATE PressCtrlH SET "); boolean firstCol = true; for (int colIdx = 0; colIdx < nbrSelCols; ++colIdx) { TableColumn col = _table.getColumnModel().getColumn(selCols[colIdx]); ColumnDisplayDefinition colDef = null; if(col instanceof ExtTableColumn) { colDef = ((ExtTableColumn) col).getColumnDisplayDefinition(); } else { continue; } if (firstCol) { firstCol = false; } else { buf.append(","); } final Object cellObj = _table.getValueAt(selRows[rowIdx], selCols[colIdx]); buf.append(colDef.getColumnName()).append(getData(colDef, cellObj, StatType.UPDATE)); } buf.append(" WHERE\n"); } final StringSelection ss = new StringSelection(buf.toString()); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, ss); }
Clone fragments detected by clone detection tool
File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/gui/action/TableCopyInStatementCommand.java File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/gui/action/TableCopyUpdateStatementCommand.java
Method name: void execute() Method name: void execute()
Number of AST nodes: 19 Number of AST nodes: 19
1
StringBuffer buf = new StringBuffer();
1
if (selRows.length != 0 && selCols.length != 0)
2
      {
3
         StringBuffer buf = new StringBuffer();
4
         for (int rowIdx = 0; rowIdx < nbrSelRows; ++rowIdx)
5
         {
6
            buf.append("UPDATE PressCtrlH SET ");
7
            boolean firstCol = true;
2
         for (int colIdx = 0; colIdx < nbrSelCols; ++colIdx)
8
            for (int colIdx = 0; colIdx < nbrSelCols; ++colIdx)
3
         {
9
         
10
   {
4
            TableColumn col = _table.getColumnModel().getColumn(selCols[colIdx]);
11
               TableColumn col = _table.getColumnModel().getColumn(selCols[colIdx]);
5
            ColumnDisplayDefinition colDef = null;
12
               ColumnDisplayDefinition colDef = null;
6
            if(col instanceof ExtTableColumn)
13
               if(col instanceof ExtTableColumn)
7
            {
14
               {
8
               colDef = ((ExtTableColumn) col).getColumnDisplayDefinition();
15
                  colDef = ((ExtTableColumn) col).getColumnDisplayDefinition();
9
            }
16
               }
10
            int lastLength = buf.length();
17
            
11
            buf.append("(");
12
            for (int rowIdx = 0; rowIdx < nbrSelRows; ++rowIdx)
18
   else
19
               {
20
                  continue;
13
            {
21
               }
14
               if(0 < rowIdx)
22
               if (firstCol)
15
               {
23
               {
16
                  buf.append(",");
24
                  
17
                  if(100 < buf.length() - lastLength)
25
firstCol = false;
18
                  {
26
               }
19
            
27
               else
20
         lastLength = buf.length(); 
28
         
21
   
29
      {
22
                  buf.append("\n");
30
                  buf.append(",");
23
                  }
24
               }
31
               }
25
               final Object cellObj = _table.getValueAt(selRows[rowIdx], selCols[colIdx]);
32
               final Object cellObj = _table.getValueAt(selRows[rowIdx], selCols[colIdx]);
26
               buf.append(getData(colDef, cellObj, StatType.IN));
33
               buf.append(colDef.getColumnName()).append(getData(colDef, cellObj, StatType.UPDATE));
27
            }
34
            }
28
            buf.append(")\n");
35
            buf.append(" WHERE\n");
29
         }
36
         }
30
         final StringSelection ss = new StringSelection(buf.toString());
37
         final StringSelection ss = new StringSelection(buf.toString());
31
         Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, ss);
38
         Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, ss);
39
      }
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.2
Clones locationClones are in different classes having the same super class
Number of node comparisons2