@ -916,8 +916,8 @@ public class MyService {
@@ -916,8 +916,8 @@ public class MyService {
It addresses <emphasis>one-way</emphasis> conversion from one type to another and is not limited to just converting Strings.
As discussed in the previous section, a Spring Container can be configured to use this system to bind bean property values.
In addition, the Spring Expression Language (SpEL) uses this system to coerce Expression values.
For example, when SpEL needs to coerce a <classname>Short</classname> to a <classname>Long</classname> to fullfill an
<function>expression.setValue()</function> attempt, the core.convert system performs the coersion.
For example, when SpEL needs to coerce a <classname>Short</classname> to a <classname>Long</classname> to fulfill an
<function>expression.setValue()</function> attempt, the core.convert system performs the coercion.
</para>
<para>
Now consider the type conversion requirements of a typical UI environment such as a web or desktop application.
@ -1467,7 +1467,7 @@ public class MyController {
@@ -1467,7 +1467,7 @@ public class MyController {
There are scenarios, particularly in large message-oriented business applications, where data and object transformation is required.
For example, consider a complex Web Service where there is a separation between the data exchange model and the internal domain model used to structure business logic.
In cases like this, a general-purpose data mapping facility can be useful for automating the mapping between these disparate models.
Spring 3 introduces such a facility built on the <linklinkend="expressions-intro">Spring Expression Language</link> (SpEl).
Spring 3 introduces such a facility built on the <linklinkend="expressions-intro">Spring Expression Language</link> (SpEL).
This facility is described in this section.
</para>
<sectionid="mapping-Mapping-API">
@ -1523,12 +1523,10 @@ public class PersonDtoPersonMapper implements Mapper<PersonDto, Person> {
@@ -1523,12 +1523,10 @@ public class PersonDtoPersonMapper implements Mapper<PersonDto, Person> {
</para>
<programlistinglanguage="java"><![CDATA[
SpelMapper mapper = new SpelMapper();
mapper.map(aSource, aTarget);
]]>
</programlisting>
mapper.map(aSource, aTarget);]]></programlisting>
<para>
By default, SpelMapper will map the fields on the source and target that have the same names.
If the field types differ, the mapping system will attempt a type coersion using Spring 3's <linklinkend="core.convert">type conversion system</link>.
If the field types differ, the mapping system will attempt a type conversion using Spring 3's <linklinkend="core.convert">type conversion system</link>.
Nested bean properties are mapped recursively.
Any mapping failures will trigger a MappingException to be thrown.
If there are multiple failures, they will be collected and returned in the MappingException thrown to the caller.
@ -1546,9 +1544,7 @@ public class CreateAccountDto {
@@ -1546,9 +1544,7 @@ public class CreateAccountDto {
private String street;
private String zip;
}
}
]]>
</programlisting>
}]]></programlisting>
<para>
And the following target object type:
</para>
@ -1564,9 +1560,7 @@ public class Account {
@@ -1564,9 +1560,7 @@ public class Account {
private String state;
private String zip;
}
}
]]>
</programlisting>
}]]></programlisting>
<para>
Used in the following test case:
</para>
@ -1592,9 +1586,7 @@ public void testDefaultSpelMappingBehavior() {
@@ -1592,9 +1586,7 @@ public void testDefaultSpelMappingBehavior() {
In this example, the <literal>number</literal>, <literal>name</literal>, and <literal>address</literal> properties are automatically mapped since they are present on both the source and target objects.
The AccountDto's <literal>address</literal> property is a JavaBean, so its nested properties are also recursively mapped.
@ -1611,10 +1603,7 @@ public void testDefaultSpelMappingBehavior() {
@@ -1611,10 +1603,7 @@ public void testDefaultSpelMappingBehavior() {
Since the two property names are not the same, default auto-mapping would never be performed.
Handle a situation like this by explicitly registering a mapping rule: