if (value == null || ((DerbyClobDescriptor) value).getData() == null) { pstmt.setNull(position, _colDef.getSqlType()); } else { // for convenience cast the object to ClobDescriptor DerbyClobDescriptor cdesc = (DerbyClobDescriptor) value; pstmt.setCharacterStream(position, new StringReader(cdesc.getData()), cdesc.getData().length()); }
if (value == null || ((BlobDescriptor)value).getData() == null) { pstmt.setNull(position, _colDef.getSqlType()); } else { // for convenience cast the object to BlobDescriptor BlobDescriptor bdesc = (BlobDescriptor)value; // There are a couple of possible ways to update the data in the DB. // The first is to use setString like this: // bdesc.getBlob().setString(0, bdesc.getData()); // However, the DB2 driver throws an exception saying that that function // is not implemented, so we have to use the other method, which is to use a stream. pstmt.setBinaryStream(position, new ByteArrayInputStream(bdesc.getData()), bdesc.getData().length); }
Clone fragments detected by clone detection tool
File path: /sql12/plugins/derby/src/net/sourceforge/squirrel_sql/plugins/derby/types/DerbyClobDataTypeComponent.java File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeBlob.java
Method name: void setPreparedStatementValue(PreparedStatement, Object, int) Method name: void setPreparedStatementValue(PreparedStatement, Object, int)
Number of AST nodes: 4 Number of AST nodes: 4
1
if (value == null || ((DerbyClobDescriptor) value).getData() == null) {
1
if (value == null || ((BlobDescriptor)value).getData() == null) {
2
         pstmt.setNull(position, _colDef.getSqlType());
2
			pstmt.setNull(position, _colDef.getSqlType());
3
      } else {
4
         
3
		}
4
		else {
5
// for convenience cast the object to ClobDescriptor
5
			// for convenience cast the object to BlobDescriptor
6
         DerbyClobDescriptor cdesc = (DerbyClobDescriptor) value;
6
			BlobDescriptor bdesc = (BlobDescriptor)value;
7
         pstmt.setCharacterStream(position,
8
                                  new StringReader(cdesc.getData()),
9
                                  c
7
			// There are a couple of possible ways to update the data in the DB.
8
			// The first is to use setString like this:
9
			//		bdesc.getBlob().setString(0, bdesc.getData());
10
			// However, the DB2 driver throws an exception saying that that function
11
			// is not implemented, so we have to use the other method, which is to use a stream.		
10
desc.getData().length());
12
			pstmt.setBinaryStream(position, new ByteArrayInputStream(bdesc.getData()), bdesc.getData().length);
11
      }
13
		}
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.4
Clones locationClones are in different classes having the same super class
Number of node comparisons16
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)10.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (value == null || ((DerbyClobDescriptor)value).getData() == null)
    1
    if (value == null || ((DerbyClobDescriptor)value).getData() == null)
    1
    if (value == null || ((BlobDescriptor)value).getData() == null)
    Differences
    Expression1Expression2Difference
    java.lang.Stringbyte[]VARIABLE_TYPE_MISMATCH
    net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptornet.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BlobDescriptorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.String of variable ((DerbyClobDescriptor)value).getData() does not match with type byte[] of variable ((BlobDescriptor)value).getData()
    • Make classes java.lang.String and byte[] extend a common superclass
    Type net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor does not match with type net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BlobDescriptor
    • Make classes net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor and net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BlobDescriptor extend a common superclass
    1
    if (value == null || ((BlobDescriptor)value).getData() == null)
    2
    pstmt.setNull(position, _colDef.getSqlType());
    2
    pstmt.setNull(position, _colDef.getSqlType());
    else
            
                                                                                                
    3
    BlobDescriptor bdesc = (BlobDescriptor)value;
    Preondition Violations
    Unmatched statement BlobDescriptor bdesc=(BlobDescriptor)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    BlobDescriptor bdesc = (BlobDescriptor)value;
    3
    DerbyClobDescriptor cdesc = (DerbyClobDescriptor)value;
    3
    DerbyClobDescriptor cdesc = (DerbyClobDescriptor)value;
    Preondition Violations
    Unmatched statement DerbyClobDescriptor cdesc=(DerbyClobDescriptor)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                    
                                                                                                                                                                                                            
    4
    pstmt.setBinaryStream(position, new ByteArrayInputStream(bdesc.getData()), bdesc.getData().length);
    Preondition Violations
    Unmatched statement pstmt.setBinaryStream(position,new ByteArrayInputStream(bdesc.getData()),bdesc.getData().length); 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
    pstmt.setBinaryStream(position, new ByteArrayInputStream(bdesc.getData()), bdesc.getData().length);
    4
    pstmt.setCharacterStream(position, new StringReader(cdesc.getData()), cdesc.getData().length());
    4
    pstmt.setCharacterStream(position, new StringReader(cdesc.getData()), cdesc.getData().length());
    Preondition Violations
    Unmatched statement pstmt.setCharacterStream(position,new StringReader(cdesc.getData()),cdesc.getData().length()); 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
                                                                                                                                                                                                      
    Precondition Violations (6)
    Row Violation
    1Type java.lang.String of variable ((DerbyClobDescriptor)value).getData() does not match with type byte[] of variable ((BlobDescriptor)value).getData()
    2Type net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor does not match with type net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BlobDescriptor
    3Unmatched statement BlobDescriptor bdesc=(BlobDescriptor)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement DerbyClobDescriptor cdesc=(DerbyClobDescriptor)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement pstmt.setBinaryStream(position,new ByteArrayInputStream(bdesc.getData()),bdesc.getData().length); 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
    6Unmatched statement pstmt.setCharacterStream(position,new StringReader(cdesc.getData()),cdesc.getData().length()); 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