1 16 package net.sf.dozer.util.mapping; 17 18 import net.sf.dozer.util.mapping.MappingException; 19 import net.sf.dozer.util.mapping.fieldmap.ClassMap; 20 import net.sf.dozer.util.mapping.fieldmap.FieldMap; 21 import net.sf.dozer.util.mapping.vo.CustomDoubleObject; 22 import net.sf.dozer.util.mapping.vo.CustomDoubleObjectIF; 23 import net.sf.dozer.util.mapping.vo.SimpleObj; 24 import net.sf.dozer.util.mapping.vo.SimpleObjPrime; 25 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 29 32 public class TestCustomFieldMapper implements CustomFieldMapperIF { 33 34 public static String FIELD_VALUE = "This field was set on the dest object by the TestCustomFieldMapper"; 35 36 public boolean mapField(Object sourceObj, Object destObj, Object sourceFieldValue, 37 ClassMap classMap, FieldMap fieldMapping) { 38 boolean result = false; 39 40 if (!(sourceObj instanceof SimpleObj)) { 41 throw new MappingException("Unsupported source object type. Should be of type: SimpleObj"); 42 } 43 44 if (!(destObj instanceof SimpleObjPrime)) { 45 throw new MappingException("Unsupported dest object type. Should be of type: SimpleObjPrime"); 46 } 47 48 if (fieldMapping.getSourceField().getName().equals("field1")) { 49 ((SimpleObjPrime) destObj).setField1(FIELD_VALUE); 50 result = true; 51 } 52 53 return result; 54 } 55 56 } | Popular Tags |