char c = e.getKeyChar(); // as a coding convenience, create a reference to the text component // that is typecast to JTextComponent. this is not essential, as we // could typecast every reference, but this makes the code cleaner JTextComponent _theComponent = (JTextComponent) DerbyClobDataTypeComponent.this._textComponent; String text = _theComponent.getText(); // handle cases of null // The processing is different when nulls are allowed and when they are // not. // 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); }
char c = e.getKeyChar(); // as a coding convenience, create a reference to the text component // that is typecast to JTextComponent. this is not essential, as we // could typecast every reference, but this makes the code cleaner JTextComponent _theComponent = (JTextComponent)DataTypeClob.this._textComponent; String text = _theComponent.getText(); // handle cases of null // The processing is different when nulls are allowed and when they are not. // if ( DataTypeClob.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 DataTypeClob.this._textComponent.restoreText(); e.consume(); } else { // non-delete when null => clear field and add text DataTypeClob.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 DataTypeClob.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/plugins/derby/src/net/sourceforge/squirrel_sql/plugins/derby/types/DerbyClobDataTypeComponent.java File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeClob.java
Method name: void keyTyped(KeyEvent) Method name: void keyTyped(KeyEvent)
Number of AST nodes: 14 Number of AST nodes: 14
1
char c = e.getKeyChar();
1
char c = e.getKeyChar();
2
         // as a coding convenience, create a reference to the text component
2
				// as a coding convenience, create a reference to the text component
3
         // that is typecast to JTextComponent. this is not essential, as we
3
				// that is typecast to JTextComponent.  this is not essential, as we
4
         // could typecast every reference, but this makes the code cleaner
4
				// could typecast every reference, but this makes the code cleaner
5
         JTextComponent _theComponent = (JTextComponent) DerbyClobDataTypeComponent.this._textComponent;
5
				JTextComponent _theComponent = (JTextComponent)DataTypeClob.this._textComponent;
6
         String text = _theComponent.getText();
6
				String text = _theComponent.getText();
7
         
8
// handle cases of null
7
				// handle cases of null
9
         // The processing is different when nulls are allowed and when they are
8
				// The processing is different when nulls are allowed and when they are
10
         // not.
11
         //
12
         if (DerbyClob
9
 not.
10
				//
13
DataTypeComponent.this._isNullable) {
11
				if ( DataTypeClob.this._isNullable) {
14
            // user enters something when field is null
12
					// user enters something when field is null
15
            if (text.equals("<null>")) {
13
					if (text.equals("<null>")) {
16
               if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
14
						if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
17
                  // delete when null => original value
15
							// delete when null => original value
18
                  DerbyClobDataTypeComponent.this._textComponent.restoreText();
16
							DataTypeClob.this._textComponent.restoreText();
19
                  e.consume();
20
               } else {
21
                  
17
							e.consume();
18
						}
19
						else {
22
// non-delete when null => clear field and add text
20
							// non-delete when null => clear field and add text
23
                  DerbyClobDataTypeComponent.this._textComponent.updateText("");
21
							DataTypeClob.this._textComponent.updateText("");
24
                  // fall through to normal processing of this key stroke
22
							// fall through to normal processing of this key stroke
25
               }
26
            } else {
27
               
23
						}
24
					}
25
					else {
28
// check for user deletes last thing in field
26
						// check for user deletes last thing in field
29
               if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
27
						if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
30
                  if (text.length() <= 1) {
28
							if (text.length() <= 1 ) {
31
                     // about to delete last thing in field, so replace with
29
								// about to delete last thing in field, so replace with
32
                     // null
33
                     DerbyClob
30
 null
34
DataTypeComponent.this._textComponent.updateText("<null>");
31
								DataTypeClob.this._textComponent.updateText("<null>");
35
                     e.consume();
36
                  }
37
               }
38
            }
39
         } else {
32
								e.consume();
33
							}
34
						}
35
					}
36
				}
37
				else {
40
            // field is not nullable
38
                    // field is not nullable
41
            //
39
                
40
    //
42
            handleNotNullableField(text, c, e, _textComponent);
41
                    handleNotNullableField(text, c, e, _textComponent);
43
         }
42
				}
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.6
Clones locationClones are in different classes having the same super class
Number of node comparisons42
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements14
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)11.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    char c = e.getKeyChar();
    1
    char c = e.getKeyChar();
    2
    JTextComponent _theComponent = (JTextComponent)DerbyClobDataTypeComponent.this._textComponent;
    2
    JTextComponent _theComponent = (JTextComponent)DerbyClobDataTypeComponent.this._textComponent;
    2
    JTextComponent _theComponent = (JTextComponent)DataTypeClob.this._textComponent;
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDataTypeComponentnet.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeClobSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression DerbyClobDataTypeComponent cannot be unified with expression DataTypeClob , 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
    2
    JTextComponent _theComponent = (JTextComponent)DataTypeClob.this._textComponent;
    3
    String text = _theComponent.getText();
    3
    String text = _theComponent.getText();
    4
    if (DerbyClobDataTypeComponent.this._isNullable)
    4
    if (DerbyClobDataTypeComponent.this._isNullable)
    4
    if (DataTypeClob.this._isNullable)
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDataTypeComponentnet.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeClobSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression DerbyClobDataTypeComponent cannot be unified with expression DataTypeClob , because common superclass net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BaseDataTypeComponent does not declare member(s) private boolean _isNullable
    4
    if (DataTypeClob.this._isNullable)
    5
    if (text.equals("<null>"))
    5
    if (text.equals("<null>"))
    6
    if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE))
    6
    if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE))
    7
    DerbyClobDataTypeComponent.this._textComponent.restoreText();
    7
    DerbyClobDataTypeComponent.this._textComponent.restoreText();
    7
    DataTypeClob.this._textComponent.restoreText();
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDataTypeComponentnet.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeClobSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression DerbyClobDataTypeComponent cannot be unified with expression DataTypeClob , 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
    DataTypeClob.this._textComponent.restoreText();
    8
    e.consume();
    8
    e.consume();
    else
    else
    9
    DerbyClobDataTypeComponent.this._textComponent.updateText("");
    9
    DerbyClobDataTypeComponent.this._textComponent.updateText("");
    9
    DataTypeClob.this._textComponent.updateText("");
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDataTypeComponentnet.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeClobSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression DerbyClobDataTypeComponent cannot be unified with expression DataTypeClob , 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
    DataTypeClob.this._textComponent.updateText("");
    else
    else
    10
    if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE))
    10
    if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE))
    11
    if (text.length() <= 1)
    11
    if (text.length() <= 1)
    12
    DerbyClobDataTypeComponent.this._textComponent.updateText("<null>");
    12
    DerbyClobDataTypeComponent.this._textComponent.updateText("<null>");
    12
    DataTypeClob.this._textComponent.updateText("<null>");
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDataTypeComponentnet.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeClobSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression DerbyClobDataTypeComponent cannot be unified with expression DataTypeClob , 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
    DataTypeClob.this._textComponent.updateText("<null>");
    13
    e.consume();
    13
    e.consume();
    else
    else
    14
    handleNotNullableField(text, c, e, _textComponent);
    14
    handleNotNullableField(text, c, e, _textComponent);
    Precondition Violations (5)
    Row Violation
    1Expression DerbyClobDataTypeComponent cannot be unified with expression DataTypeClob , 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
    2Expression DerbyClobDataTypeComponent cannot be unified with expression DataTypeClob , because common superclass net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BaseDataTypeComponent does not declare member(s) private boolean _isNullable
    3Expression DerbyClobDataTypeComponent cannot be unified with expression DataTypeClob , 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 DerbyClobDataTypeComponent cannot be unified with expression DataTypeClob , 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
    5Expression DerbyClobDataTypeComponent cannot be unified with expression DataTypeClob , 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