// If the Decision Table model was pre-5.4 Numeric data-types were always stored as
 // BigDecimals. This function attempts to set the correct DTCellValue property based
 // on the *true* data type.
 private void convertDTCellValueFromNumeric(DataType.DataTypes dataType, DTCellValue52 dcv) {
   // Generic type NUMERIC was always stored as a BigDecimal
   final BigDecimal value = (BigDecimal) dcv.getNumericValue();
   switch (dataType) {
     case NUMERIC_BIGDECIMAL:
       dcv.setNumericValue(value == null ? null : value);
       break;
     case NUMERIC_BIGINTEGER:
       dcv.setNumericValue(value == null ? null : value.toBigInteger());
       break;
     case NUMERIC_BYTE:
       dcv.setNumericValue(value == null ? null : value.byteValue());
       break;
     case NUMERIC_DOUBLE:
       dcv.setNumericValue(value == null ? null : value.doubleValue());
       break;
     case NUMERIC_FLOAT:
       dcv.setNumericValue(value == null ? null : value.floatValue());
       break;
     case NUMERIC_INTEGER:
       dcv.setNumericValue(value == null ? null : value.intValue());
       break;
     case NUMERIC_LONG:
       dcv.setNumericValue(value == null ? null : value.longValue());
       break;
     case NUMERIC_SHORT:
       dcv.setNumericValue(value == null ? null : value.shortValue());
       break;
   }
 }
  @Override
  public GuidedDecisionTableUiCell convertCell(
      final DTCellValue52 cell,
      final BaseColumn column,
      final CellUtilities cellUtilities,
      final ColumnUtilities columnUtilities) {
    // If the underlying modelCell does not have a value don't create a UiModelCell. The
    // underlying model data is fully populated whereas the uiModel is sparsely populated.
    if (!cell.hasValue()) {
      return null;
    }

    final DataType.DataTypes dataType = columnUtilities.getDataType(column);
    cellUtilities.convertDTCellValueType(dataType, cell);

    switch (dataType) {
      case NUMERIC:
        return new GuidedDecisionTableUiCell<Number>(cell.getNumericValue(), cell.isOtherwise());
      case NUMERIC_BIGDECIMAL:
        return new GuidedDecisionTableUiCell<BigDecimal>(
            (BigDecimal) cell.getNumericValue(), cell.isOtherwise());
      case NUMERIC_BIGINTEGER:
        return new GuidedDecisionTableUiCell<BigInteger>(
            (BigInteger) cell.getNumericValue(), cell.isOtherwise());
      case NUMERIC_BYTE:
        return new GuidedDecisionTableUiCell<Byte>(
            (Byte) cell.getNumericValue(), cell.isOtherwise());
      case NUMERIC_DOUBLE:
        return new GuidedDecisionTableUiCell<Double>(
            (Double) cell.getNumericValue(), cell.isOtherwise());
      case NUMERIC_FLOAT:
        return new GuidedDecisionTableUiCell<Float>(
            (Float) cell.getNumericValue(), cell.isOtherwise());
      case NUMERIC_INTEGER:
        return new GuidedDecisionTableUiCell<Integer>(
            (Integer) cell.getNumericValue(), cell.isOtherwise());
      case NUMERIC_LONG:
        return new GuidedDecisionTableUiCell<Long>(
            (Long) cell.getNumericValue(), cell.isOtherwise());
      case NUMERIC_SHORT:
        return new GuidedDecisionTableUiCell<Short>(
            (Short) cell.getNumericValue(), cell.isOtherwise());
      case DATE:
        return new GuidedDecisionTableUiCell<Date>(cell.getDateValue(), cell.isOtherwise());
      case BOOLEAN:
        return new GuidedDecisionTableUiCell<Boolean>(cell.getBooleanValue(), cell.isOtherwise());
      default:
        return new GuidedDecisionTableUiCell<String>(cell.getStringValue(), cell.isOtherwise());
    }
  }
 // Convert a Short value to a String
 private String convertShortValueToString(DTCellValue52 dcv) {
   final Short value = (Short) dcv.getNumericValue();
   return (value == null ? "" : value.toString());
 }
 // Convert a Long value to a String
 private String convertLongValueToString(DTCellValue52 dcv) {
   final Long value = (Long) dcv.getNumericValue();
   return (value == null ? "" : value.toString());
 }
 // Convert a Integer value to a String
 private String convertIntegerValueToString(DTCellValue52 dcv) {
   final Integer value = (Integer) dcv.getNumericValue();
   return (value == null ? "" : value.toString());
 }
 // Convert a Double value to a String
 private String convertDoubleValueToString(DTCellValue52 dcv) {
   final Double value = (Double) dcv.getNumericValue();
   return (value == null ? "" : value.toString());
 }
 // Convert a BigDecimal value to a String
 private String convertBigDecimalValueToString(DTCellValue52 dcv) {
   final BigDecimal value = (BigDecimal) dcv.getNumericValue();
   return (value == null ? "" : value.toPlainString());
 }
  /**
   * Convert a Model cell to one that can be used in the UI
   *
   * @param dcv
   * @return
   */
  @Override
  public CellValue<? extends Comparable<?>> convertModelCellValue(
      BaseColumn column, DTCellValue52 dcv) {

    // Analysis cells do not use data-type
    if (column instanceof AnalysisCol52) {
      return makeNewAnalysisCellValue();
    }

    // Other cells do use data-type
    DataType.DataTypes dataType = utilities.getDataType(column);
    utilities.assertDTCellValue(dataType, dcv);

    CellValue<? extends Comparable<?>> cell = null;
    switch (dataType) {
      case BOOLEAN:
        cell = makeNewBooleanCellValue(dcv.getBooleanValue());
        break;
      case DATE:
        cell = makeNewDateCellValue(dcv.getDateValue());
        break;
      case NUMERIC:
        cell = makeNewNumericCellValue((BigDecimal) dcv.getNumericValue());
        break;
      case NUMERIC_BIGDECIMAL:
        cell = makeNewBigDecimalCellValue((BigDecimal) dcv.getNumericValue());
        break;
      case NUMERIC_BIGINTEGER:
        cell = makeNewBigIntegerCellValue((BigInteger) dcv.getNumericValue());
        break;
      case NUMERIC_BYTE:
        cell = makeNewByteCellValue((Byte) dcv.getNumericValue());
        break;
      case NUMERIC_DOUBLE:
        cell = makeNewDoubleCellValue((Double) dcv.getNumericValue());
        break;
      case NUMERIC_FLOAT:
        cell = makeNewFloatCellValue((Float) dcv.getNumericValue());
        break;
      case NUMERIC_INTEGER:
        cell = makeNewIntegerCellValue((Integer) dcv.getNumericValue());
        break;
      case NUMERIC_LONG:
        if (column instanceof RowNumberCol52) {
          cell = makeNewRowNumberCellValue((Long) dcv.getNumericValue());
        } else {
          cell = makeNewLongCellValue((Long) dcv.getNumericValue());
          if (column instanceof AttributeCol52) {
            AttributeCol52 at = (AttributeCol52) column;
            if (at.getAttribute().equals(RuleAttributeWidget.SALIENCE_ATTR)) {
              if (at.isUseRowNumber()) {
                cell = makeNewRowNumberCellValue((Long) dcv.getNumericValue());
              }
            }
          }
        }
        break;
      case NUMERIC_SHORT:
        cell = makeNewShortCellValue((Short) dcv.getNumericValue());
        break;
      default:
        cell = makeNewStringCellValue(dcv.getStringValue());
        if (column instanceof AttributeCol52) {
          AttributeCol52 ac = (AttributeCol52) column;
          if (ac.getAttribute().equals(RuleAttributeWidget.DIALECT_ATTR)) {
            cell = makeNewDialectCellValue(dcv.getStringValue());
          }
        }
    }

    if (dcv.isOtherwise()) {
      cell.addState(CellState.OTHERWISE);
    }

    return cell;
  }