Skip to main content
Pentaho Documentation

Work With Fields

Data Type

ValueMetaInterface objects are used to determine the characteristics of the row fields. They are typically obtained from a RowMetaInterface object, which is acquired by a call to getInputRowMeta(). The getType() method returns one of the static constants declared by ValueMetaInterface to indicate the PDI field type. Each field type maps to a corresponding native Java type for the actual value. The following table illustrates the mapping of the most frequently used field types.

PDI data type Type constant Java data type Description 
String TYPE_STRING java.lang.String A variable unlimited length text encoded in UTF-8 (Unicode) 
Integer TYPE_INTEGER java.lang.Long A signed long 64-bit integer 
Number TYPE_NUMBER java.lang.Double A double precision floating point value 
BigNumber TYPE_BIGNUMBER java.math.BigDecimal An arbitrary unlimited precision number 
Date TYPE_DATE java.util.Date A date-time value with millisecond precision 
Boolean TYPE_BOOLEAN java.lang.Boolean A boolean value true or false
Binary TYPE_BINARY java.lang.byte[] An array of bytes that contain any type of binary data.

Do not assume that the Java value of a row field matches these data types directly. This may or may not be true, based on the storage type used for the field. 

Storage Types

In addition to the data type of a field, the storage type, getStorageType()/setStorageType(), is used to interpret the actual field value in a row array. These storage types are available.

Type constant Actual field data type Interpretation 
STORAGE_TYPE_NORMAL As listed in previous table The value in the row array is of the type listed in the data type table above and represents the field value directly.
STORAGE_TYPE_BINARY_STRING  java.lang.byte[] The field has been created using the Lazy Conversion feature. This means it is a non-altered sequence of bytes as read from an external medium, usually a file. 
STORAGE_TYPE_INDEXED java.lang.Integer The row value is an integer index into a fixed array of possible values. The ValueMetaInterface object maintains the set of possible values in getIndex()/setIndex()

Accessing Row Values

In a typical data processing scenario, a step is not interested in dealing with the complexities of the storage type. It just needs the actual data value on which to do processing. In order to safely read the value of a field, the ValueMetaInterface object provides a set of accessor methods to get at the actual Java value. The argument is a value from a row array that corresponds to the ValueMetaInterface object. The accessor methods always return a proper data value, regardless of the field storage type.

  • getString()
  • getInteger()
  • getNumber()
  • getBigNumber()
  • getDate()
  • getBoolean()
  • getBinary()

For each of these methods, RowMetaInterface has corresponding methods that require the row array and the index of the field as arguments.

Additional Field Characteristics

ValueMetaInterface represents all aspects of a PDI field, including conversion masks, trim type, and alike. All of these are available using corresponding accessor methods, such as getConversionMask() and getTrimType(). Refer to the Javadoc for a complete overview.