com.ibm.commerce.foundation.dataload.config

Interface ValueHandler

  • All Known Implementing Classes:
    AbstractValueHandler, PatternValueHandler


    public interface ValueHandler
    This class defines the interface for the custom extension to handle the value in the BusinessObjectBuilder configuration. It will be used in the BusinessObjectBuilder.

    The main purpose for the ValueHandler is when your input value cannot be simply mapped to a field in the business object. For example, if in the input, you only have a logon ID, but in the business object, you only have a field which expects the user internal unique ID. You need a value handler to resolve the user internal unique ID based on the input logon ID. Another example is that if your input data contain Y or N, but the business object field expects true or false. You can have a value handler to convert Y to true and N to false.

    The BusinessObjectBuilder will only create one instance of the implementation class if the same implementation class is specified in more than one places in the BusinessObjectBuilder configuration. So the resolveValue() method resolving value should only depend on the input parameters, not on the position you defined in the configuration file.

    When defining the value handler in the configuration, it can associate with a list of parameters which are name-value pairs. These name value pairs will be passed to the resolveValue method as a parameter map.

    All implementation classes should extend from the AbstractValueHandler class.

    See Also:
    AbstractValueHandler
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String COPYRIGHT
      IBM Copyright notice field.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method and Description
      void close()
      Close the class to release any resources it used.
      void init()
      Initializes the instance.
      java.lang.String resolveValue(java.lang.String inputValue, java.util.Map<java.lang.String,java.lang.String> parameterMap, java.lang.Object dataObject)
      Resolve the value based on the input value and parameters passed in.
    • Field Detail

      • COPYRIGHT

        static final java.lang.String COPYRIGHT
        IBM Copyright notice field.
        See Also:
        Constant Field Values
    • Method Detail

      • init

        void init()
           throws DataLoadException
        Initializes the instance. This method will be called only once before any lines in the CSV file are processed.
        Throws:
        DataLoadException - if there are some errors.
      • resolveValue

        java.lang.String resolveValue(java.lang.String inputValue,
                                      java.util.Map<java.lang.String,java.lang.String> parameterMap,
                                      java.lang.Object dataObject)
                               throws DataLoadException
        Resolve the value based on the input value and parameters passed in. The value handler will be called during each CSV line is processed. Most implementation classes will resolve the value only depending on the input value and the parameter map. The dataObject is provided in case you need to use some data from the dataObject.
        Parameters:
        inputValue - an input value
        parameterMap - a parameter map is name-value pairs defined in the configuration.
        dataObject - the current business object being populated.
        Returns:
        resolved new value
        Throws:
        DataLoadException - if there are some errors to resolve the value.
      • close

        void close()
        Close the class to release any resources it used. This method will be called only once after all lines in the CSV file are processed.