Field Mapping
Predefined Field Value Mappers
When defining the fields to extract using responseGenerator.handlers.handlerName.fields.fieldName.mapperName
, you can specify the
name of a pre-registered field value mapper. Predefined Field Value Mappers describes the available pre-registered
mappers.
Mapper | Description |
---|---|
dayOfWeek | Takes an ISO date time value and converts it to the name of the
day of the week represented by the value: MONDAY ,
TUESDAY , WEDNESDAY ,
THURSDAY , FRIDAY ,
SATURDAY , or SUNDAY . |
dayOfMonth | Takes an ISO date time value and converts it to the number of the day of the month represented by the value: 1 to 31. |
monthOfYear | Converts an ISO date/time value to the name of a month as represented by: JANUARY , FEBRUARY , MARCH ,
APRIL , MAY , JUNE , JULY , AUGUST , SEPTEMBER ,
OCTOBER , NOVEMBER , or DECEMBER . |
Direct Field Value Mapping
A map-based field value mapper can be used to convert a raw field value to a new
value using a lookup table. To use this mapper, set the mapperClass
property to com.matrixx.mapping.field.MapBasedFieldValueMapper
and
specify the lookup key-value pairs in the mapperParameters
property.
The following configuration excerpt shows mapping the field value
rawFieldValueOne
to the string one
and
rawFieldValueTwo
to the string two
.
fields:
fieldOne:
path: Path.to.field
mapperClass: com.matrixx.mapping.field.MapBasedFieldValueMapper
mapperParameters:
rawFieldValueOne: "one"
rawFieldValueTwo: "two"
Use the type
property to convert the field value to an integer:
fields:
fieldOne:
path: Path.to.field
mapperClass: com.matrixx.mapping.field.MapBasedFieldValueMapper
type: "integer"
mapperParameters:
rawFieldValueOne: "1"
rawFieldValueTwo: "2"
If the raw field value is not found in the lookup table, the field value is set to
null
. Use the useOriginalValue
mapping
parameter to ensure that the original value is set instead:
fields:
fieldOne:
path: Path.to.field
mapperClass: com.matrixx.mapping.field.MapBasedFieldValueMapper
mapperParameters:
rawFieldValueOne: "one"
rawFieldValueTwo: "two"
useOriginalValue: "true"
Regular Expression Field Value Mapping
A regular expression field value mapper can be used to convert a raw field value that matches a regular expression to a new value. To use this mapper set the
mapperClass
property to com.matrixx.mapping.field.RegexMapBasedFieldValueMapper
. Specify the regular expression and resulting values as the key
value pairs in the mapperParameters
property. The value of the first matching regular expression is used.
The following excerpt shows use of regular expression matching to map the field value
111
to the string one
and 222
to the string two
:
fields:
fieldOne:
path: Path.to.field
mapperClass: com.matrixx.mapping.field.RegexMapBasedFieldValueMapper
mapperParameters:
"^[1]{3}$": "one"
"^[2]{3}$": "two"
Use the type
property to convert the field value to an integer:
fields:
fieldOne:
path: Path.to.field
mapperClass: com.matrixx.mapping.field.RegexMapBasedFieldValueMapper
type: "integer"
mapperParameters:
"^[1]{3}$": "1"
"^[2]{3}$": "2"
If the raw field value is not found in the lookup table, the field value is set to
null
. Use the useOriginalValue
mapping
parameter to ensure that the original value is set instead:
fields:
fieldOne:
path: Path.to.field
mapperClass: com.matrixx.mapping.field.RegexMapBasedFieldValueMapper
mapperParameters:
"^[1]{3}$": "one"
"^[2]{3}$": "two"
useOriginalValue: "true"