Data Types in the DMN Engine

A decision table allows to specify the types of inputs and outputs. When the DMN engine evaluates an input or an output, it checks if the type of the value matches the specified type. If the types do not match, the engine tries to transform the value into the specified type or throws an exception.

The DMN engine supports basic types which can be extended by custom types.

Supported Data Types

The following types are supported by the DMN engine:

Data Type Can transform from Produce values of type
string java.lang.Object StringValue
boolean java.lang.Boolean, java.lang.String BooleanValue
integer java.lang.Number, java.lang.String IntegerValue
long java.lang.Number, java.lang.String LongValue
double java.lang.Number, java.lang.String DoubleValue
date java.util.Date, java.lang.String DateValue

Each data type transformer produces a typed value which contains the value and additional type informations.

If the given type does not match one of the above types then the value is transformed into an untyped value by default.

Working with Dates

The DMN engine supports a date type which is a combination of date and time. By default, the data type transformer accept objects of the type java.util.Date and Strings having the format yyyy-MM-dd'T'HH:mm:ss.

If you prefer another format or different representation of a date, implement a custom type and replace the default transformer.

Setting the Data Type of an Input

The type of a decision table input is specified by the typeRef attribute on the inputExpression element.

<decision>
  <decisionTable>
    <input id="orderSum" label="Order sum">
      <inputExpression typeRef="double">
        <text>sum</text>
      </inputExpression>
    </input>
    <!-- ... -->
  </decisionTable>
</decision>

Setting the Data Type of an Output

The type of a decision table output is specified by the typeRef attribute on the output element.

<decision>
  <decisionTable>
    <!-- ... -->
    <output id="result" label="Check Result" name="result" typeRef="string" />
    <!-- ... -->
  </decisionTable>
</decision>

Setting the Data Type of a Variable

The type of a decision literal expression result is specified by the typeRef attribute on the variable element.

<decision>
  <variable name="result" typeRef="string" />
  <!-- ... -->
</decision>

Implement a Custom Data Type

Use of Internal API

Please be aware that these APIs are not part of the public API and may change in later releases.

The default data types of the DMN engine can be extended or replaced by custom types. For example, you can add a new type for time or change the transformation to support a different date format or localized boolean constants.

To do this, implement a new DmnDataTypeTransformer . The transformation is processed in the transform() method and returns a typed value. If it cannot successfully transform a value, it must throw an IllegalArgumentException.

public class CustomDataTypeTransformer implements DmnDataTypeTransformer {

  public TypedValue transform(Object value) throws IllegalArgumentException {
    // transform the value into a typed value
    return typedValue;
  }
}

To use this data type transformer in the DMN engine, add it to the DMN engine configuration.

On this Page: