if ( DataTypeString.this._isNullable) { // user enters something when field is null if (text.equals("<null>")) { if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) { // delete when null => original value DataTypeString.this._textComponent.restoreText(); e.consume(); } else { // non-delete when null => clear field and add text DataTypeString.this._textComponent.updateText(""); // fall through to normal processing of this key stroke } } else { // for strings, a "blank" field is allowed, so only // switch to null when there is nothing left in the field // and user does delete if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) { if (text.length() == 0 ) { // about to delete last thing in field, so replace with null DataTypeString.this._textComponent.updateText("<null>"); e.consume(); } } } } else { // field is not nullable // handleNotNullableField(text, c, e, _textComponent); }
if (DerbyClobDataTypeComponent.this._isNullable) { // user enters something when field is null if (text.equals("<null>")) { if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) { // delete when null => original value DerbyClobDataTypeComponent.this._textComponent.restoreText(); e.consume(); } else { // non-delete when null => clear field and add text DerbyClobDataTypeComponent.this._textComponent.updateText(""); // fall through to normal processing of this key stroke } } else { // check for user deletes last thing in field if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) { if (text.length() <= 1) { // about to delete last thing in field, so replace with // null DerbyClobDataTypeComponent.this._textComponent.updateText("<null>"); e.consume(); } } } } else { // field is not nullable // handleNotNullableField(text, c, e, _textComponent); }
Clone fragments detected by clone detection tool
File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeString.java File path: /sql12/plugins/derby/src/net/sourceforge/squirrel_sql/plugins/derby/types/DerbyClobDataTypeComponent.java
Method name: void keyTyped(KeyEvent) Method name: void keyTyped(KeyEvent)
Number of AST nodes: 11 Number of AST nodes: 11
1
if ( DataTypeString.this._isNullable) {
1
if (DerbyClobDataTypeComponent.this._isNullable) {
2
				// user enters something when field is null
2
            // user enters something when field is null
3
				if (text.equals("<null>")) {
3
            if (text.equals("<null>")) {
4
					if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
4
               if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
5
						// delete when null => original value
5
                  // delete when null => original value
6
						DataTypeString.this._textComponent.restoreText();
7
						e.consume();
8
					}
9
					else {
10
						
6
                  DerbyClobDataTypeComponent.this._textComponent.restoreText();
7
                  e.consume();
8
               } else {
11
// non-delete when null => clear field and add text
9
                  // non-delete when null => clear field and add text
12
						DataTypeString.this._textComponent.updateText("");
10
                  DerbyClobDataTypeComponent.this._textComponent.updateText("");
13
						// fall through to normal processing of this key stroke
11
                  // fall through to normal processing of this key stroke
14
					}
15
				}
16
				else {
17
					// for strings, a "blank" field is allowed, so only
18
					// switch to null when there is nothing left in the field
19
					// and user does delete
20
					
12
               }
13
            } else {
14
               // check for user deletes last thing in field
21
if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
15
               if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
22
						if (text.length() == 0 ) {
23
							// about to delete last thing in field, so replace with null
24
							DataTypeString.this._textComponent.updateText("<null>");
25
							e.consume();
26
						}
27
					}
28
				}
29
			}
30
			
16
                  if (text.length() <= 1) {
17
                     // about to delete last thing in field, so replace with
18
                     // null
19
                     DerbyClobDataTypeComponent.this._textComponent.updateText("<null>");
20
                     e.consume();
21
                  }
22
               }
23
            }
31
else {
24
         } else {
32
                // field is not nullable
25
            // field is not nullable
33
                //
26
            
34
    
27
//
35
            handleNotNullableField(text, c, e, _textComponent);
28
            handleNotNullableField(text, c, e, _textComponent);
36
			}
29
         }
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)1.3
Clones locationClones are in different classes having the same super class
Number of node comparisons33
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements11
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)8.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    7
    if (DataTypeString.this._isNullable)
    7
    if (DataTypeString.this._isNullable)
    4
    if (DerbyClobDataTypeComponent.this._isNullable)
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeStringnet.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDataTypeComponentSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression DataTypeString cannot be unified with expression DerbyClobDataTypeComponent , because common superclass net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BaseDataTypeComponent does not declare member(s) private boolean _isNullable
    4
    if (DerbyClobDataTypeComponent.this._isNullable)
    8
    if (text.equals("<null>"))
    5
    if (text.equals("<null>"))
    9
    if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE))
    6
    if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE))
    10
    DataTypeString.this._textComponent.restoreText();
    10
    DataTypeString.this._textComponent.restoreText();
    7
    DerbyClobDataTypeComponent.this._textComponent.restoreText();
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeStringnet.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDataTypeComponentSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression DataTypeString cannot be unified with expression DerbyClobDataTypeComponent , because common superclass net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BaseDataTypeComponent does not declare member(s) private net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.IRestorableTextComponent _textComponent
    7
    DerbyClobDataTypeComponent.this._textComponent.restoreText();
    11
    e.consume();
    8
    e.consume();
    else
    else
    12
    DataTypeString.this._textComponent.updateText("");
    12
    DataTypeString.this._textComponent.updateText("");
    9
    DerbyClobDataTypeComponent.this._textComponent.updateText("");
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeStringnet.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDataTypeComponentSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression DataTypeString cannot be unified with expression DerbyClobDataTypeComponent , because common superclass net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BaseDataTypeComponent does not declare member(s) private net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.IRestorableTextComponent _textComponent
    9
    DerbyClobDataTypeComponent.this._textComponent.updateText("");
    else
    else
    13
    if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE))
    10
    if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE))
    14
    if (text.length() == 0)
    14
    if (text.length() == 0)
    11
    if (text.length() <= 1)
    Differences
    Expression1Expression2Difference
    01LITERAL_VALUE_MISMATCH
    ==<=OPERATOR_MISMATCH
    Preondition Violations
    Expression text.length() == 0 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression text.length() <= 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11
    if (text.length() <= 1)
    15
    DataTypeString.this._textComponent.updateText("<null>");
    15
    DataTypeString.this._textComponent.updateText("<null>");
    12
    DerbyClobDataTypeComponent.this._textComponent.updateText("<null>");
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeStringnet.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDataTypeComponentSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression DataTypeString cannot be unified with expression DerbyClobDataTypeComponent , because common superclass net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BaseDataTypeComponent does not declare member(s) private net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.IRestorableTextComponent _textComponent
    12
    DerbyClobDataTypeComponent.this._textComponent.updateText("<null>");
    16
    e.consume();
    13
    e.consume();
    else
    else
    17
    handleNotNullableField(text, c, e, _textComponent);
    14
    handleNotNullableField(text, c, e, _textComponent);
    Precondition Violations (6)
    Row Violation
    1Expression DataTypeString cannot be unified with expression DerbyClobDataTypeComponent , because common superclass net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BaseDataTypeComponent does not declare member(s) private boolean _isNullable
    2Expression DataTypeString cannot be unified with expression DerbyClobDataTypeComponent , because common superclass net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BaseDataTypeComponent does not declare member(s) private net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.IRestorableTextComponent _textComponent
    3Expression DataTypeString cannot be unified with expression DerbyClobDataTypeComponent , because common superclass net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BaseDataTypeComponent does not declare member(s) private net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.IRestorableTextComponent _textComponent
    4Expression text.length() == 0 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression text.length() <= 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression DataTypeString cannot be unified with expression DerbyClobDataTypeComponent , because common superclass net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BaseDataTypeComponent does not declare member(s) private net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.IRestorableTextComponent _textComponent