基本属性映射
不用显式的属性映射 ( 双向 )
属性名字相同就不需要在 mapping xml 文件中详细指定映射关系 ,Dozer 会自动映射处理
简单类型的映射 ( 双向 )
以下用一个简单例子做为开始 , 如果你两个属性拥有不同的属性名 , 你可以做如下映射
<field>
<a>one</a>
<b>onePrime</b>
</field>
类型转换
Dozer 引擎会自动进行类型转换 , 目前 ,Dozer 支持如下的类型转换 ( 都是双向的 )
Primitive 基本数据类型 , 后面带 Wrapper 是包装类 Complex Type 是复杂类型
下面的就不翻译了 , 一些数据类型翻译起来累
- Primitive to Primitive Wrapper
- Primitive to Custom Wrapper
- Primitive Wrapper to Primitive Wrapper
- Primitive to Primitive
- Complex Type to Complex Type
- String to Primitive
- String to Primitive Wrapper
- String to Complex Type if the Complex Type contains a String constructor
- String 到复杂类型 , 如果复杂类型包含一个 String 类型的构造器
- String to Map
- Collection to Collection
- Collection to Array
- Map to Complex Type
- Map to Custom Map Type
- Enum to Enum
- Each of these can be mapped to one another: java.util.Date, java.sql.Date, java.sql.Time, java.sql.Timestamp, java.util.Calendar, java.util.GregorianCalendar
- String to any of the supported Date/Calendar Objects.
- Objects containing a toString() method that produces a long representing time in (ms) to any supported Date/Calendar object.
Recursive Mapping (bi-directional)
Dozer 支持类之间的水平复制 , 如果你定义了复杂类型的字段 ,Dozer 将查找 2 个类之间的映射文件 , 日过你没有定义映射关系 , 那么将只复制名字相同的字段