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)DataTypeBlob.this._textComponent; String text = _theComponent.getText(); // handle cases of null // The processing is different when nulls are allowed and when they are not. // if ( DataTypeBlob.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 DataTypeBlob.this._textComponent.restoreText(); e.consume(); } else { // non-delete when null => clear field and add text DataTypeBlob.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 DataTypeBlob.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/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeBlob.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)DataTypeBlob.this._textComponent;
5
				JTextComponent _theComponent = (JTextComponent)DataTypeClob.this._textComponent;
6
				String text = _theComponent.getText();
6
				String text = _theComponent.getText();
7
				// handle cases of null
7
				// handle cases of null
8
				// The processing is different when nulls are allowed and when they are not.
8
				// The processing is different when nulls are allowed and when they are not.
9
				//
9
				//
10
				if ( DataTypeBlob.this._isNullable) {
10
				if ( DataTypeClob.this._isNullable) {
11
					// user enters something when field is null
11
					// user enters something when field is null
12
					if (text.equals("<null>")) {
12
					if (text.equals("<null>")) {
13
						if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
13
						if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
14
							// delete when null => original value
14
							// delete when null => original value
15
							DataTypeBlob.this._textComponent.restoreText();
15
							DataTypeClob.this._textComponent.restoreText();
16
							e.consume();
16
							e.consume();
17
						}
17
						}
18
						else {
18
						else {
19
							// non-delete when null => clear field and add text
19
							// non-delete when null => clear field and add text
20
							DataTypeBlob.this._textComponent.updateText("");
20
							DataTypeClob.this._textComponent.updateText("");
21
							// fall through to normal processing of this key stroke
21
							// fall through to normal processing of this key stroke
22
						}
22
						}
23
					}
23
					}
24
					else {
24
					else {
25
						// check for user deletes last thing in field
25
						// check for user deletes last thing in field
26
						if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
26
						if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
27
							if (text.length() <= 1 ) {
27
							if (text.length() <= 1 ) {
28
								// about to delete last thing in field, so replace with null
28
								// about to delete last thing in field, so replace with null
29
								DataTypeBlob.this._textComponent.updateText("<null>");
29
								DataTypeClob.this._textComponent.updateText("<null>");
30
								e.consume();
30
								e.consume();
31
							}
31
							}
32
						}
32
						}
33
					}
33
					}
34
				}
34
				}
35
				else {
35
				else {
36
                    // field is not nullable
36
                    // field is not nullable
37
                    //
37
                    //
38
                    handleNotNullableField(text, c, e, _textComponent);
38
                    handleNotNullableField(text, c, e, _textComponent);
39
				}
39
				}
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.4
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)10.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    char c = e.getKeyChar();
    1
    char c = e.getKeyChar();
    2
    JTextComponent _theComponent = (JTextComponent)DataTypeBlob.this._textComponent;
    2
    JTextComponent _theComponent = (JTextComponent)DataTypeBlob.this._textComponent;
    2
    JTextComponent _theComponent = (JTextComponent)DataTypeClob.this._textComponent;
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeBlobnet.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeClobSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression DataTypeBlob 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 (DataTypeBlob.this._isNullable)
    4
    if (DataTypeBlob.this._isNullable)
    4
    if (DataTypeClob.this._isNullable)
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeBlobnet.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeClobSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression DataTypeBlob 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
    DataTypeBlob.this._textComponent.restoreText();
    7
    DataTypeBlob.this._textComponent.restoreText();
    7
    DataTypeClob.this._textComponent.restoreText();
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeBlobnet.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeClobSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression DataTypeBlob 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
    DataTypeBlob.this._textComponent.updateText("");
    9
    DataTypeBlob.this._textComponent.updateText("");
    9
    DataTypeClob.this._textComponent.updateText("");
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeBlobnet.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeClobSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression DataTypeBlob 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
    DataTypeBlob.this._textComponent.updateText("<null>");
    12
    DataTypeBlob.this._textComponent.updateText("<null>");
    12
    DataTypeClob.this._textComponent.updateText("<null>");
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeBlobnet.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeClobSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression DataTypeBlob 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 DataTypeBlob 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 DataTypeBlob 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 DataTypeBlob 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 DataTypeBlob 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 DataTypeBlob 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