Interface DataTransformer

public interface DataTransformer

Specifies interface for data transformation. Some of your application's class should implement this DataTransformer in order to be used by Makumba during DB operations.

In your db configuration file (e.g. it should be specified with a line

to run your transformer (yourClassThatImplementsDataTransformer) on all the records of that makumba type (makumba.Type) before being inserted into the database.


with a simple DataTransformer class PersonHook:
 import org.makumba.*;
 import java.util.*;
 public class PersonHook implements DataTransformer {
     public boolean transform(Dictionary d, Database db) {
         //we might want to make sure a name is all lowercase with capital initial:
         String n= (String)d.get("name");
         if(n!=null && n.trim().length()>2) {
             d.put("name", n.substring(0,1).toUpperCase()+n.substring(1).toLowerCase());
             return true
         } else {
             return false;
Would ensure that application writes only "properly capitalized" names to the DB, wherever in the application objects of type general.Person would be created.

Method Summary
 boolean transform(Dictionary<String,Object> d, Transaction db)
          Performs the data transformation.

Method Detail


boolean transform(Dictionary<String,Object> d,
                  Transaction db)
Performs the data transformation.

d - data to transform
db - database
true if specified database operation should be done (eg data transformed successfully or data is valid), false otherwise.