示例#1
0
 // 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;
   }
 }
示例#2
0
  @Override
  public void populateDecisionTable(final GuidedDecisionTable52 dtable, final int maxRowCount) {
    if (this.values.size() < maxRowCount) {
      for (int iRow = this.values.size(); iRow < maxRowCount; iRow++) {
        this.values.add(new DTCellValue52(0));
      }
    }

    for (int iRow = 0; iRow < this.values.size(); iRow++) {
      dtable.getData().add(new ArrayList<DTCellValue52>());
      final DTCellValue52 dcv = this.values.get(iRow);
      dcv.setNumericValue(Integer.valueOf(iRow + 1));
      dtable.getData().get(iRow).add(0, dcv);
    }
  }
示例#3
0
 // 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 convertDTCellValueFromString(DataType.DataTypes dataType, DTCellValue52 dcv) {
   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 numericValue = null;
       try {
         if (text != null) {
           numericValue = new BigDecimal(text);
         }
       } catch (Exception e) {
       }
       dcv.setNumericValue(numericValue);
       break;
     case NUMERIC_BIGDECIMAL:
       BigDecimal bigDecimalValue = null;
       try {
         if (text != null) {
           bigDecimalValue = new BigDecimal(text);
         }
       } catch (Exception e) {
       }
       dcv.setNumericValue(bigDecimalValue);
       break;
     case NUMERIC_BIGINTEGER:
       BigInteger bigIntegerValue = null;
       try {
         if (text != null) {
           bigIntegerValue = new BigInteger(text);
         }
       } catch (Exception e) {
       }
       dcv.setNumericValue(bigIntegerValue);
       break;
     case NUMERIC_BYTE:
       Byte byteValue = null;
       try {
         if (text != null) {
           byteValue = new Byte(text);
         }
       } catch (Exception e) {
       }
       dcv.setNumericValue(byteValue);
       break;
     case NUMERIC_DOUBLE:
       Double doubleValue = null;
       try {
         if (text != null) {
           doubleValue = new Double(text);
         }
       } catch (Exception e) {
       }
       dcv.setNumericValue(doubleValue);
       break;
     case NUMERIC_FLOAT:
       Float floatValue = null;
       try {
         if (text != null) {
           floatValue = new Float(text);
         }
       } catch (Exception e) {
       }
       dcv.setNumericValue(floatValue);
       break;
     case NUMERIC_INTEGER:
       Integer integerValue = null;
       try {
         if (text != null) {
           integerValue = new Integer(text);
         }
       } catch (Exception e) {
       }
       dcv.setNumericValue(integerValue);
       break;
     case NUMERIC_LONG:
       Long longValue = null;
       try {
         if (text != null) {
           longValue = new Long(text);
         }
       } catch (Exception e) {
       }
       dcv.setNumericValue(longValue);
       break;
     case NUMERIC_SHORT:
       Short shortValue = null;
       try {
         if (text != null) {
           shortValue = new Short(text);
         }
       } catch (Exception e) {
       }
       dcv.setNumericValue(shortValue);
       break;
   }
 }