Class TLcdDataTypeMapping

java.lang.Object
com.luciad.datamodel.transformation.TLcdDataTypeMapping

public class TLcdDataTypeMapping extends Object

This class is used to build an ILcdObjectTransformation that transforms instances of one data object type into another data object type. This transformation transforms source data objects into target data objects by transforming the data properties of the source data objects one by one using ILcdDataPropertyTransformation instances.

  • Constructor Details

    • TLcdDataTypeMapping

      public TLcdDataTypeMapping(TLcdDataType aSourceType, TLcdDataType aTargetType)
      Creates a new data type mapping. Properties on the source data with null value will not be transformed by default.
      Parameters:
      aSourceType - the source type
      aTargetType - the target type
    • TLcdDataTypeMapping

      public TLcdDataTypeMapping(TLcdDataType aSourceType, TLcdDataType aTargetType, boolean aTransformEmptyProperties)
      Creates a new data type mapping.
      Parameters:
      aSourceType - the source type
      aTargetType - the target type
      aTransformEmptyProperties - indicates whether the created transformations should make an attempt to transform properties without a value. This may be useful if a null value in the source data should be mapped onto a non-null default value in the target data.
  • Method Details

    • getTargetType

      public TLcdDataType getTargetType()
    • getSourceType

      public TLcdDataType getSourceType()
    • mapProperty

      public void mapProperty(String aSourceProperty, ILcdDataPropertyTransformation aTransformation)
      Maps the given source property using the given transformation on the target object.
      Parameters:
      aSourceProperty - the source property
      aTransformation - the transformation that is to be used to transform values for the given source property
    • mapProperty

      public void mapProperty(TLcdDataProperty aSourceProperty, ILcdDataPropertyTransformation aTransformation)
      Maps the given source property using the given transformation on the target object. This property mapping is always uni-directional. To make the type mapping bi-directional, probably additional property mappings need to be registered on this object's inverse type mapping.
      Parameters:
      aSourceProperty - the source property to map
      aTransformation - the transformation to use to map the source property
    • mapProperty

      public void mapProperty(String aSourceProperty, String aTargetProperty)
      Maps the source property with the given name on the target property with the given name.
      Parameters:
      aSourceProperty - the source property
      aTargetProperty - the target property
      See Also:
    • mapProperty

      public void mapProperty(TLcdDataProperty aSourceProperty, TLcdDataProperty aTargetProperty)
      Maps the given source property on the target property. Transformations created by this mapping will convert values of the source property to values acceptable for the target property using the object transformation provider that is given as argument when creating the transformations.
      Parameters:
      aSourceProperty - the source property
      aTargetProperty - the target property
    • mapProperty

      public void mapProperty(String aSourceProperty, String aTargetProperty, ILcdObjectTransformation aTransformation)
      Maps the source property with the given name on the target property with the given name. Source values are transformed into target values using the given transformation
      Parameters:
      aSourceProperty - the source property
      aTargetProperty - the target property
      aTransformation - the transformation used to transform source values into target values
    • mapProperty

      public void mapProperty(TLcdDataProperty aSourceProperty, TLcdDataProperty aTargetProperty, ILcdObjectTransformation aTransformation)
      Maps the given source property on the given target property. Source values are transformed into target values using the given transformation
      Parameters:
      aSourceProperty - the source property
      aTargetProperty - the target property
      aTransformation - the transformation used to transform source values into target values
    • mapTargetProperty

      public void mapTargetProperty(String aTargetProperty, ILcdObjectTransformation aTransformation)

      Maps the given target property using the given transformation. The transformation should transform instances of this object's source type into appropriate values for the given target property. This property mapping is always uni-directional. To make the type mapping bi-directional, additional property mappings have to be registered on this object's inverse type mapping.

      This method is for instance used to map properties whose values depends on the value of multiple source properties.

      Parameters:
      aTargetProperty - the name of the target property
      aTransformation - the transformation used to transform a source instance into a value for the target property
    • mapTargetProperty

      public void mapTargetProperty(TLcdDataProperty aTargetProperty, ILcdObjectTransformation aTransformation)

      Maps the given target property using the given transformation. The transformation should transform instances of this object's source type into appropriate values for the given target property.

      This method is for instance used to map properties whose values depends on the value of multiple source properties.

      Parameters:
      aTargetProperty - the target property
      aTransformation - the transformation used to transform a source instance into a value for the target property
    • getInverse

      public TLcdDataTypeMapping getInverse()
      Returns the inverse of this mapping. The inverse is typically used in case properties are not mapped one-on-one from source type to target type.
      Returns:
      the inverse of this mapping
    • createTransformation

      public ILcdObjectTransformation createTransformation(TLcdObjectTransformationProvider aProvider)

      Creates and returns a transformation that is capable of transforming instances of the source type into instances of the target type.

      The returned object transformation transforms objects as follows:

      1. A new instance is created of the target type using type.newInstance().
      2. Each source property for which a mapping is provided (using one of the mapProperty methods) is transformed. The order in which the property transformations are applied is implementation dependent and should not be relied upon.
      3. The new target instance is returned.

      Parameters:
      aProvider - the transformation provider
      Returns:
      a transformation that is capable of transforming instances of the source type into instances of the target type