CloneSet16


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
169320.989class_body_declarations[6]
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
1170188
E:/TSE/Projects-CloneDR/sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeByte.java
2169188
E:/TSE/Projects-CloneDR/sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeLong.java
3169189
E:/TSE/Projects-CloneDR/sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeShort.java
Next
Last
Clone Instance
1
Line Count
170
Source Line
188
Source File
E:/TSE/Projects-CloneDR/sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeByte.java

/**
 * Implement the interface for validating and converting to internal object.
 * Null is a valid successful return, so errors are indicated only by
 * existance or not of a message in the messageBuffer.
 */
public Object validateAndConvert(String value, Object originalValue, StringBuffer messageBuffer) {
  // handle null, which is shown as the special string "<null>"
  if (value.equals("<null>") || value.equals(""))
    return null;
  // Do the conversion into the object in a safe manner
  try {
    Object obj = new Byte(value);
    return obj;
  }
  catch (Exception
         e) {
    messageBuffer.append(e.toString() + "\n");
    //?? do we need the message also, or is it automatically part of the toString()?
    //messageBuffer.append(e.getMessage());
    return null;
  }
}

/**
 * If true, this tells the PopupEditableIOPanel to use the
 * binary editing panel rather than a pure text panel.
 * The binary editing panel assumes the data is an array of bytes,
 * converts it into text form, allows the user to change how that
 * data is displayed (e.g. Hex, Decimal, etc.), and converts
 * the data back from text to bytes when the user editing is completed.
 * If this returns false, this DataType class must
 * convert the internal data into a text string that
 * can be displayed (and edited, if allowed) in a TextField
 * or TextArea, and must handle all
 * user key strokes related to editing of that data.
 */
public boolean useBinaryEditingPanel() {
  return false;
}

/*
 * Now the functions for the Popup-related operations.
 */
/**
 * Returns true if data type may be edited in the popup,
 * false if not.
 */
public boolean isEditableInPopup(Object originalValue) {
  return true;
}

/*
 * Return a JTextArea usable in the CellPopupDialog
 * and fill in the value.
 */
public JTextArea getJTextArea(Object value) {
  _textComponent = new RestorableJTextArea();
  // value is a simple string representation of the data,
  // the same one used in Text and in-cell operations.
  ((RestorableJTextArea) _textComponent).setText(renderObject(value));
  // special handling of operations while editing this data type
  ((RestorableJTextArea) _textComponent).addKeyListener(new KeyTextHandler());
  return (RestorableJTextArea) _textComponent;
}

/**
 * Validating and converting in Popup is identical to cell-related operation.
 */
public Object validateAndConvertInPopup(String value, Object originalValue, StringBuffer messageBuffer) {
  return validateAndConvert(value, originalValue, messageBuffer);
}

/*
 * The following is used in both cell and popup operations.
 */
/*
 * Internal class for handling key events during editing
 * of both JTextField and JTextArea.
 */
private class KeyTextHandler extends BaseKeyTextHandler {
  public void keyTyped(KeyEvent e) {
    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) DataTypeByte.this._textComponent;
    String text = _theComponent.getText();
    // look for illegal chars
    if ( !DataTypeByte.this._isSigned && c == '-') {
      // cannot use '-' when unsigned
      _beepHelper.beep(_theComponent);
      e.consume();
    }
    // tabs and newlines get put into the text before this check,
    // so remove them
    // This only applies to Popup editing since these chars are
    // not passed to this level by the in-cell editor.
    if (c == KeyEvent.VK_TAB || c == KeyEvent.VK_ENTER) {
      // remove all instances of the offending char
      int index = text.indexOf(c);
      if (index != -1) {
        if (index == text.length() - 1) {
          text = text.substring(0, text.length() - 1); // truncate string
        }
        else {
          text = text.substring(0, index) + text.substring(index + 1);
        }
        ((IRestorableTextComponent) _theComponent).updateText(text);
        _beepHelper.beep(_theComponent);
      }
      e.consume();
    }
    if ( !(Character.isDigit(c) || (c == '-') || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE))) {
      _beepHelper.beep(_theComponent);
      e.consume();
    }
    // check for max size reached (only works when DB provides non-zero scale info
    if (DataTypeByte.this._scale > 0 && text.length() == DataTypeByte.this._scale && c != KeyEvent.VK_BACK_SPACE && c != KeyEvent.VK_DELETE) {
      // max size reached
      e.consume();
      _beepHelper.beep(_theComponent);
    }
    // handle cases of null
    // The processing is different when nulls are allowed and when they are not.
    //
    if (DataTypeByte.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
          DataTypeByte.this._textComponent.restoreText();
          e.consume();
        }
        else {
          // non-delete when null => clear field and add text
          DataTypeByte.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
            DataTypeByte.this._textComponent.updateText("<null>");
            e.consume();
          }
        }
      }
    }
    else {
      // field is not nullable
      //
      handleNotNullableField(text, c, e, _textComponent);
    }
  }
}


Next
Previous
Clone Instance
2
Line Count
169
Source Line
188
Source File
E:/TSE/Projects-CloneDR/sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeLong.java

/**
 * Implement the interface for validating and converting to internal object.
 * Null is a valid successful return, so errors are indicated only by
 * existance or not of a message in the messageBuffer.
 */
public Object validateAndConvert(String value, Object originalValue, StringBuffer messageBuffer) {
  // handle null, which is shown as the special string "<null>"
  if (value.equals("<null>") || value.equals(""))
    return null;
  // Do the conversion into the object in a safe manner
  try {
    Object obj = new Long(value);
    return obj;
  }
  catch (Exception
         e) {
    messageBuffer.append(e.toString() + "\n");
    //?? do we need the message also, or is it automatically part of the toString()?
    //messageBuffer.append(e.getMessage());
    return null;
  }
}

/**
 * If true, this tells the PopupEditableIOPanel to use the
 * binary editing panel rather than a pure text panel.
 * The binary editing panel assumes the data is an array of bytes,
 * converts it into text form, allows the user to change how that
 * data is displayed (e.g. Hex, Decimal, etc.), and converts
 * the data back from text to bytes when the user editing is completed.
 * If this returns false, this DataType class must
 * convert the internal data into a text string that
 * can be displayed (and edited, if allowed) in a TextField
 * or TextArea, and must handle all
 * user key strokes related to editing of that data.
 */
public boolean useBinaryEditingPanel() {
  return false;
}

/*
 * Now the functions for the Popup-related operations.
 */
/**
 * Returns true if data type may be edited in the popup,
 * false if not.
 */
public boolean isEditableInPopup(Object originalValue) {
  return true;
}

/*
 * Return a JTextArea usable in the CellPopupDialog
 * and fill in the value.
 */
public JTextArea getJTextArea(Object value) {
  _textComponent = new RestorableJTextArea();
  // value is a simple string representation of the data,
  // the same one used in Text and in-cell operations.
  ((RestorableJTextArea) _textComponent).setText(renderObject(value));
  // special handling of operations while editing this data type
  ((RestorableJTextArea) _textComponent).addKeyListener(new KeyTextHandler());
  return (RestorableJTextArea) _textComponent;
}

/**
 * Validating and converting in Popup is identical to cell-related operation.
 */
public Object validateAndConvertInPopup(String value, Object originalValue, StringBuffer messageBuffer) {
  return validateAndConvert(value, originalValue, messageBuffer);
}

/*
 * The following is used in both cell and popup operations.
 */
/*
 * Internal class for handling key events during editing
 * of both JTextField and JTextArea.
 */
private class KeyTextHandler extends BaseKeyTextHandler {
  public void keyTyped(KeyEvent e) {
    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) DataTypeLong.this._textComponent;
    String text = _theComponent.getText();
    // look for illegal chars
    if ( !DataTypeLong.this._isSigned && c == '-') {
      // cannot use '-' when unsigned
      _beepHelper.beep(_theComponent);
      e.consume();
    }
    // tabs and newlines get put into the text before this check,
    // so remove them
    // This only applies to Popup editing since these chars are
    // not passed to this level by the in-cell editor.
    if (c == KeyEvent.VK_TAB || c == KeyEvent.VK_ENTER) {
      // remove all instances of the offending char
      int index = text.indexOf(c);
      if (index != -1) {
        if (index == text.length() - 1) {
          text = text.substring(0, text.length() - 1); // truncate string
        }
        else {
          text = text.substring(0, index) + text.substring(index + 1);
        }
        ((IRestorableTextComponent) _theComponent).updateText(text);
        _beepHelper.beep(_theComponent);
      }
      e.consume();
    }
    if ( !(Character.isDigit(c) || (c == '-') || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE))) {
      _beepHelper.beep(_theComponent);
      e.consume();
    }
    // check for max size reached (only works when DB provides non-zero scale info
    if (DataTypeLong.this._scale > 0 && text.length() == DataTypeLong.this._scale && c != KeyEvent.VK_BACK_SPACE && c != KeyEvent.VK_DELETE) {
      // max size reached
      e.consume();
      _beepHelper.beep(_theComponent);
    }
    // handle cases of null
    // The processing is different when nulls are allowed and when they are not.
    //
    if (DataTypeLong.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
          DataTypeLong.this._textComponent.restoreText();
          e.consume();
        }
        else {
          // non-delete when null => clear field and add text
          DataTypeLong.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
            DataTypeLong.this._textComponent.updateText("<null>");
            e.consume();
          }
        }
      }
    }
    else {
      // field is not nullable
      //
      handleNotNullableField(text, c, e, _textComponent);
    }
  }
}


First
Previous
Clone Instance
3
Line Count
169
Source Line
189
Source File
E:/TSE/Projects-CloneDR/sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeShort.java

/**
 * Implement the interface for validating and converting to internal object.
 * Null is a valid successful return, so errors are indicated only by
 * existance or not of a message in the messageBuffer.
 */
public Object validateAndConvert(String value, Object originalValue, StringBuffer messageBuffer) {
  // handle null, which is shown as the special string "<null>"
  if (value.equals("<null>") || value.equals(""))
    return null;
  // Do the conversion into the object in a safe manner
  try {
    Object obj = new Short(value);
    return obj;
  }
  catch (Exception
         e) {
    messageBuffer.append(e.toString() + "\n");
    //?? do we need the message also, or is it automatically part of the toString()?
    //messageBuffer.append(e.getMessage());
    return null;
  }
}

/**
 * If true, this tells the PopupEditableIOPanel to use the
 * binary editing panel rather than a pure text panel.
 * The binary editing panel assumes the data is an array of bytes,
 * converts it into text form, allows the user to change how that
 * data is displayed (e.g. Hex, Decimal, etc.), and converts
 * the data back from text to bytes when the user editing is completed.
 * If this returns false, this DataType class must
 * convert the internal data into a text string that
 * can be displayed (and edited, if allowed) in a TextField
 * or TextArea, and must handle all
 * user key strokes related to editing of that data.
 */
public boolean useBinaryEditingPanel() {
  return false;
}

/*
 * Now the functions for the Popup-related operations.
 */
/**
 * Returns true if data type may be edited in the popup,
 * false if not.
 */
public boolean isEditableInPopup(Object originalValue) {
  return true;
}

/*
 * Return a JTextArea usable in the CellPopupDialog
 * and fill in the value.
 */
public JTextArea getJTextArea(Object value) {
  _textComponent = new RestorableJTextArea();
  // value is a simple string representation of the data,
  // the same one used in Text and in-cell operations.
  ((RestorableJTextArea) _textComponent).setText(renderObject(value));
  // special handling of operations while editing this data type
  ((RestorableJTextArea) _textComponent).addKeyListener(new KeyTextHandler());
  return (RestorableJTextArea) _textComponent;
}

/**
 * Validating and converting in Popup is identical to cell-related operation.
 */
public Object validateAndConvertInPopup(String value, Object originalValue, StringBuffer messageBuffer) {
  return validateAndConvert(value, originalValue, messageBuffer);
}

/*
 * The following is used in both cell and popup operations.
 */
/*
 * Internal class for handling key events during editing
 * of both JTextField and JTextArea.
 */
private class KeyTextHandler extends BaseKeyTextHandler {
  public void keyTyped(KeyEvent e) {
    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) DataTypeShort.this._textComponent;
    String text = _theComponent.getText();
    // look for illegal chars
    if ( !DataTypeShort.this._isSigned && c == '-') {
      // cannot use '-' when unsigned
      _beepHelper.beep(_theComponent);
      e.consume();
    }
    // tabs and newlines get put into the text before this check,
    // so remove them
    // This only applies to Popup editing since these chars are
    // not passed to this level by the in-cell editor.
    if (c == KeyEvent.VK_TAB || c == KeyEvent.VK_ENTER) {
      // remove all instances of the offending char
      int index = text.indexOf(c);
      if (index != -1) {
        if (index == text.length() - 1) {
          text = text.substring(0, text.length() - 1); // truncate string
        }
        else {
          text = text.substring(0, index) + text.substring(index + 1);
        }
        ((IRestorableTextComponent) _theComponent).updateText(text);
        _beepHelper.beep(_theComponent);
      }
      e.consume();
    }
    if ( !(Character.isDigit(c) || (c == '-') || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE))) {
      _beepHelper.beep(_theComponent);
      e.consume();
    }
    // check for max size reached (only works when DB provides non-zero scale info
    if (DataTypeShort.this._scale > 0 && text.length() == DataTypeShort.this._scale && c != KeyEvent.VK_BACK_SPACE && c != KeyEvent.VK_DELETE) {
      // max size reached
      e.consume();
      _beepHelper.beep(_theComponent);
    }
    // handle cases of null
    // The processing is different when nulls are allowed and when they are not.
    //
    if (DataTypeShort.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
          DataTypeShort.this._textComponent.restoreText();
          e.consume();
        }
        else {
          // non-delete when null => clear field and add text
          DataTypeShort.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
            DataTypeShort.this._textComponent.updateText("<null>");
            e.consume();
          }
        }
      }
    }
    else {
      // field is not nullable
      //
      handleNotNullableField(text, c, e, _textComponent);
    }
  }
}


Clone AbstractionParameter Count: 2Parameter Bindings

/**
         * Implement the interface for validating and converting to internal object.
         * Null is a valid successful return, so errors are indicated only by
         * existance or not of a message in the messageBuffer.
         */
public Object validateAndConvert(String value, Object originalValue, StringBuffer messageBuffer) {
  // handle null, which is shown as the special string "<null>"
  if (value.equals("<null>") || value.equals(""))
    return null;
  // Do the conversion into the object in a safe manner
  try {
    Object obj = new [[#variable18c207c0]](value);
    return obj;
  }
  catch (Exception
         e) {
    messageBuffer.append(e.toString() + "\n");
    //?? do we need the message also, or is it automatically part of the toString()?
    //messageBuffer.append(e.getMessage());
    return null;
  }
}

/**
         * If true, this tells the PopupEditableIOPanel to use the
         * binary editing panel rather than a pure text panel.
         * The binary editing panel assumes the data is an array of bytes,
         * converts it into text form, allows the user to change how that
         * data is displayed (e.g. Hex, Decimal, etc.), and converts
         * the data back from text to bytes when the user editing is completed.
         * If this returns false, this DataType class must
         * convert the internal data into a text string that
         * can be displayed (and edited, if allowed) in a TextField
         * or TextArea, and must handle all
         * user key strokes related to editing of that data.
         */
public boolean useBinaryEditingPanel() {
  return false;
}

/*
         * Now the functions for the Popup-related operations.
         */
/**
         * Returns true if data type may be edited in the popup,
         * false if not.
         */
public boolean isEditableInPopup(Object originalValue) {
  return true;
}

/*
         * Return a JTextArea usable in the CellPopupDialog
         * and fill in the value.
         */
public JTextArea getJTextArea(Object value) {
  _textComponent = new RestorableJTextArea();
  // value is a simple string representation of the data,
  // the same one used in Text and in-cell operations.
  ((RestorableJTextArea) _textComponent).setText(renderObject(value));
  // special handling of operations while editing this data type
  ((RestorableJTextArea) _textComponent).addKeyListener(new KeyTextHandler());
  return (RestorableJTextArea) _textComponent;
}

/**
         * Validating and converting in Popup is identical to cell-related operation.
         */
public Object validateAndConvertInPopup(String value, Object originalValue, StringBuffer messageBuffer) {
  return validateAndConvert(value, originalValue, messageBuffer);
}

/*
         * The following is used in both cell and popup operations.
         */
/*
         * Internal class for handling key events during editing
         * of both JTextField and JTextArea.
         */
private class KeyTextHandler extends BaseKeyTextHandler {
  public void keyTyped(KeyEvent e) {
    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)  [[#variable18c11300]].this._textComponent;
    String text = _theComponent.getText();
    // look for illegal chars
    if ( ! [[#variable18c11300]].this._isSigned && c == '-') {
      // cannot use '-' when unsigned
      _beepHelper.beep(_theComponent);
      e.consume();
    }
    // tabs and newlines get put into the text before this check,
    // so remove them
    // This only applies to Popup editing since these chars are
    // not passed to this level by the in-cell editor.
    if (c == KeyEvent.VK_TAB || c == KeyEvent.VK_ENTER) {
      // remove all instances of the offending char
      int index = text.indexOf(c);
      if (index != -1) {
        if (index == text.length() - 1) {
          text = text.substring(0, text.length() - 1); // truncate string
        }
        else {
          text = text.substring(0, index) + text.substring(index + 1);
        }
        ((IRestorableTextComponent) _theComponent).updateText(text);
        _beepHelper.beep(_theComponent);
      }
      e.consume();
    }
    if ( !(Character.isDigit(c) || (c == '-') || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE))) {
      _beepHelper.beep(_theComponent);
      e.consume();
    }
    // check for max size reached (only works when DB provides non-zero scale info
    if ( [[#variable18c11300]].this._scale > 0 && text.length() == [[#variable18c11300]].this._scale && c != KeyEvent.VK_BACK_SPACE && c != KeyEvent.VK_DELETE) {
      // max size reached
      e.consume();
      _beepHelper.beep(_theComponent);
    }
    // handle cases of null
    // The processing is different when nulls are allowed and when they are not.
    //
    if ( [[#variable18c11300]].this._isNullable) {
      // user enters something when field is null
      if (text.equals("<null>")) {
        if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
           [[#variable18c11300]].this._textComponent.restoreText();
          e.consume();
        }
        else {
           [[#variable18c11300]].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) {
             [[#variable18c11300]].this._textComponent.updateText("<null>");
            e.consume();
          }
        }
      }
    }
    else {
      // field is not nullable
      //
      handleNotNullableField(text, c, e, _textComponent);
    }
  }
}
 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
11[[#18c207c0]]
Byte 
12[[#18c207c0]]
Long 
13[[#18c207c0]]
Short 
21[[#18c11300]]
DataTypeByte 
22[[#18c11300]]
DataTypeLong 
23[[#18c11300]]
DataTypeShort