Predefined transformers

The transformers specified here are registered at DataSift startup, and are always available to the user without further configuration.

  1. Object transformers
  2. Map transformers
  3. String transformers
  4. Iterating transformers

Object transformers

Identity

Data parameterTypeDescription
datajava.lang.Object Piece of data to be passed (no transformations done).

Map transformers

MapAsBean

Config parameterTypeRequiredDefault valueDescription
beanClassNamejava.lang.StringYes Class name for the object (bean) which will be instantiated.
setPropertiesjava.lang.String[]Yes Names of the properties which will be set in the bean. The value for each of these properties (e.g. property anything) will be retrieved from the Map and set into the bean (e.g. setAnything(value) would be called).

Many property names may be declared separated by spaces.
Data parameterTypeDescription
datajava.lang.Map Piece of data to be transformed.

MultivaluedMapAsBeanMap

Config parameterTypeRequiredDefault valueDescription
beanClassNamejava.lang.StringYes Class name for the object (bean) which will be instantiated for each index in the multivalued map.
setPropertiesjava.lang.String[]Yes Names of the properties which will be set in the beans. The value for each of these properties (e.g. property anything) will be retrieved from the Map and set into each of the corresponding beans (e.g. setAnything(value) would be called).

Many property names may be declared separated by spaces.
Data parameterTypeDescription
datajava.lang.Map Piece of data to be transformed. This will be a Map with String keys, containing keys such as anything1 or anything2. This will be transformed into a Map with two keys: "1" and "2", each of them containing as a value a bean of class beanClassName on which the setAnything() method will have been called with the correspondent values.

MultivaluedMapAsMapsMap

Config parameterTypeRequiredDefault valueDescription
setPropertiesjava.lang.String[]Yes Names of the properties which will be set in the result maps. The value for each of these properties (e.g. property anything) will be retrieved from the source Map and set into the corresponding (by index) result Map (e.g. put("anything",value) would be called).

Many property names may be declared separated by spaces.
Data parameterTypeDescription
datajava.lang.Map Piece of data to be transformed. This will be a Map with String keys, containing keys such as anything1 or anything2. This will be transformed into a Map with two keys: "1" and "2", each of them containing as a value a Map on which the put("anything",value) method will have been called with the correspondent values.

String transformers

StringAsBoolean

Config parameterTypeRequiredDefault valueDescription
trimjava.lang.BooleanNoBoolean.TRUE Trim the String before transforming it.
nullAsFalsejava.lang.BooleanNoBoolean.TRUE Convert null values into false boolean values.
Data parameterTypeDescription
datajava.lang.String Piece of data to be transformed.

StringAsCalendar

Config parameterTypeRequiredDefault valueDescription
trimjava.lang.BooleanNoBoolean.TRUE Trim the String before transforming it.
patternjava.lang.StringYes Date pattern to use for matching. This pattern will be defined as specified in java.text.SimpleDateFormat. Only the date fields present in this pattern will be set in the resulting Calendar instance.
localejava.lang.StringNo(Default locale) Locale to be used for date constants (month names, etc). For instance: "es", "es_ES", "es_ES.UTF-8"...
Data parameterTypeDescription
datajava.lang.String Piece of data to be transformed.

StringAsDouble

Config parameterTypeRequiredDefault valueDescription
trimjava.lang.BooleanNoBoolean.TRUE Trim the String before transforming it.
Data parameterTypeDescription
datajava.lang.String Piece of data to be transformed.

StringAsFloat

Config parameterTypeRequiredDefault valueDescription
trimjava.lang.BooleanNoBoolean.TRUE Trim the String before transforming it.
Data parameterTypeDescription
datajava.lang.String Piece of data to be transformed.

StringAsInteger

Config parameterTypeRequiredDefault valueDescription
trimjava.lang.BooleanNoBoolean.TRUE Trim the String before transforming it.
Data parameterTypeDescription
datajava.lang.String Piece of data to be transformed.

StringAsUrl

Config parameterTypeRequiredDefault valueDescription
trimjava.lang.BooleanNoBoolean.TRUE Trim the String before transforming it.
Data parameterTypeDescription
datajava.lang.String Piece of data to be transformed (result will be a java.net.URL object).

StringExtractPattern

Config parameterTypeRequiredDefault valueDescription
trimjava.lang.BooleanNoBoolean.TRUE Trim the String before transforming it.
patternjava.lang.StringYes Pattern (as defined by java.util.regex.Pattern) to be used for matching.
patternGroupjava.lang.StringNo0 Group to be extracted from the pattern (as defined by java.util.regex.Matcher).
Data parameterTypeDescription
datajava.lang.String Piece of data to be transformed.

StringTrim

Data parameterTypeDescription
datajava.lang.String Piece of data to be transformed (string which will be trimmed).

SubString

Config parameterTypeRequiredDefault valueDescription
trimjava.lang.BooleanNoBoolean.TRUE Trim the String before transforming it.
Data parameterTypeDescription
datajava.lang.String Piece of data to be transformed.

Iterating transformers

ArrayIterator

This transformer iterates on an array object and applies to each of its items all the transformations declared as nested for this iterator. As a result, it returns:

  • If the successCondition is met, it will return an array of java.util.Map objects, one for each item in the target array which transformation had been successful. Each of these Maps will be in the same format as the one obtained by calling getResults() on a TransformationResult object (this is, will contain either the transformed objects or ResolutionNotPossibleException exceptions).


  • If the successCondition is not met, it will throw a ResolutionNotPossibleException.

Config parameterTypeRequiredDefault valueDescription
successConditionjava.lang.StringNoAND Condition to apply on the results of the iteration items to consider the array transformation as successful. Possible values:
  • AND: All the items must be transformed OK.
  • OR: At least one item must be transformed OK.
  • EXOR: Only one item must be transformed OK.
  • NEXOR: Either none or all of the items must be transformed OK.
Data parameterTypeDescription
datajava.lang.Object[] Piece of data to be validated.

CollectionIterator

This transformer iterates on a Collection object and applies to each of its items all the transformations declared as nested for this iterator. As a result, it returns:

  • If the successCondition is met, it will return a Collection of java.util.Map objects, one for each item in the target collection which transformation had been successful. Each of these Maps will be in the same format as the one obtained by calling getResults() on a TransformationResult object (this is, will contain either the transformed objects or ResolutionNotPossibleException exceptions).


  • If the successCondition is not met, it will throw a ResolutionNotPossibleException.

Config parameterTypeRequiredDefault valueDescription
successConditionjava.lang.StringNoAND Condition to apply on the results of the iteration items to consider the collection transformation as successful. Possible values:
  • AND: All the items must be transformed OK.
  • OR: At least one item must be transformed OK.
  • EXOR: Only one item must be transformed OK.
  • NEXOR: Either none or all of the items must be transformed OK.
Data parameterTypeDescription
datajava.util.Collection Piece of data to be validated.

MapIterator

This transformer iterates on a Map object and applies to each of its entries all the transformations declared as nested for this iterator. As a result, it returns:

  • If the successCondition is met, it will return a Map with the same keys as the target Map object and java.util.Map objects as values, one for each item in the target Map which transformation had been successful. Each of these value Maps will be in the same format as the one obtained by calling getResults() on a TransformationResult object (this is, will contain either the transformed objects or ResolutionNotPossibleException exceptions).


  • If the successCondition is not met, it will throw a ResolutionNotPossibleException.

Config parameterTypeRequiredDefault valueDescription
successConditionjava.lang.StringNoAND Condition to apply on the results of the iteration items to consider the map transformation as successful. Possible values:
  • AND: All the items must be transformed OK.
  • OR: At least one item must be transformed OK.
  • EXOR: Only one item must be transformed OK.
  • NEXOR: Either none or all of the items must be transformed OK.
Data parameterTypeDescription
datajava.util.Map Piece of data to be validated.