Ejemplo n.º 1
0
 private DTCellValue52 cloneLimitedEntryValue(DTCellValue52 dcv) {
   if (dcv == null) {
     return null;
   }
   DTCellValue52 clone = new DTCellValue52();
   switch (dcv.getDataType()) {
     case BOOLEAN:
       clone.setBooleanValue(dcv.getBooleanValue());
       break;
     case DATE:
       clone.setDateValue(dcv.getDateValue());
       break;
     case NUMERIC:
       clone.setNumericValue(dcv.getNumericValue());
       break;
     case STRING:
       clone.setStringValue(dcv.getStringValue());
   }
   return clone;
 }
  // If the Decision Table model has been converted from the legacy text based
  // class then all values are held in the DTCellValue's StringValue. This
  // function attempts to set the correct DTCellValue property based on
  // the DTCellValue's data type.
  private void assertDTCellValue(DTDataTypes52 dataType, DTCellValue52 dcv) {
    // If already converted exit
    if (dataType.equals(dcv.getDataType())) {
      return;
    }

    String text = dcv.getStringValue();
    switch (dataType) {
      case BOOLEAN:
        dcv.setBooleanValue((text == null ? false : Boolean.valueOf(text)));
        break;
      case DATE:
        Date d = null;
        try {
          if (text != null) {
            if (DATE_CONVERTOR == null) {
              throw new IllegalArgumentException("DATE_CONVERTOR has not been initialised.");
            }
            d = DATE_CONVERTOR.parse(text);
          }
        } catch (IllegalArgumentException e) {
        }
        dcv.setDateValue(d);
        break;
      case NUMERIC:
        BigDecimal bd = null;
        try {
          if (text != null) {
            bd = new BigDecimal(text);
          }
        } catch (NumberFormatException e) {
        }
        dcv.setNumericValue(bd);
        break;
    }
  }