public interface ColumnHandler
The main purpose of the ColumnHandler is to resolve the column value based on the input values which cannot be simply mapped to the column value through the configuration. For example, to populate the password column in the database, your input is a clear text password, but the column in the database expects an encrypted value, you need to write a column handler to encrypt the clear password and return an encrypted password from the method resolveColumnValue().
The TableObjectMediator will only create one instance of the ColumnHandler implementation class if the same implementation class is specified in more than one places in the TableObjectBuilder configuration. So the resolveColumnValue() method resolving value should only depend on the input parameters, not the position you defined in the configuration file.
When defining the column 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 resolveColumnValue method as a parameter map.
All implementation classes should extend from the AbstractColumnHandler class.
AbstractColumnHandler
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COPYRIGHT
IBM Copyright notice field.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the class to release any resources it used, such as jdbc prepared statements.
|
void |
init()
Initializes the instance, such as creating some prepared statements to access the database.
|
java.lang.String |
resolveColumnValue(java.util.Map<java.lang.String,java.lang.String> parameterMap,
ExtendedTableDataObject extenededTableDataObject)
Resolve the column value based on the input parameters passed in.
|
static final java.lang.String COPYRIGHT
void init() throws DataLoadException
DataLoadException
- if there are some errors.java.lang.String resolveColumnValue(java.util.Map<java.lang.String,java.lang.String> parameterMap, ExtendedTableDataObject extenededTableDataObject) throws DataLoadException
The column handler will be called during each CSV line is processed.
For example, if you define the following parameters in the ColumnHandler configuration:
<_config:Parameter name="LOGONID" value="logonId" />the parameter map will contain the map from LOGONID to the value of logonId. Most implementation classes will resolve the column value only depending on the parameter map. The extenededTableDataObject is provided in case you need to use some values from the extenededTableDataObject.
parameterMap
- a parameter map which are name-value pairs
defined in the configuration.extenededTableDataObject
- the current table data object which contains
the table configuration and some column values which have been
resolved so far. You can also modify the object to update some column values.DataLoadException
- if there are some errors to resolve the value.void close()