com.univocity.api.config.builders
Interface FieldMappingSetup


public interface FieldMappingSetup

The FieldMappingSetup is the base configuration used to define what fields should be read from a source entity in an EntityMapping.

Author:
uniVocity Software Pty Ltd - dev@univocity.com
See Also:
EntityMapping, RowReader, FunctionCall

Method Summary
 CopyToMultipleFields copy(String... sourceFields)
          Copies values of multiple fields from the source entity in an EntityMapping and writes them to multiple fields in the destination entity.
 CopyToSingleField copy(String sourceField)
          Copies the value of one field from the source entity in an EntityMapping and writes it to a field in the destination entity.
 Merge merge(String... sourceFields)
          Takes values of multiple fields from the source entity in an EntityMapping and merges them into a single value using a function.
 CopyTransform read(String... sourceFields)
          Reads values of multiple fields from the source entity in an EntityMapping, but does not transfer them to the destination.
 Split split(String sourceField)
          Selects a field from the source entity in an EntityMapping to be split into multiple values using a function.
 

Method Detail

split

Split split(String sourceField)
Selects a field from the source entity in an EntityMapping to be split into multiple values using a function.

Example:


 //Splits "field_name" using "split_function" to generate values to "field_1" and "field_2" in the destination entity.

  mapping.value().split("field_name").with("split_function").into("field_1", "field_2");
 

Parameters:
sourceField - the field name in the source entity to be split into multiple values. Expressions are allowed within curly braces (i.e. "{expression}")
Returns:
the next step of this configuration: define a split function that will process values read from the given field.

merge

Merge merge(String... sourceFields)
Takes values of multiple fields from the source entity in an EntityMapping and merges them into a single value using a function.

Example:


  //Merges "item", "price" and the result of the function "getDate()" using "pipe_separator_function"
  //to generate a single value for the field "receipt" in the destination entity.

  mapping.value().merge("item", "price", "{getDate()}").using("pipe_separator_function").into("receipt");
 

Parameters:
sourceFields - the field names in the source entity to be split into multiple values. Expressions are allowed within curly braces (i.e. "{expression}")
Returns:
the next step of this configuration: define a merge function that will process values read from the given fields.

copy

CopyToSingleField copy(String sourceField)
Copies the value of one field from the source entity in an EntityMapping and writes it to a field in the destination entity.

Example:


  //Copies "CHO_Factor" to "carbohydrate_factor".

  mapping.value().copy("CHO_Factor").to("carbohydrate_factor");

  //copies the result of an expression, in this case the value of the variable "version", to "version_number".
  mapping.value().copy("{$version}").to("version_number");
 

Parameters:
sourceField - the field name in the source entity to have its value copied to the a field in the destination. Expressions are allowed within curly braces (i.e. "{expression}")
Returns:
the next step of this configuration: define which destination fields will receive the values read from the given field names.

copy

CopyToMultipleFields copy(String... sourceFields)
Copies values of multiple fields from the source entity in an EntityMapping and writes them to multiple fields in the destination entity.

Example:


  //Copies "CHO_Factor", "Fat_Factor" and "Pro_Factor" to "carbohydrate_factor", "fat_factor" and "protein_factor" respectively.

  mapping.value().copy("CHO_Factor", "Fat_Factor", "Pro_Factor").to("carbohydrate_factor", "fat_factor", "protein_factor");
 

Parameters:
sourceFields - the field names in the source entity to have their values copied to the same number of fields in the destination. Expressions are allowed within curly braces (i.e. "{expression}")
Returns:
the next step of this configuration: define which destination fields will receive the values read from the given field names.

read

CopyTransform read(String... sourceFields)
Reads values of multiple fields from the source entity in an EntityMapping, but does not transfer them to the destination. This is used to obtain values from the input that might be required for custom processing such as logging, statistics or generating data structures and objects. These values will be available to RowReaders while executing the mapping.

Example:


  //Reads "CHO_Factor" and "Fat_Factor"  to memory for custom processing.
  mapping.value().read("CHO_Factor", "Fat_Factor");
 

Parameters:
sourceFields - the field names in the source entity to have their values loaded in memory for processing. Expressions are allowed within curly braces (i.e. "{expression}")
Returns:
the next step of this configuration: define functions applied to each value read.


Copyright © 2015 uniVocity Software Pty Ltd. All rights reserved.