@ -754,7 +754,7 @@ public final class CustomPropertyEditorRegistrar implements PropertyEditorRegist
@@ -754,7 +754,7 @@ public final class CustomPropertyEditorRegistrar implements PropertyEditorRegist
Spring 3 introduces a <filename>core.convert</filename> package that provides a general type conversion system.
The system defines a SPI to implement type conversion logic, as well as a API to execute type conversions at runtime.
Within a Spring container, if configured, this system can be used as an alternative to PropertyEditors to convert externalized bean property value strings to required property types.
The public API may also be used anywhere in your application where type coersion is needed.
The public API may also be used anywhere in your application where type conversion is needed.
</para>
<sectionid="core-convert-Converter-SPI">
<title>Converter SPI</title>
@ -769,12 +769,12 @@ public interface Converter<S, T> {
@@ -769,12 +769,12 @@ public interface Converter<S, T> {
}]]>
</programlisting>
<para>
To create your own Converter, simply implement the Converter interface.
To create your own Converter, simply implement the interface above.
Parameterize S as the type you are converting from, and T as the type you are converting to.
For each call to convert(S), the source argument is guaranteed to be NOT null.
Your Converter may throw any Exception if conversion fails.
An IllegalArgumentException is often thrown to report an invalid source value.
Take special care to ensure your Converter implementation is thread safe.
Take care to ensure your Converter implementation is thread safe.
</para>
<para>
Several converter implementations are provided in the <filename>core.convert.converters</filename> package as a convenience.
@ -791,6 +791,47 @@ public class StringToInteger implements Converter<String, Integer> {
@@ -791,6 +791,47 @@ public class StringToInteger implements Converter<String, Integer> {
}]]>
</programlisting>
</section>
<sectionid="core-convert-ConverterFactory-SPI">
<title>ConverterFactory</title>
<para>
When you need to centralize the conversion logic for an entire class hierarchy, for example, when converting from String to java.lang.Enum objects, implement a ConverterFactory:
@ -809,7 +850,7 @@ public interface ConversionService {
@@ -809,7 +850,7 @@ public interface ConversionService {
</programlisting>
<para>
Most ConversionService implementations also implement <interface>ConverterRegistry</interface>, which provides a SPI for registering converters.
Internally, a ConversionService implementation delegates to its registered Converters to carry out type conversion logic.
Internally, a ConversionService implementation delegates to its registered Converters and ConverterFactories to carry out type conversion logic.
</para>
<para>
Two ConversionService implementations are provided with the system in the <filename>core.convert.support</filename> package.
@ -870,7 +911,7 @@ public class MyService {
@@ -870,7 +911,7 @@ public class MyService {
<sectionid="ui.format">
<title>Spring 3 UI Field Formatting</title>
<para>
The <filename>core.convert</filename> is a simple, general-purpose type conversion system.
<filename>core.convert</filename> is a simple, general-purpose type conversion system.
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 when binding bean property values.
In addition, the Spring Expression Language (SpEL) uses this system to coerce Expression values.
@ -953,7 +994,7 @@ public final class DateFormatter implements Formatter<Date> {
@@ -953,7 +994,7 @@ public final class DateFormatter implements Formatter<Date> {
</programlisting>
<para>
The Spring team welcomes community-driven Formatter contributions; see <ulinkurl="http://jira.springframework.org">http://jira.springframework.org</ulink> to contribute.
In particular, the team expects to integrate support for Joda Time and Money Formatters in the future.
In particular, the team hopes to integrate support for Joda Time and Money Formatters in the future.
</para>
</section>
<sectionid="ui-format-Formatted-Annotation">
@ -1036,7 +1077,7 @@ public class MyModel {
@@ -1036,7 +1077,7 @@ public class MyModel {